Project

General

Profile

1 49495 tsampikos.
"use strict";
2
3
function createCookie(name, value, seconds) {
4
    var date = new Date();
5
    date.setTime(date.getTime() + (seconds * 1000));
6
    var expires = "; expires=" + date.toGMTString();
7
8
    var path = '$environment.getProperty("idp.cookie.path", $request.getContextPath())';
9
    if (path.length > 0)
10
        path = "; path=" + path;
11
    document.cookie = name + "=" + value + expires + path;
12
}
13
14
function eraseCookie(name) {
15
    createCookie(name, "", -31536000);
16
}
17
18
function readCookie(name) {
19
    var nameEQ = name + "=";
20
    var ca = document.cookie.split(';');
21
    for (var i = 0; i < ca.length; i++) {
22
        var c = ca[i];
23
        while (c.charAt(0) == ' ')
24
            c = c.substring(1, c.length);
25
        if (c.indexOf(nameEQ) == 0)
26
            return c.substring(nameEQ.length, c.length);
27
    }
28
    return null;
29
}
30
31
function load(id) {
32
    var checkbox = document.getElementById(id);
33
    if (checkbox != null) {
34
        var spnego = readCookie(checkbox.name);
35
        checkbox.checked = (spnego == "1");
36
    }
37
}
38
39
function check(checkbox) {
40
    if (checkbox.checked) {
41
        createCookie(checkbox.name, checkbox.value, $environment.getProperty("idp.cookie.maxAge","31536000"));
42
    } else {
43
        eraseCookie(checkbox.name);
44
    }
45
}