Add cookie support

This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2024-08-12 12:34:19 -05:00
parent 97ee67f055
commit 9f90b8edd5

View File

@ -71,16 +71,31 @@
<option value="design5">Design 5 (Circle, varient 2)</option>
</select>
<input class="button" type="button" onclick="drawDesign();" value="Draw design">
<input class="button" id="toggleEasterEgg" type="button" onclick="easterEgg(false);" value="Disable Easter Egg" style="display: none;">
</div>
<script>
function drawDesign() {
let event = document.getElementById('designSelections');
let value = event.options[event.selectedIndex].value;
//alert(value);
let inputText = document.getElementById("inputText").value;
if (inputText.includes("🏳️‍⚧️")) {
inputText += " Trans rights are human rights! 🏳️‍⚧️";
function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
console.log(decodedCookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function easterEgg(easterEggState) {
console.log("Easter egg state is: " + easterEggState);
if (easterEggState) {
document.cookie = "easterEggState=true";
document.body.style.backgroundImage = "url(https://files.calebfontenot.com/blahaj-bl%C3%A5haj.gif)";
document.getElementById("toggleEasterEgg").style.display = "inline";
// change name :3
let siteData = document.getElementsByClassName("info");
console.log(siteData);
@ -88,6 +103,28 @@
console.log(siteData[i]);
siteData[i].innerHTML = siteData[i].innerHTML.replace("Caleb", "Chloe");
}
} else {
document.cookie = "easterEggState=false";
document.body.style.backgroundImage = "url(space.gif)";
document.getElementById("toggleEasterEgg").style.display = "none";
// change name :3
let siteData = document.getElementsByClassName("info");
console.log(siteData);
for (let i = 0; i < siteData.length; ++i) {
console.log(siteData[i]);
siteData[i].innerHTML = siteData[i].innerHTML.replace("Chloe", "Caleb");
}
}
}
easterEgg((/true/).test(getCookie("easterEggState")));
function drawDesign() {
let event = document.getElementById('designSelections');
let value = event.options[event.selectedIndex].value;
//alert(value);
let inputText = document.getElementById("inputText").value;
if (inputText.includes("🏳️‍⚧️")) {
inputText += " Trans rights are human rights! 🏳️‍⚧️";
easterEgg(true);
}
let designText;
switch (value) {