PageSourceSearch

https://mountorielmedicalpractice.co.uk/script/cookie-consent/cookie-consent.js?version=3

js mountorielmedicalpractice.co.uk collected 2026-10-08 18:39:42 UTC 6,641 bytes, 209 lines download raw bytes

1$(document).ready(function () {
2    var cookieKey = 'MswCookieConsent';
3    //fix: this will fix user's with the incorrect cookie consent encoding - causing errors on the prescription form
4    removeCookies(['CookieConsent']);
5
6   // if we are on the cookie policy page, remove the pop up from the DOM.
7    if (isCookiePolicyPath()) {
8        $('#cookieConsent').remove();
9    }
10
11    var cookie = getCookie(cookieKey);
12
13    if (cookie === undefined) {
14        $('#cookieConsent-button-save').hide();
15        showCookieConsent();
16    } else {
17        //fix to allow Mavis in reception to use the enter key to submit forms :/
18        $('#cookieConsent').remove();
19        
20        var cookieConsent = JSON.parse(cookie);
21        setCategories(cookieConsent);
22        getCookieConsent(cookieConsent);
23    }
24
25    $('#cookiePolicy-button-save').on("click", function () {
26        var categories = [];
27        $('#selectable-checkbox input:checkbox:checked').each(function () {
28            categories.push($(this).val());
29        });
30
31        var cookie = categories.length
32            ? createCookieSettings(actionTypeEnum.Accept, categories)
33            : createCookieSettings(actionTypeEnum.Reject, categories);
34
35        setCookie(cookieKey, JSON.stringify(cookie));
36        
37        //check if we need to remove any cookies 
38        $('#selectable-checkbox input:checkbox:not(:checked)').each(function () {
39            var category = $(this).val();
40            switch (category) {
41                case categoryTypeEnum.Performance:
42                    var performanceCookies = getPerformanceCookies();
43                    removeCookies(performanceCookies);
44                    break;
45                case categoryTypeEnum.Functionality:
46                    var functionalCookies = getFunctionalCookies();
47                    removeCookies(functionalCookies);
48                    break;
49            }
50        });
51    });
52
53    $('#cookieConsent-button-save').on("click", function () {
54        var categories = [];
55        $('#selectable-checkbox input:checkbox:checked').each(function () {
56            categories.push($(this).val());
57        });
58        var cookie = categories.length
59            ? createCookieSettings(actionTypeEnum.Accept, categories)
60            : createCookieSettings(actionTypeEnum.Reject, categories);
61
62        setCookie(cookieKey, JSON.stringify(cookie));
63        hideCookieConsent();
64
65        if (isSecurePath()) {
66            window.location.reload();
67        }
68    });
69
70    $('#cookieConsent-button-accept').on("click", function () {
71        var cookie = createCookieSettings(actionTypeEnum.Accept, getAllCategories());
72        setCookie(cookieKey, JSON.stringify(cookie));
73
74        hideCookieConsent();
75
76        if (isSecurePath()) {
77            window.location.reload();
78        }
79    });
80
81    $('#cookieConsent-button-reject').on("click", function () {
82        var cookieSettings = createCookieSettings(actionTypeEnum.Reject, []);
83        setCookie(cookieKey, JSON.stringify(cookieSettings));
84        hideCookieConsent();
85    });
86
87    $('#cookieConsent-button-close').on("click", function () {
88        hideCookieConsent();
89    });
90
91    $('#cookieConsent-button-close').on("keyup", function (e) {
92        if (e.keyCode == 13) {
93            hideCookieConsent();
94        }
95    });
96
97    $('#cookieConsent-checkboxs').on("change", function () {
98        $('#cookieConsent-button-accept').hide();
99        $('#cookieConsent-button-save').show();
100    });
101});
102
103
104function removeCookies(cookies) {
105    $.each(cookies, function (i, value) {
106         $.removeCookie(value, { path: '/' });
107    });
108}
109
110function createCookieSettings(action, categories) {
111    var cookie = new Object();
112    cookie.action = action;
113    cookie.categories = categories;
114    return cookie;
115}
116
117function getAllCategories() {
118    return [categoryTypeEnum.Performance, categoryTypeEnum.Functionality, categoryTypeEnum.Targeting];
119}
120
121function setCategories(cookieConsent) {
122    $.each(cookieConsent.categories,
123        function (index, category) {
124            $("#selectable-checkbox input[value='" + category + "']").prop('checked', true);
125        });
126}
127
128function showCookieConsent() {
129    $('#cookieConsent').show();
130}
131
132function hideCookieConsent() {
133    $('#cookieConsent').hide();
134}
135
136function isSecurePath() {
137    var url = window.location.href;
138    var pathname = new URL(url).pathname.toLowerCase();
139    return pathname.indexOf('secure') > -1;
140}
141
142function isCookiePolicyPath() {
143    var url = window.location.href;
144    var pathname = new URL(url).pathname.toLowerCase();
145    return pathname.indexOf('cookiepolicy') > -1;
146}
147
148function getCookieConsent(cookieConsent) {
149    if (cookieConsent.action === actionTypeEnum.Accept) {
150        $.each(cookieConsent.categories,
151            function (i, category) {
152                var tag = $("*[data-cookiecategory='" + category + "']");
153                tag.each(function () {
154                    var self = this;
155                    var async = !!self.src.includes('analytics');
156                    reloadJavascript(self.src, "text/javascript", category, async);
157                });
158            });
159    }
160}
161
162function reloadJavascript(src, type, data, async) {
163    var head = document.getElementsByTagName('head')[0];
164    var script = document.createElement('script');
165    script.async = async;
166    script.src = src;
167    script.type = type;
168    script.setAttribute('data-cookiecategory', data);
169
170    head.appendChild(script);
171}
172
173var actionTypeEnum = {
174    Accept: 'accept',
175    Reject: 'reject'
176};
177
178var categoryTypeEnum = {
179    Performance: 'performance',
180    Targeting: 'targeting',
181    Functionality: 'functionality'
182}
183
184function setCookie(name, value) {
185    var expires = '';
186    var date = new Date();
187    date.setFullYear(date.getFullYear() + 1);
188    expires = '; expires=' + date.toUTCString();
189    document.cookie = name + '=' + (value || '') + expires + '; path=/';
190}
191
192function getCookie(name) {
193    var nameEq = name + '=';
194    var ca = document.cookie.split(';');
195    for (var i = 0; i < ca.length; i++) {
196        var c = ca[i];
197        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
198        if (c.indexOf(nameEq) == 0) return c.substring(nameEq.length, c.length);
199    }
200}
201
202
203function getFunctionalCookies() {
204    return ['googtrans', 'apps', 'dList1', 'dList2', 'repeatPrescription', 'repeatPrescription2'];
205}
206
207function getPerformanceCookies() {
208    return ['_gid', '_ga', '_gat'];
209}

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.