PageSourceSearch

https://notification.elsport.com/js/pushNotificationSdkJS.js?v=2021630

js elsport.com collected 2026-10-02 17:08:45 UTC 36,470 bytes, 949 lines download raw bytes

1//Set variables
2var notificationSettingsDialog = document.getElementsByClassName('notification-settings-dialog');
3var notificationsSettingsOverlayPopup = document.getElementsByClassName('notifications-settings-overlay-popup');
4var notificationBoxOverlay = document.getElementsByClassName('notification-box-overlay');
5var bellBellActive = document.querySelector('.bell.bell-active');
6var bellBellInactive = document.querySelector('.bell.bell-inactive');
7var muteNotifications = document.getElementById("mute-notifications");
8var advancedNotificationSettings = document.getElementsByClassName("advanced-notification-settings");
9var notificationSettingsPanel = document.getElementsByClassName('notification-settings-panel');
10var bellLauncher = document.getElementsByClassName("bell-launcher");
11var body = document.getElementsByTagName('BODY')[0];
12var notificationConfirmationBox = document.getElementsByClassName("notification-confirmation-box");
13var newscontainer = document.getElementsByClassName("newscontainer");
14var socialBarMobile = document.getElementsByClassName("social-bar-mobile");
15var listunreadNewsDesktop = document.getElementsByClassName("listunreadNewsDesktop");
16var programsList = document.getElementsByClassName("programsList");
17var blockNotificationImage = document.getElementsByClassName("block-notification-image");
18var enableNotificationTutorial = document.getElementsByClassName("enable-notification-tutorial");
19var saveSettingsButton = document.getElementsByClassName("saveSettingsButton");
20var allowNotification = document.getElementsByClassName("allowNotification");
21var blockNotification = document.getElementsByClassName("blockNotification");
22var bellLauncherButtonBellInactive = document.querySelector(".bell-launcher-button .bell-inactive");
23var bellLauncherButtonBellActive = document.querySelector(".bell-launcher-button .bell-active");
24var ntfCtgCategoryDesktop = document.querySelector(".ntfCtg-category.desktop");
25var ntfCtgCategoryMobile = document.querySelector(".ntfCtg-category.mobile");
26var ntfCtgCheckbox = document.getElementsByClassName("ntfCtg-checkbox");
27var openNotificationSettings = document.querySelectorAll(".openNotificationSettings");
28var closeNotificationBox = document.querySelectorAll(".close-notification-box");
29var closePrioritySettings = document.getElementsByClassName("closePrioritySettings");
30var savePrioritySettings = document.getElementsByClassName("savePrioritySettings");
31var saveAdvancedSettings = document.getElementsByClassName('saveAdvancedSettings');
32var ntfCtgCategory = document.querySelectorAll('.ntfCtg-category');
33var toggleAdvanced = document.querySelectorAll('.toggle-advanced');
34var notificationBody = document.querySelectorAll('#notification-body');
35var notificationPriorityRange = document.getElementById('notificationPriorityRange');
36var AllValue = document.querySelectorAll('.value');
37var notificationLevelValueSelected = document.querySelector('.notification-level .value.selected');
38var notificationSdk = document.getElementById('notificationSdk');
39
40/*var script_tag = document.getElementById('wnsdk');
41var query = script_tag.src.replace(/^[^\?]+\??/,'');
42// Parse the querystring into arguments and parameters
43var vars = query.split("&");
44var args = {};
45for (var i=0; i<vars.length; i++) {
46    var pair = vars[i].split("=");
47    // decodeURI doesn't expand "+" to a space.
48    args[pair[0]] = decodeURI(pair[1]).replace(/\+/g, ' ');
49}
50var vapidKey = args['vapidKey'];*/
51/**
52 * Convert a URL safe base64 string to a Uint8Array
53 * @param base64String
54 * @returns {Uint8Array}
55 */
56function urlBase64ToUint8Array(base64String) {
57    const padding = '='.repeat((4 - base64String.length % 4) % 4);
58    const base64 = (base64String + padding)
59        .replace(/\-/g, '+')
60        .replace(/_/g, '/');
61
62    const rawData = window.atob(base64);
63    const outputArray = new Uint8Array(rawData.length);
64
65    for (var i = 0; i < rawData.length; ++i) {
66        outputArray[i] = rawData.charCodeAt(i);
67    }
68    return outputArray;
69}
70
71/**
72 * Add a cookie using javascript
73 *
74 * @param cname
75 * @param cvalue
76 * @param exdays
77 */
78function setCookie(cname, cvalue, exdays) {
79    var d = new Date()
80    d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000)
81    var expires = 'expires=' + d.toUTCString()
82    document.cookie = cname + '=' + cvalue + '; ' + expires + '; path=/'
83}
84
85/**
86 * Retrieve a cookie using javascript
87 *
88 * @param cname
89 * @returns {string}
90 */
91function getCookie(cname) {
92    var name = cname + '='
93    var ca = document.cookie.split(';')
94    for (var i = 0; i < ca.length; i++) {
95        var c = ca[i]
96        while (c.charAt(0) == ' ') {
97            c = c.substring(1)
98        }
99        if (c.indexOf(name) == 0) {
100            return c.substring(name.length, c.length)
101        }
102    }
103    return ''
104}
105
106/**
107 * detect IE
108 * returns version of IE or false, if browser is not Internet Explorer
109 */
110function detectIE() {
111    var ua = window.navigator.userAgent;
112
113    // Test values; Uncomment to check result …
114
115    // IE 10
116    // ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)';
117
118    // IE 11
119    // ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
120
121    // Edge 12 (Spartan)
122    // ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0';
123
124    // Edge 13
125    // ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586';
126
127    var msie = ua.indexOf('MSIE ');
128    if (msie > 0) {
129        // IE 10 or older => return version number
130        return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
131    }
132
133    var trident = ua.indexOf('Trident/');
134    if (trident > 0) {
135        // IE 11 => return version number
136        var rv = ua.indexOf('rv:');
137        return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
138    }
139
140    /*  var edge = ua.indexOf('Edge/');
141      if (edge > 0) {
142          // Edge (IE 12+) => return version number
143          return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
144      }*/
145
146    // other browser
147    return false;
148}
149
150function detectEdge(){
151    var ua = window.navigator.userAgent;
152    var edge = ua.indexOf('Edge/');
153    if (edge > 0) {
154        // Edge (IE 12+) => return version number
155        return true;
156    }
157    return false;
158}
159
160function detectiOS() {
161    return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
162}
163
164/*function detectMacOs(){
165    return (navigator.appVersion.indexOf("Mac")!=-1)
166}*/
167
168function detectAndroidNative(){
169    var ua = navigator.userAgent;
170    return ((ua.indexOf('Mozilla/5.0') > -1 && ua.indexOf('Android ') > -1 && ua.indexOf('AppleWebKit') > -1) && !(ua.indexOf('Chrome') > -1));
171}
172
173function getBrowserVersion(fn) {
174    navigator.sayswho = (function () {
175        var platform = ((window.innerWidth * 1) <= 768) ? "Mobile" : "Desktop";
176
177        var ua = navigator.userAgent, tem,
178            M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
179        if (/trident/i.test(M[1])) {
180            tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
181            M[0] = 'IE ' + (tem[1] || '');
182        }
183        if (M[1] === 'Chrome') {
184            tem = ua.match(/\bOPR\/(\d+)/);
185            if (tem != null) {
186                M.splice(1, 1, 'Opera');
187                M.splice(2, 1, tem[1]);
188            }
189
190            tem = ua.match(/\bEdge\/(\d+(.\d+)+)/i);
191            if (tem != null) {
192                M.splice(1, 1, 'Edge');
193                M.splice(2, 1, tem[1]);
194            }
195        }
196        M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
197        if ((tem = ua.match(/version\/(\d+)/i)) != null) M.splice(1, 1, tem[1]);
198
199        var browser = M[0];
200        if (navigator.userAgent.match(/SamsungBrowser/i) !== null)
201            browser = "Samsung Internet";
202
203        fn(browser, M[1], platform);
204
205    })();
206}
207
208function getNotificationSubscription(fn) {
209    if (typeof navigator.serviceWorker === "undefined" || typeof navigator.serviceWorker.ready === "undefined") {
210        fn('no subscription');
211    } else {
212        navigator.serviceWorker.ready.then(function (reg) {
213            reg.pushManager.getSubscription().then(function (subscription) {
214                fn(subscription);
215            })
216        }).catch(function (error) {
217            fn('no subscription');
218        });
219    }
220}
221
222function checkIfPermissionChanged() {
223    navigator.permissions.query({name: 'notifications'}).then(function (permission) {
224        permission.onchange = function () {
225            if (Notification.permission !== 'granted') {
226                /*if(!currentlySubscibing)
227                    activateNotifications(false)
228                }else {*/
229                currentSubscription.setUnsubscribedFlag();
230                currentSubscription.updateTokenOnServer();
231            }
232        };
233    });
234}
235
236function permissionDenied(){
237    return Notification.permission === "denied";
238}
239
240function permissionGranted(){
241    return Notification.permission === "granted";
242}
243
244function defaultPermission(){
245    return Notification.permission === "default";
246}
247
248var currentSubscription = {
249    initializeSubscription : function(){
250        this.getDeviceId();
251        this.getCountry();
252        this.getDeviceInformations();
253        this.checkSubscription();
254    },
255    priority: (getCookie("ntfPriority"))?getCookie("ntfPriority"):3,
256    categories: (getCookie("ntfCategories"))?getCookie("ntfCategories"):"[]",
257    customPermissionConfirmed: (getCookie("notificationPermission"))?getCookie("notificationPermission"):false,
258    getDeviceId : function() {
259        this.deviceId = "";
260        /*new Fingerprint2().get(function(result, components){
261            this.deviceId = result;
262        }.bind(this))*/
263    },
264    getCountry : function(){
265        if(getCookie("ntfcountry"))
266            this.country = getCookie("ntfcountry");
267        else {
268            var script = document.createElement('script');
269            script.onload = function () {
270                console.log("country: "+getCookie("ntfcountry"));
271                this.country = getCookie("ntfcountry");
272            };
273            script.src = 'https://notification.elfann.com/js/getIpCountry.php';
274            document.head.appendChild(script);
275        }
276    },
277    getDeviceInformations : function(){
278        getBrowserVersion(function(browser,version,platform) {
279            this.browser= browser;
280            this.browserVersion=version;
281            this.platform= platform;
282        }.bind(this))
283    },
284    checkSubscription : function(){
285        getNotificationSubscription(function (subscription) {
286            //Unselect all the Labels
287            AllValue.forEach(function(el) {
288                el.classList.remove('selected');
289            });
290            if (!subscription || subscription == null || subscription === "no subscription" || !permissionGranted()) {
291                this.setUnsubscribedFlag();
292                ``
293                if(notificationPriorityRange) {
294                    notificationPriorityRange.value = 1;
295                    document.querySelector(".notification-level .value[data-value='1']").classList.add('selected');
296                }
297            } else {
298                this.tokens = JSON.stringify(subscription);
299                this.setSubscribedFlag();
300                //this.getUserSubscriptionFromServer()
301                this.restoreToken();
302
303                if(notificationPriorityRange) {
304                    if (currentSubscription.priority == 1) {
305                        notificationPriorityRange.value = 34;
306                        document.querySelector(".notification-level .value[data-value='34']").classList.add('selected');
307                    } else if (currentSubscription.priority == 2) {
308                        notificationPriorityRange.value = 64;
309                        document.querySelector(".notification-level .value[data-value='64']").classList.add('selected');
310                    } else if (currentSubscription.priority == 3) {
311                        notificationPriorityRange.value = 100;
312                        document.querySelector(".notification-level .value[data-value='100']").classList.add('selected');
313                    }
314                }
315            }
316            if(bellLauncher.length){
317                bellLauncher[0].style.display = "block";
318            }
319        }.bind(this));
320    },
321    setSelectedPriority : function(selectedPriority)
322    {
323        setCookie("ntfPriority", selectedPriority, 365);
324        this.priority = selectedPriority;
325    },
326
327    setSelectedCategories : function(categories) {
328        setCookie("ntfCategories", categories, 365);
329        this.categories = categories;
330    },
331
332    getSelectedCategories() {
333        var enabledCategories = this.categories;
334        if (enabledCategories) {
335            enabledCategories = JSON.parse(enabledCategories);
336            if (enabledCategories.length) {
337                var categories = [];
338                for (var i = 0; i < enabledCategories.length; i++) {
339                    var categoryPriority = enabledCategories[i].split("_");
340                    categories[categoryPriority[0]] = categoryPriority[1];
341                }
342                return JSON.stringify(categories);
343            }
344            return [];
345        }
346        return [];
347    },
348
349    setGrantedCustomPermissionFlag : function() {
350        setCookie("notificationPermission", "1", 365);
351        this.customPermissionConfirmed = "1";
352    },
353
354    setDeniedCustomPermissionFlag : function() {
355        setCookie("notificationPermission", "0", 7);
356        this.customPermissionConfirmed = "0";
357    },
358
359    setUnsubscribedFlag : function() {
360        setCookie("ntfSubscribed", "0", 365);
361        turnOffNotifications();
362        this.status = 2;
363    },
364
365    setSubscribedFlag : function() {
366        setCookie("ntfSubscribed", "1", 365);
367        turnOnNotifications();
368        this.status = 1;
369    },
370    subscribedToNotifications : function() {
371        return this.status == 1;
372    },
373
374    restoreToken : function() {
375        if (!getCookie("tokenRestored")) {
376            setCookie("tokenRestored", "1", 0.25);
377            this.updateTokenOnServer(true);
378        }
379    },
380    activateNotifications : function(showSettings) {
381        if (permissionDenied()) {
382            showUnblockTutorial();
383        } else {
384            hideCustomConfirmationBox();
385            if (!permissionGranted() && !isMobile && !(this.browser == "Firefox" && parseInt(this.browserVersion) >= 70)) {
386                openSubscriptionWindow(showSettings);
387            } else
388                this.subscribeToNotifications(showSettings);
389        }
390    },
391    subscribeToNotifications : function(showSettings, restored) {
392        'use strict';
393        if ('serviceWorker' in navigator) {
394            navigator.serviceWorker.register("/sw.js?v=2021817").then(function() {
395                return navigator.serviceWorker.ready;
396            }).then(function(reg) {
397                reg.pushManager.subscribe({
398                    userVisibleOnly: true,
399                    applicationServerKey: urlBase64ToUint8Array(notificationSdk.getAttribute("data-vapidKey")),
400                }).then(function(sub) {
401                    this.setSubscribedFlag();
402
403                    this.tokens = JSON.stringify(sub);
404
405                    if (showSettings)openSettings();
406                    if (typeof restored === "undefined") restored = false;
407                    this.updateTokenOnServer(restored);
408                }.bind(this)).catch(function(error) {
409                    this.setUnsubscribedFlag();
410                }.bind(this));
411            }.bind(this)).catch(function (error) {
412            });
413        }
414        // Notification.requestPermission();
415    },
416    unsubscribeFromNotifications : function() {
417        getNotificationSubscription(function (subscription) {
418            subscription.unsubscribe().then(function (successful) {
419                if(successful) {
420                    this.setUnsubscribedFlag();
421                    this.updateTokenOnServer();
422                }
423            }.bind(this)).catch(function (e) {
424
425            })
426        }.bind(this));
427    },
428    updateTokenOnServer : function (restored) {
429        if (typeof restored === "undefined") restored = false;
430        if (typeof this.status === "undefined") this.status = 1;
431
432        var url = notificationSdk.getAttribute("data-domain")+"rest/newToken/Web"; //location.protocol + "//" + window.location.hostname + (window.location.port !== "80" ? ":" + window.location.port : "") + "/updateNotificationToken"
433
434        var data = {
435            token: this.tokens,
436            applicationId: notificationSdk.getAttribute("data-applicationId"),
437            categories: this.getSelectedCategories(),
438            level: this.priority,
439            country: this.country,
440            browser: this.browser,
441            status: this.status,
442            browserVersion:this.browserVersion,
443            platform: this.platform,
444            permission: (Notification.permission === 'granted') ? 1 : 0,
445            restored:restored
446
447        };
448
449        var formData  = new FormData();
450
451        // Push our data into our FormData object
452        for(name in data) {
453            formData.append(name, data[name]);
454        }
455
456        //Ajax call Post
457        GETPOSTN(url, formData, updateTokenOnServerHandler);
458        function updateTokenOnServerHandler(data){}
459    },
460    getUserSubscriptionFromServer : function() {
461        var url = location.protocol + "//" + window.location.hostname + (window.location.port !== "80" ? ":" + window.location.port : "") + "/getSubscriptionData";
462        var data = {
463            tokens: this.tokens,
464            deviceId: this.deviceId
465        };
466        //Ajax call Post
467        GETPOSTN(url, data, getUserSubscriptionFromServerHandler);
468        function getUserSubscriptionFromServerHandler(data){
469            if(!data.exist){
470                this.updateTokenOnServer(true);
471            }
472        }
473    }
474};
475
476function closeSetting() {
477    if(notificationSettingsDialog.length){
478        hideN(notificationSettingsDialog[0]);
479    }
480    if(notificationsSettingsOverlayPopup.length){
481        hideN(notificationsSettingsOverlayPopup[0]);
482    }
483    if(notificationBoxOverlay.length){
484        hideN(notificationBoxOverlay[0]);
485    }
486}
487
488function openSettings() {
489    if (!permissionGranted() || !currentSubscription.subscribedToNotifications()) {
490        currentSubscription.activateNotifications(true);
491    }else {
492        if (isMobile) {
493            window.location = "/notifications";
494        } else {
495            var notificationPriority = currentSubscription.priority;
496            var ntfCtgCheckboxAll = document.getElementById('ntfCtg-checkbox_all_'+notificationPriority);
497            ntfCtgCheckboxAll.click();
498            showN(notificationsSettingsOverlayPopup[0]);
499        }
500    }
501}
502
503function openSubscriptionWindow(showSettings){
504    var w = 585;
505    var h = 700;
506
507    var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
508    var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
509
510    var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
511    var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
512
513    var left = ((width / 2) - (w / 2)) + dualScreenLeft;
514    var top = ((height / 2) - (h / 2)) + dualScreenTop;
515
516    window.open(location.protocol + "//" + window.location.hostname + (window.location.port !== "80" ? ":" + window.location.port : "") + "/subscribe?showSettings="+showSettings, 'Continue_to_Application', 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
517}
518
519function turnOnNotifications() {
520    bellBellActive.classList.remove("hidden");
521    bellBellInactive.classList.add("hidden");
522    if(typeof(muteNotifications) != 'undefined' && muteNotifications != null){
523        muteNotifications.setAttribute('disabled', false);
524        muteNotifications.setAttribute('checked', true);
525    }
526}
527
528function turnOffNotifications() {
529    bellBellActive.classList.add("hidden");
530    bellBellInactive.classList.remove("hidden");
531    if(typeof(muteNotifications) != 'undefined' && muteNotifications != null) {
532        muteNotifications.setAttribute('disabled', false);
533        muteNotifications.setAttribute('checked', false);
534    }
535}
536
537function showCustomConfirmationBox(){
538    showN(notificationConfirmationBox[0]);
539    if(typeof(newscontsocialBarMobileainer) != 'undefined' && newscontainer != null) {
540        if(socialBarMobile.length) {
541            socialBarMobile[0].classList.add("hideForNotification");
542        }
543        if(listunreadNewsDesktop.length) {
544            listunreadNewsDesktop[0].classList.add("hideForNotification");
545        }
546        if(programsList.length) {
547            programsList[0].classList.add("hideForNotification");
548        }
549    }
550}
551
552function hideCustomConfirmationBox(){
553    hideN(notificationConfirmationBox[0]);
554    if(typeof(newscontainer) != 'undefined' && newscontainer != null) {
555        if(socialBarMobile.length) {
556            socialBarMobile[0].classList.remove("hideForNotification");
557        }
558        if(listunreadNewsDesktop.length) {
559            listunreadNewsDesktop[0].classList.remove("hideForNotification");
560        }
561        if(programsList.length) {
562            programsList[0].classList.remove("hideForNotification");
563        }
564    }
565}
566
567function showUnblockTutorial(){
568    blockNotificationImage[0].setAttribute("src",blockNotificationImage[0].getAttribute("data-src"));
569    showN(enableNotificationTutorial[0]);
570}
571
572function initializeNotification() {
573    currentSubscription.initializeSubscription();
574
575 /*   if(!detectEdge()) {
576        checkIfPermissionChanged();
577    }*/
578
579    if(defaultPermission() && !currentSubscription.customPermissionConfirmed) {
580        showCustomConfirmationBox();
581    }
582}
583
584function initializeNotificationActions(){
585    allowNotification[0].addEventListener("click", function(e){
586        e.preventDefault();
587
588        if(typeof gtag != "undefined")
589            gtag('event', 'permission', {'event_category': 'web-push', 'event_label': 'allow'});
590
591        currentSubscription.setGrantedCustomPermissionFlag();
592        currentSubscription.activateNotifications(false);
593    });
594
595    blockNotification[0].addEventListener("click", function(e){
596        e.preventDefault();
597
598        if(typeof gtag != "undefined")
599            gtag('event', 'permission', {'event_category': 'web-push', 'event_label': 'deny'});
600
601        hideCustomConfirmationBox();
602        currentSubscription.setDeniedCustomPermissionFlag();
603    });
604
605    if(typeof(muteNotifications) != 'undefined' && muteNotifications != null){
606        muteNotifications.addEventListener("click", function(e){
607            if (this.checked) {
608                currentSubscription.activateNotifications(false);
609            } else {
610                currentSubscription.unsubscribeFromNotifications();
611            }
612        });
613    }
614
615    bellLauncherButtonBellInactive.addEventListener("click", function(e){
616        e.preventDefault();
617        if(!isMobile || body.getAttribute('data-page') === 'notifications')
618            currentSubscription.activateNotifications(false);
619        else
620            openSettings();
621    });
622
623    bellLauncherButtonBellActive.addEventListener("click", function(e){
624        e.preventDefault();
625        if(!isMobile || body.getAttribute('data-page') === 'notifications')
626            currentSubscription.unsubscribeFromNotifications();
627        else
628            openSettings();
629    });
630}
631
632function initializeNotificationOptions() {
633
634    /**
635     * Position the bell next to the page container
636     */
637   /* var window_width = $(window).width();
638    var container_width = $('#generalcontainer').outerWidth();
639    var right = ((window_width - container_width) / 2) - $('.bell-launcher').outerWidth() - 40;
640    if (right < 8) right = 8;
641    $('.bell-launcher').css({'right': right});*/
642
643    openNotificationSettings.forEach(function(el){
644        el.addEventListener("click", function(e){
645            e.preventDefault();
646            openSettings();
647            sendBellClickEvent();
648        });
649    })
650
651    if(isMobile){
652        if(typeof(ntfCtgCategoryDesktop) != 'undefined' && ntfCtgCategoryDesktop != null){
653            ntfCtgCategoryDesktop.parentNode.removeChild(ntfCtgCategoryDesktop);
654        }
655    }else{
656        if(typeof(ntfCtgCategoryMobile) != 'undefined' && ntfCtgCategoryMobile != null){
657            ntfCtgCategoryMobile.parentNode.removeChild(ntfCtgCategoryMobile);
658        }
659    }
660
661    for(var i = 0; i < ntfCtgCheckbox.length; i++){
662        ntfCtgCheckbox[i].addEventListener("click", function (e) {
663            e.preventDefault();
664            //Set variables
665            var categoryElement = this.closest("div.ntfCtg-category");
666            var selectedPriority = this.getAttribute('data-value');
667            var category = categoryElement.getAttribute('data-id');
668            var ntfCtgCheckboxCategorySelectedPriority = document.querySelector("#ntfCtg-checkbox_" + category + "_" + selectedPriority);
669            var allCatNtfCtgCheckboxBox = categoryElement.querySelectorAll('.ntfCtg-checkbox-box');
670            var allCatPriorityCheckbox = categoryElement.querySelectorAll('.priority-checkbox');
671            var allNtfCtgPriorityCheckboxChecked = ntfCtgCheckboxCategorySelectedPriority.querySelectorAll('.priority-checkbox:checked');
672            var allNtfCtgPriorityCheckbox = ntfCtgCheckboxCategorySelectedPriority.querySelectorAll('.priority-checkbox');
673
674            var disabled = false;
675            if (selectedPriority == 1 && allNtfCtgPriorityCheckboxChecked.length && category != "all")
676                disabled = true;
677
678            allCatNtfCtgCheckboxBox.forEach(function (el) {
679                el.classList.remove("ntfCtg-checkbox-checked");
680            });
681
682            allCatPriorityCheckbox.forEach(function (el) {
683                el.removeAttribute("checked");
684                el.checked = false;
685            });
686
687            if (!disabled) {
688                allNtfCtgPriorityCheckbox.forEach(function (el) {
689                    el.removeAttribute("checked");
690                    el.checked = true;
691                });
692
693                for (var priority = 1; priority <= selectedPriority; priority++) {
694                    var ntfCtgCheckboxCategoryPriority = document.querySelector("#ntfCtg-checkbox_" + category + "_" + priority);
695                    var allNtfCtgCheckboxBox = ntfCtgCheckboxCategoryPriority.querySelectorAll('.ntfCtg-checkbox-box');
696                    allNtfCtgCheckboxBox.forEach(function (el) {
697                        el.classList.add("ntfCtg-checkbox-checked");
698                    });
699                }
700            }
701        });
702    }
703    
704    closeNotificationBox.forEach(function(el) {
705        el.addEventListener("click", function(e){
706            e.preventDefault();
707            this.closest('.notification-box-overlay').style.display = 'none';
708        });
709    });
710
711    document.addEventListener('keyup', function(event) {
712        if (event.keyCode === 27) { // escape key maps to keycode `27`
713            closeSetting();
714        }
715    });
716
717    if(closePrioritySettings.length) {
718        closePrioritySettings[0].addEventListener("click", function (e) {
719            e.preventDefault();
720            closeSetting();
721        });
722    }
723    if(savePrioritySettings.length) {
724        savePrioritySettings[0].addEventListener("click", function (e) {
725            e.preventDefault();
726            currentSubscription.setSelectedPriority(document.querySelectorAll('.ntfCtg-category.all-categories .priority-checkbox:checked')[0].value);
727            currentSubscription.updateTokenOnServer();
728            closeSetting();
729        });
730    }
731    if(saveAdvancedSettings.length) {
732        saveAdvancedSettings[0].addEventListener("click", function (e) {
733            e.preventDefault();
734            //Set variable
735            var categories = [];
736
737            document.querySelectorAll('.ntfCtg-category').forEach(function (el) {
738                //Set variables
739                var categoryId = el.getAttribute('data-id');
740                if(el.querySelector(".priority-checkbox:checked")) {
741                    var selectedPriority = el.querySelector(".priority-checkbox:checked").value;
742                }else{
743                    var selectedPriority = "disabled";
744                }
745                if (categoryId != 0 && categoryId != "all") {
746                    categories.push(categoryId + "_" + selectedPriority);
747                }
748            });
749            categories = JSON.stringify(categories);
750            currentSubscription.setSelectedCategories(categories);
751            currentSubscription.updateTokenOnServer();
752        });
753    }
754
755    if(toggleAdvanced.length) {
756        toggleAdvanced[0].addEventListener("click", function (e) {
757            e.preventDefault();
758            notificationBody.classList.toggle("visible");
759            this.querySelector("li").classList.toggle('icon-arrow-down icon-arrow-up');
760            saveSettingsButton.classList.toggle("saveAdvancedSettings");
761            saveSettingsButton.classList.toggle("savePrioritySettings");
762        });
763    }
764
765    if(notificationPriorityRange) {
766    // if(typeof(notificationPriorityRange) != 'undefined' && notificationPriorityRange != null) {
767        //Notification Bar Settings
768        notificationPriorityRange.oninput = function () {
769            //Unselect all the Labels
770            AllValue.forEach(function(el) {
771                el.classList.remove('selected');
772            });
773            //Check the selcted value
774            if (parseInt(this.value) >= 0 && parseInt(this.value) <= 18) {
775                //Set the slider to the range value
776                notificationPriorityRange.value = "1";
777                //Select the related label
778                document.querySelector(".notification-level .value[data-value='1']").classList.add('selected');
779            } else if (parseInt(this.value) >= 19 && parseInt(this.value) <= 50) {
780                //Set the slider to the range value
781                notificationPriorityRange.value = "34";
782                //Select the related label
783                document.querySelector(".notification-level .value[data-value='34']").classList.add('selected');
784            } else if (parseInt(this.value) >= 51 && parseInt(this.value) <= 82) {
785                //Set the slider to the range value
786                notificationPriorityRange.value = "64";
787                //Select the related label
788                document.querySelector(".notification-level .value[data-value='64']").classList.add('selected');
789            } else if (parseInt(this.value) >= 83 && parseInt(this.value) <= 100) {
790                //Set the slider to the range value
791                notificationPriorityRange.value = "100";
792                //Select the related label
793                document.querySelector(".notification-level .value[data-value='100']").classList.add('selected');
794            }
795        };
796
797        notificationPriorityRange.onchange = function () {
798            console.log(document.querySelector('.notification-level .value.selected').getAttribute('data-level'));
799            if (document.querySelector('.notification-level .value.selected').getAttribute('data-level') == 0) {
800                currentSubscription.unsubscribeFromNotifications();
801            } else {
802                currentSubscription.setSelectedPriority(document.querySelector('.notification-level .value.selected').getAttribute('data-level'));
803                if (!permissionGranted() || !currentSubscription.subscribedToNotifications()) {
804                    currentSubscription.activateNotifications(false);
805                } else {
806                    currentSubscription.updateTokenOnServer();
807                }
808            }
809        };
810    }
811}
812
813function sendBellClickEvent(){
814    if (!isMobile) {
815        switch (body.getAttribute('data-page')) {
816            case 'homepage':
817                ga('send', 'event', 'Homepage', 'Notification Bell');
818                break;
819            case 'news':
820                ga('send', 'event', 'News Page', 'Notification Bell');
821                break;
822            case 'category':
823                ga('send', 'event', 'Category Page', 'Notification Bell');
824                break;
825        }
826    }
827}
828
829function loadAdvancedSettings() {
830    if(isMobile){
831        saveSettingsButton.classList.add("savePrioritySettings");
832        saveSettingsButton.classList.add("saveAdvancedSettings");
833    }
834
835    var enabledCategories = JSON.parse(currentSubscription.categories);
836
837    if (enabledCategories.length) {
838        for (var i = 0; i < enabledCategories.length; i++) {
839            var categoryPriority = enabledCategories[i].split("_");
840            var categoryId = categoryPriority[0];
841            var priority = categoryPriority[1];
842            if (priority == "disabled") {
843                var ntfCtgCheckbox1 = document.getElementById('ntfCtg-checkbox_'+categoryId+'_1');
844                ntfCtgCheckbox1.click();
845              } else if(priority != 1){
846                var ntfCtgCheckboxPriority = document.getElementById('ntfCtg-checkbox_'+categoryId+'_'+priority);
847                ntfCtgCheckboxPriority.click();
848            }
849        }
850    } else if(currentSubscription.priority > 1) {
851        var ntfCtgCheckbox = document.querySelector('.ntfCtg-category.single-category .ntfCtg-checkbox[data-value="' + currentSubscription.priority + '"]');
852        ntfCtgCheckbox.click();
853    }
854}
855
856function checkSubscription() {
857    getNotificationSubscription(function (subscription) {
858        console.log(subscription);
859    });
860}
861
862//On document Ready
863(function(funcName, baseObj) {
864    if(allowNotification.length) {
865        console.log("new js v3");
866        //Set variable
867        var isIE = detectIE();
868        var isiOS = detectiOS();
869        var isAndroidNative = detectAndroidNative();
870        //var isMac = detectMacOs();
871        if (!isiOS && !isAndroidNative) {
872            initializeNotification();
873            initializeNotificationActions();
874            initializeNotificationOptions();
875            if (advancedNotificationSettings.length) loadAdvancedSettings();
876        } else {
877            bellLauncher[0].parentNode.removeChild(bellLauncher[0]);
878            hideN(notificationSettingsPanel[0]);
879        }
880    }
881})("docReady", window);
882
883window.addEventListener("load",function(){
884    setTimeout(function(){
885        if(allowNotification.length) {
886            if (bellLauncher.length) {
887                bellLauncher[0].style.display = "block";
888            }
889        }
890    },1000);
891});
892
893
894//Common functions
895/** Show element **/
896function showN(elem) {
897    // elem.classList.add("show");
898    elem.style.display = "block";
899}
900
901/** Hide element **/
902function hideN(elem) {
903    // elem.classList.remove("show");
904    elem.style.display = "none";
905}
906
907/** Get Post **/
908var GETPOSTN = function(url,data,successHandler){
909    var xmlhttp;
910    if (window.XMLHttpRequest) {
911        xmlhttp = new XMLHttpRequest();
912    } else {
913        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
914    }
915    xmlhttp.onreadystatechange = function(){
916        if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
917            /*var data = xmlhttp.response;*/
918            var data = xmlhttp.responseText;
919            if(data)
920                data = JSON.parse(data);
921            successHandler && successHandler(data);
922        }
923    };
924    xmlhttp.open("POST", url, true);
925    /*    xmlhttp.responseType = 'json';*/
926   // xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
927    xmlhttp.send(data);
928};
929
930/** Get **/
931var GETN = function(url,successHandler){
932    var xmlhttp;
933    if (window.XMLHttpRequest) {
934        xmlhttp = new XMLHttpRequest();
935    } else {
936        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
937    }
938    xmlhttp.onreadystatechange = function(){
939        if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
940            var data = xmlhttp.responseText;
941            try {
942                var data = JSON.parse(data);
943            } catch (e) {}
944            successHandler && successHandler(data);
945        }
946    };
947    xmlhttp.open("GET", url, true);
948    xmlhttp.send();
949};

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.