fuenfknoepfe/fuenfknoepfe.js

62 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2020-07-19 22:32:34 +00:00
// fuenfknoepfe.js - teh ultimate fife buttons website
function click_handler(ziel) {
var chkBox = document.getElementById('rememberBox');
if (chkBox.checked == true) {
setzeKeks(ziel);
} else {
entferneKeks();
}
return false;
}
function setzeKeks(ziel) {
console.log("setzen");
wirklichsetzeKeks(ziel, 30);
}
function entferneKeks() {
console.log("entfernen");
wirklichsetzeKeks("", -1);
}
function wirklichsetzeKeks(ziel, dauer) {
var d = new Date();
d.setTime(d.getTime() + (dauer * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = "ziel=" + ziel + ";" + expires + ";path=/";
}
function allewegefuehrennachKeks() {
var keks = getCookie("ziel");
if (keks != "") {
setzeKeks(keks);
console.log("Do redirect here: " + keks);
// Simulate an HTTP redirect:
// window.location.replace("http://www.w3schools.com");
} else {
console.log("Ohne Keks keine Äktschn.");
}
}
function getCookie(keksname) {
var name = keksname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for (var i = 0; i < ca.length; i++) {
var 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 machkeksweg() {
entferneKeks();
window.location.replace("index.html");
}