new addon - cookienotice - configure, show and handle a simple cookie usage notice
[friendica-addons.git/.git] / cookienotice / templates / head.tpl
1 <!-- <link rel="stylesheet" type="text/css" href="/addon/cookienotice/css/cookienotice.css" /> -->
2 <script>
3     window.addEventListener("load", function () {
4         var cookiename = 'cncookiesaccepted'
5         var cookie = getCookie(cookiename);
6         
7         if (cookie == "") {
8             document.getElementById('cookienotice-box').style.display = 'block';
9             document.getElementById('cookienotice-ok-button').onclick = function () {
10                 console.log('clicked');
11                 setCookie(cookiename, 1, 365);
12                 document.getElementById('cookienotice-box').style.display = 'none';
13             };
14         }
15         
16         function setCookie(cname, cvalue, exdays) {
17             var d = new Date();
18             d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
19             var expires = "expires=" + d.toUTCString();
20             document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
21         }
22         
23         function getCookie(cname) {
24             var name = cname + "=";
25             var decodedCookie = decodeURIComponent(document.cookie);
26             var ca = decodedCookie.split(';');
27             for (var i = 0; i < ca.length; i++) {
28                 var c = ca[i];
29                 while (c.charAt(0) == ' ') {
30                     c = c.substring(1);
31                 }
32                 if (c.indexOf(name) == 0) {
33                     return c.substring(name.length, c.length);
34                 }
35             }
36             return "";
37         }
38
39     });
40 </script>