PageSourceSearch

https://davidlivingstone-academy.org/include_v5/cookie_popup/cookie_popup_v13.js

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

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.