PageSourceSearch

https://www.prep.kes.school/include_v4/cookie_popup/cookie_popup_v11.js

js kes.school collected 2026-10-09 21:39:02 UTC 4,397 bytes, 113 lines download raw bytes

1$(function () {
2
3    var _cb_cookie = getCookie("agreed_cookie_policy");
4    $("#cb_cookie_preferences #_cb_accept_pref").css("background-color", $("#cb_cookie_landing #_cb_accept").css( "background-color" ));
5
6    if (typeof _cb_cookie === 'undefined' || _cb_cookie == '') {
7        $("#cb_cookie_policy_popup").removeClass('seen');
8        $("#cb_cookie_policy_popup_shroud").removeClass('seen');
9    } else if (_cb_cookie == 'accepted') {
10        $("#_cb_accept_all").attr('checked', 'checked');
11        $("#cb_cookie_policy_popup").addClass('show_preferences');
12    } else if (_cb_cookie == 'denied') {
13        $("#_cb_accept_thirdparty").attr('checked', 'checked');
14        $("#cb_cookie_policy_popup").addClass('show_preferences');
15    }
16
17    $("#cb_cookie_policy_popup:not(.seen) .cb_cookie_policy_popup_text .cb_cookie_button").focus();
18
19    $("#_cb_preferences").click(function (e) {
20        $("#cb_cookie_policy_popup").addClass('show_preferences');
21    });
22
23    $("#cb_cookie_landing #_cb_accept").click(function (e) {
24        $("#_cb_accept_all").attr('checked', 'checked');
25        cb_cookie_policy_popup_set_cookie();
26    });
27    $("#cb_cookie_preferences #_cb_accept_pref").click(function (e) {
28        e.preventDefault();
29        cb_cookie_policy_popup_set_cookie();
30    });
31    $("#cb_cookie_policy_popup .cb_cookie_policy_popup_icon").click(function (e) {
32        $("#cb_cookie_policy_popup").removeClass('seen');
33        $("#cb_cookie_policy_popup_shroud").fadeIn();
34    });
35
36    function cb_cookie_policy_popup_set_cookie() {
37        var state = $("input[name='thirdparty']:checked").val();
38        if (typeof state === 'undefined') {
39            alert('Please select an option.');
40        } else {
41            var expirationDate = new Date();
42            expirationDate.setTime(expirationDate.getTime() + (30 * 24 * 60 * 60 * 1000)); // add 30 days
43            var expires = "expires=" + expirationDate.toUTCString();
44            var secure = '';
45            if (location.protocol == 'https:') {
46                secure = 'secure;';
47            }
48            document.cookie = "agreed_cookie_policy=" + state + ";" + expires + ";" + secure + "path=/";
49
50            cookie_loadTracking(state);
51            //location.reload();
52
53            $("#cb_cookie_policy_popup_shroud").fadeOut();
54            $("#cb_cookie_policy_popup").addClass('seen');
55            $("#cb_cookie_policy_popup").addClass('show_preferences');
56        }
57    }
58
59    function getCookie(cname) {
60        var name = cname + "=";
61        var decodedCookie = decodeURIComponent(document.cookie);
62        var ca = decodedCookie.split(';');
63        for (var i = 0; i < ca.length; i++) {
64            var c = ca[i];
65            while (c.charAt(0) == ' ') {
66                c = c.substring(1);
67            }
68            if (c.indexOf(name) == 0) {
69                return c.substring(name.length, c.length);
70            }
71        }
72        return "";
73    }
74
75    function cookie_loadTracking(state) {
76        // Set google consent
77        if (state == 'accepted') { state = 'granted'; }
78        if (typeof gtag_ga4 === 'function') {
79            gtag_ga4('consent', 'update', {
80                'ad_storage': state,
81                'analytics_storage': state,
82                'ad_user_data': state,
83                'ad_personalization': state,
84            });
85        }
86        if (state == 'granted') {
87            activateDeferredScripts();
88        }
89    }
90
91    // Some script tags have type set to "text/plain" to them running automatically
92    // this function will find "<script>" tags with dat tag "data-requires-consent" and type set to javascript to allow script to run
93    function activateDeferredScripts() {
94      document.querySelectorAll('script[data-requires-consent]').forEach(function(script) {
95        const newScript = document.createElement('script');
96        newScript.type = 'text/javascript';
97
98        if (script.src) {
99          newScript.src = script.src;
100        } else {
101          newScript.textContent = script.textContent;
102        }
103
104        script.parentNode.replaceChild(newScript, script);
105      });
106    }
107
108
109    $("#cb_cookie_policy_popup").slideDown(800);
110    if (document.cookie.includes('agreed_cookie_policy=accepted')) {
111         cookie_loadTracking('accepted');
112    }
113});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.