added cookie info to actaddmanual too

This commit is contained in:
Ellpeck 2020-04-02 22:14:53 +02:00
parent b444258f77
commit f8154dc051
6 changed files with 41 additions and 32 deletions

View File

@ -30,7 +30,11 @@
<body>
<div id="sidebar"></div>
<div id="entries"></div>
<div id="entries">
<!-- Cookie notification -->
<script src="../scripts/cookies.js"></script>
<script src="../scripts/cookieinfo.js"></script>
</div>
<script src="index.js"></script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

View File

@ -26,6 +26,12 @@ body {
background-color: white;
}
.alert {
width: 90%;
margin-left: auto;
margin-right: auto;
}
#entries {
margin-left: 300px;
}

View File

@ -28,6 +28,7 @@
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/prettify.js"></script>
<script src="scripts/cookies.js"></script>
<script src="scripts/main.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
@ -79,7 +80,7 @@
<!-- Content -->
<div class="container main">
<!-- Cookie notification -->
<script src="scripts/cookies.js"></script>
<script src="scripts/cookieinfo.js"></script>
<div id="main">
<!-- NOBLOG -->

15
scripts/cookieinfo.js Normal file
View File

@ -0,0 +1,15 @@
if (getCookie("notification") !== "true") {
let notif = "";
notif += '<div class="alert alert-danger alert-dismissible fade show" role="alert">';
notif += "This site uses cookies to store information about your browsing activity.";
notif += "<br>For more information, check out the <a href=\"#privacy\">privacy policy</a>.";
notif += "<br>Have a nice day!";
notif += '<button type="button" class="close" data-dismiss="alert" id="notif-close">';
notif += '<span>&times;</span>';
notif += '</button></div>';
document.write(notif);
$("#notif-close").on("click", function () {
setCookie("notification", "true", 365);
});
}

View File

@ -1,15 +1,14 @@
if (cookieNotification) {
let notif = "";
notif += '<div class="alert alert-danger alert-dismissible fade show" role="alert">';
notif += "This site uses cookies to store information about your browsing activity.";
notif += "<br>For more information, check out the <a href=\"#privacy\">privacy policy</a>.";
notif += "<br>Have a nice day!";
notif += '<button type="button" class="close" data-dismiss="alert" id="notif-close">';
notif += '<span>&times;</span>';
notif += '</button></div>';
document.write(notif);
function getCookie(key) {
let c = document.cookie;
if (!c)
return undefined;
let start = c.indexOf(key + "=") + key.length + 1;
let end = c.indexOf(";", start);
return c.substring(start, end < 0 ? c.length : end);
}
$("#notif-close").on("click", function () {
setCookie("notification", "true", 365);
});
function setCookie(key, value, days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = key + "=" + value + "; expires=" + date.toUTCString();
}

View File

@ -1,5 +1,4 @@
let dark = getCookie("dark") === "true";
let cookieNotification = getCookie("notification") !== "true";
let pride = new Date().getMonth() == 5;
if (dark) {
@ -39,19 +38,4 @@ $(function () {
});
PR.prettyPrint();
});
function getCookie(key) {
let c = document.cookie;
if (!c)
return undefined;
let start = c.indexOf(key + "=") + key.length + 1;
let end = c.indexOf(";", start);
return c.substring(start, end < 0 ? c.length : end);
}
function setCookie(key, value, days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = key + "=" + value + "; expires=" + date.toUTCString();
}
});