Project

General

Profile

1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 *//** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17
 *
18
 * CookieNotice
19
 *
20
 * @category     Template
21
 * @copyright    Manuela v.d.Decken <manuela@isteam.de>
22
 * @author       Manuela v.d.Decken <manuela@isteam.de>
23
 * @license      http://www.gnu.org/licenses/gpl.html   GPL License
24
 * @version      0.0.1
25
 * @lastmodified 19.09.2015
26
 * @since        File available since 04.07.2015
27
 * @description  switch off the cookie notice for n days
28
    (by default after 7 days the cookie will be removed again)
29
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
30

    
31
    function CookieNotice(NoticeAreaId) {
32

    
33
        var CookieLifetime = 7; // lifetime of the cookie in days
34
        var thisObject = this;
35
        this.Box = document.getElementById(NoticeAreaId);
36

    
37
        this.hideNotice = function(e) {
38
            e = e || window.event;
39
            var target = e.target || e.srcElement;
40
            if (target.id == 'CookieNoticeClose') {
41
                thisObject.Box.style.display = 'none';
42
                thisObject.setCookie("CookieNoticeVisible", "none", CookieLifetime);
43
                if (e.stopPropagation) {
44
                    e.stopPropagation();
45
                } else {
46
                    e.cancelBubble = true;
47
                }
48
            }
49
        };
50

    
51
        this.setCookie = function(cname,cvalue,exdays) {
52
            var d = new Date();
53
            d.setTime(d.getTime() + (exdays*86400000));
54
            var expires = "expires=" + d.toGMTString();
55
             document.cookie = cname+"="+cvalue+"; path=/; "+expires;
56
        };
57

    
58
        this.getCookie = function(cname) {
59
            var name = cname + "=";
60
            var ca = document.cookie.split(';');
61
            for(var i=0; i<ca.length; i++) {
62
                var c = ca[i];
63
                while (c.charAt(0)==' ') c = c.substring(1);
64
                if (c.indexOf(name) === 0) {
65
                    return c.substring(name.length, c.length);
66
                }
67
            }
68
            return "";
69
        };
70

    
71
        this.start = function() {
72
            var value = thisObject.getCookie('CookieNoticeVisible');
73
            if (value != 'none') {
74
                thisObject.Box.style.display = 'block';
75
            }
76
        };
77
        this.Box.onclick = thisObject.hideNotice;
78
        this.start();
79
    }/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80
    show the cookie notice if needed
81
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
82
    var watchNotice = new CookieNotice('CookieNotice');
83
//    new CookieNotice('CookieNotice');
84

    
85

    
86

    
87

    
(1-1/9)