PageSourceSearch

https://merolagani.com/Scripts/jquicker-1.5.js

js merolagani.com collected 2026-10-02 12:59:06 UTC 9,054 bytes, 236 lines download raw bytes

1//document.addEventListener('DOMContentLoaded', function () {
2//    if (!Notification) {
3//        alert('Desktop notifications not available in your browser.');
4//        return;
5//    }
6
7//    navigator.serviceWorker.register('/sw.js');
8
9//    let expiryDate = new Date(localStorage.getItem('reqeustNotificationExpiryDate'));
10
11//    if (Notification.permission === "default" && expiryDate <= new Date()) {
12//        $('.popup').show();
13//    }
14//    else {
15//        AlertNotification.checkNotificationSubscription();
16//    }
17//});
18
19var AlertNotification = {
20    requestNotification: function () {
21        if (Notification.permission !== "granted")
22            Notification.requestPermission(function (permission) {
23                // If the user accepts, let's create a notification
24                if (permission === "granted") {
25                    // call api to update notification record
26                    AlertNotification.checkNotificationSubscription();
27
28                    navigator.serviceWorker.ready.then(function (registration) {
29                        registration.showNotification("", {
30                            body: 'Thank you for subscribing to Merolagani News Alerts',
31                            icon: 'https://merolagani.com/Content/images/merolagani.png',
32                            data: "",
33                            actions: [{ action: 'close', title: 'close' }]
34                        });
35                    });
36                }
37            });
38    },
39    notifyPromotion: function (data) {
40        var setCookieVal = 0; var arrayNews = [];
41
42        if (!AlertNotification.readCookie('promoCookieList')) {
43            AlertNotification.createCookie('promoCookieList', setCookieVal, 1);
44        }
45
46        var cookieVal = AlertNotification.getCookie('promoCookieList');
47
48        if (cookieVal != 0) {
49            var id = cookieVal.split('|');
50
51            for (var i = 0; i < id.length - 1; i++) {
52                arrayNews.push(parseInt(id[i]));
53            }
54        }
55
56        var dataLength = data.length;
57        var arrayLength = arrayNews.length;
58
59        if (Notification.permission === "granted") {
60            $.each(data, function () {
61                setCookieVal = setCookieVal + this.PromotionID + '|';
62                if ((dataLength - arrayLength) === 1) {
63                    if (cookieVal == 0) {
64                            AlertNotification.sendImageNotification(this.PromotionID, this.Title, this.Description, this.ImagePath, this.Url);
65                    } else {
66                        if (arrayNews.length > 0) {
67                            var index = $.inArray(this.PromotionID, arrayNews);
68                            if (index == -1) {
69                                AlertNotification.sendImageNotification(this.PromotionID, this.Title, this.Description, this.ImagePath, this.Url);
70                            }
71                        }
72                    }
73                }
74
75            });
76
77            if (cookieVal == 0) {
78                AlertNotification.createCookie('promoCookieList', setCookieVal, 1);
79            } else {
80                AlertNotification.createCookie('promoCookieList', "", -1);
81                AlertNotification.createCookie('promoCookieList', setCookieVal, 1);
82            }
83        }
84
85    },
86
87    notifyMe: function (data) {
88        var setCookieVal = 0; var arrayNews = [];
89        let newsCookieList = [];
90
91        if (!AlertNotification.readCookie('newsCookieList')) {
92            AlertNotification.createCookie('newsCookieList', setCookieVal, 1);
93        }
94
95        var cookieVal = AlertNotification.getCookie('newsCookieList');
96       
97        if (cookieVal != 0) {
98            var id = cookieVal.split('|');
99
100            for (var i = 0; i < id.length; i++) {
101                arrayNews.push(parseInt(id[i]));
102            }
103        }
104
105        var dataLength = data.length;
106
107        var arrayLength = arrayNews.length;
108
109        if (Notification.permission !== "granted") {}
110        else {
111            $.each(data, function () {
112                
113                var index = $.inArray(this.NewsID, arrayNews);
114                if (index == -1) {
115                   // AlertNotification.sendNotification(this.NewsID, this.NewsTitle, this.FileName);
116                }
117
118                newsCookieList.push(this.NewsID);
119
120            });
121
122            setCookieVal = (newsCookieList.length > 0) ? newsCookieList.join('|') : "0";
123
124            if (cookieVal == 0) {
125                AlertNotification.createCookie('newsCookieList', setCookieVal, 1);
126            } else {
127                AlertNotification.createCookie('newsCookieList', "", -1);
128                AlertNotification.createCookie('newsCookieList', setCookieVal, 1);
129            }
130        }
131
132    },
133    sendNotification: function (id, title, file) {
134         //console.log(id);
135        navigator.serviceWorker.ready.then(function (registration) {
136
137            registration.showNotification("", {
138                body: title,
139                icon: 'https://images.merolagani.com/Uploads/Repository/' + file,
140                data: {
141                    id: id,
142                    uniqueId: $.cookie('notifToken')
143                },
144                actions: [{ action: 'close', title: 'close' }]
145            });
146        });        
147    },
148
149    sendImageNotification: function (id, title, description, imagePath, url) {
150        navigator.serviceWorker.ready.then(function (registration) {
151            registration.showNotification(title, {
152                body: description,
153                icon: 'https://images.merolagani.com/Uploads/Repository/merolagani.png',
154                image: imagePath,
155                data: {
156                    id: id,
157                    url: url,
158                    uniqueId: $.cookie('notifToken')
159                },
160                tag: 'promotion'
161                //actions: [{ action: 'close', title: 'close' }]
162            });
163        });     
164    },
165
166    createCookie: function (name, value, days) {
167        var expires = "";
168        if (days) {
169            var date = new Date();
170             date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); // days
171            //date.setTime(date.getTime() + (days * 60 * 60 * 1000)); // hours
172            expires = "; expires=" + date.toGMTString();
173        }
174        else  expires = "";
175        document.cookie = name + "=" + value + expires + "; path=/";
176    },
177    readCookie: function (name) {
178        if (typeof $.cookie('newsCookieList') === 'undefined') {
179            return false;
180        } else {
181            var i, x, y, ARRcookies = document.cookie.split(";");
182            for (i = 0; i < ARRcookies.length; i++) {
183                x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
184                y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
185                x = x.replace(/^\s+|\s+$/g, "");
186                if (x == name) {
187                    return true;
188                }
189            }
190        }
191        return false;
192    },
193    getCookie: function (name) {
194        var re = new RegExp(name + "=([^;]+)");
195        var value = re.exec(document.cookie);
196        return (value != null) ? unescape(value[1]) : null;
197    },
198    updateRequestExpiryDate() {
199        let expiryDate = new Date();
200        expiryDate.setDate(expiryDate.getDate() + 15);
201        localStorage.setItem('reqeustNotificationExpiryDate', expiryDate.toDateString())
202    },
203    checkNotificationSubscription() {
204        if (Notification.permission === 'granted') {
205            if (!$.cookie('notifToken')) {
206                //call api to update notification record
207                $.ajax({
208                    type: "POST",
209                    async: false,
210                    url: 'https://merolagani.com/handlers/webrequesthandler.ashx?type=update_notification_subscription',
211                    data: null,
212                    success: function (resultData) {
213                    },
214                    error: function (e) {
215                    }
216                });
217            }
218            else if ((!$.cookie('notifUserToken') || $.cookie('notifUserToken') === 'no') && $.cookie('meroLagani_LoginSession')) {
219                //call api to update userid in notification record
220                $.ajax({
221                    type: "POST",
222                    contentType: "application/json",
223                    async: false,
224                    url: 'https://merolagani.com/handlers/webrequesthandler.ashx?type=update_notification_subscription',
225                    data: JSON.stringify({
226                        notifToken: $.cookie('notifToken')
227                    }),
228                    success: function (resultData) {
229                    },
230                    error: function (e) {
231                    }
232                });
233            }
234        }
235    }
236};

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.