PageSourceSearch

https://lydneypractice.nhs.uk/wp-content/plugins/spCookiePolicy/js/sp_cookiepolicy.js?ver=1.0.8%20FOUNDATION

js lydneypractice.nhs.uk collected 2026-10-05 23:46:51 UTC 8,263 bytes, 208 lines download raw bytes

1"use strict";
2
3function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } }
4function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
7function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
9var CookiePolicy = function () {
10
11    function CookiePolicy() {
12        _classCallCheck(this, CookiePolicy);
13        _defineProperty(this, "initiated", false);
14        _defineProperty(this, "analytics", false);
15        _defineProperty(this, "settings", false);
16
17        this.domain = "." + window.location.hostname.replace("www.", "");
18        this.initCookie();
19
20        if (!this.initiated) {
21            jQuery("#cookiepolicy").css("display", "block");
22        }
23    }
24
25    _createClass(CookiePolicy, [
26        {
27            key: "initCookie",
28            value: function initCookie() {
29                var cookie = document.cookie.match(/cookiepolicy=({.*?})/);
30
31                if (cookie) {
32                    cookie = JSON.parse(cookie[1]);
33                    this.analytics = cookie.analytics;
34                    this.settings  = cookie.settings;
35                    this.initiated = true;
36                } else {
37                    this.deleteSettingsCookies();
38                    this.deleteAnalyticsCookies();
39                }
40
41                this.append();
42            }
43        },
44        {
45            key: "append",
46            value: function append() {
47                if (jQuery("#top-info").length) {
48                    jQuery("#cookiepolicy").prependTo("#top-info");
49                } else {
50                    jQuery("#cookiepolicy").prependTo("body");
51                }
52            }
53        },
54        {
55            key: "setCookie",
56            value: function setCookie(name, value) {
57                var expiration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
58
59                if (!_instanceof(expiration, Date)) {
60                    var date = new Date();
61                    var expirationDays = expiration;
62                    expiration = new Date();
63                    expiration.setTime(date.getTime() + expirationDays * 24 * 60 * 60 * 1000);
64                }
65
66                document.cookie = name + "=" + value + ";expires=" + expiration.toUTCString() + ";path=/;domain=" + this.domain;
67            }
68        },
69        {
70            key: "getCookie",
71            value: function getCookie(name, type) {
72                var cookiesAllowed = false;
73
74                cookiesAllowed = type == "analytics" && this.analytics == true ? true : cookiesAllowed;
75                cookiesAllowed = type == "settings"  && this.settings  == true ? true : cookiesAllowed;
76
77                if (cookiesAllowed) {
78                    var regex = new RegExp(name + "=([^;]*)");
79                    var cookie = document.cookie.match(regex);
80                    return cookie ? cookie[1] : false;
81                }
82
83                return false;
84            }
85        },
86        {
87            key: "deleteCookie",
88            value: function deleteCookie(name) {
89                document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;domain=" + this.domain;
90                document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;";
91            }
92        },
93        {
94            key: "deleteSettingsCookies",
95            value: function deleteSettingsCookies(name) {
96                document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;domain=" + this.domain;
97                var cookies = document.cookie.match(/[a-zA-Z0-9-_]+=/g);
98
99                if (cookies) {
100                    for (var i = 0; i < cookies.length; i++) {
101                        var cookie = cookies[i].replace(/=$/, "");
102
103                        if (["_ga", "_gat", "_gid", "cookiepolicy"].indexOf(cookie) == -1) {
104                            this.deleteCookie(cookie);
105                        }
106                    }
107                }
108            }
109        },
110        {
111            key: "deleteAnalyticsCookies",
112            value: function deleteAnalyticsCookies() {
113                this.deleteCookie("_ga");
114                this.deleteCookie("_gat");
115                this.deleteCookie("_gid");
116            }
117        },
118        {
119            key: "saveCookies",
120            value: function saveCookies(analytics, settings) {
121                this.analytics = analytics;
122                this.settings = settings;
123                var expiration = analytics && settings ? 365 : 30; // Cookie lasts 365 days if user accepts all, or 30 days if denies any option
124
125                this.setCookie("cookiepolicy", JSON.stringify({
126                    analytics: analytics,
127                    settings: settings
128                }), expiration);
129
130                if (!settings)
131                    this.deleteSettingsCookies();
132
133                if (!analytics)
134                    this.deleteAnalyticsCookies();
135                else if (typeof initGoogleAnalytics == "function")
136                    initGoogleAnalytics();
137            }
138        },
139        {
140            key: "setEmergencyPopup",
141            value: function setEmergencyPopup() {
142                if (jQuery("#emergency-popup-script").length && !this.getCookie("emergency-popup", "settings")) {
143                    var date = new Date();
144                    var expiration = new Date(date.getFullYear() + "-" + date.getMonth() + 1 + "-" + date.getDate() + " 23:59:59");
145                    this.setCookie("emergency-popup", expiration);
146                }
147            }
148        }
149    ]);
150
151    return CookiePolicy;
152}();
153
154jQuery(document).ready(function ($) {
155    var cookiePolicy = new CookiePolicy();
156
157    if ($("#cookie-settings").length) {
158        if (cookiePolicy.analytics || !cookiePolicy.initiated)
159            $("#analytics-cookie-on").prop("checked", true);
160        else
161            $("#analytics-cookie-off").prop("checked", true);
162
163        if (cookiePolicy.settings || !cookiePolicy.initiated)
164            $("#settings-cookie-on").prop("checked", true);
165        else
166            $("#settings-cookie-off").prop("checked", true);
167    }
168
169    $("#accept-cookies").on("click", function () {
170        cookiePolicy.saveCookies(true, true);
171
172        $("#cookiepolicy").slideUp();
173
174        if (cookiePolicy.settings)
175            cookiePolicy.setEmergencyPopup();
176    });
177
178    $("#save-cookies").on("click", function () {
179        var analytics = $("#analytics-cookie-on").is(":checked");
180        var settings = $("#settings-cookie-on").is(":checked");
181        cookiePolicy.saveCookies(analytics, settings);
182
183        $("#cookiepolicy").slideUp();
184
185        if (cookiePolicy.settings)
186            cookiePolicy.setEmergencyPopup();
187
188        if (!$("#cookie-alert").length) {
189            $("<div id='cookie-alert' class='frm_message'>Your cookie settings were saved.</div>").insertAfter("#save-cookies");
190        }
191
192        $("#cookie-alert").attr("tabindex", "0").focus();
193        setTimeout(function () {
194            $("#cookie-alert").removeAttr("tabindex");
195        }, 500);
196    });
197
198    $("#cookie-settings input[type=radio]").on("change", function () {
199        $("#cookie-alert").remove();
200    });
201});
202
203function getCookiePolicy() {
204    var cookiePolicy = document.cookie.match(/cookiepolicy=({.*?})/);
205    cookiePolicy = cookiePolicy ? JSON.parse(cookiePolicy[1]) : false;
206  
207    return cookiePolicy;
208}

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.