]> git.mxchange.org Git - friendica-addons.git/blob - cookienotice/cookienotice.js
Rename "fetchUrl" and "fetchUrlFull" to "fetch" and "fetchFull"
[friendica-addons.git] / cookienotice / cookienotice.js
1 window.addEventListener("load", function () {
2         var cookiename = 'cncookiesaccepted'
3         var cookie = getCookie(cookiename);
4
5         if (cookie == "") {
6                 document.getElementById('cookienotice-box').style.display = 'block';
7                 document.getElementById('cookienotice-ok-button').onclick = function () {
8                         setCookie(cookiename, 1, 365);
9                         document.getElementById('cookienotice-box').style.display = 'none';
10                 };
11         }
12
13         function setCookie(cname, cvalue, exdays) {
14                 var d = new Date();
15                 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
16                 var expires = "expires=" + d.toUTCString();
17                 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
18         }
19
20         function getCookie(cname) {
21                 var name = cname + "=";
22                 var decodedCookie = decodeURIComponent(document.cookie);
23                 var ca = decodedCookie.split(';');
24                 for (var i = 0; i < ca.length; i++) {
25                         var c = ca[i];
26                         while (c.charAt(0) == ' ') {
27                                 c = c.substring(1);
28                         }
29                         if (c.indexOf(name) == 0) {
30                                 return c.substring(name.length, c.length);
31                         }
32                 }
33                 return "";
34         }
35
36 });