1'use strict'; 2 3class TsoftWebPush { 4 5 constructor(){ 6 7 let _this = this; 8 9 if ('serviceWorker' in navigator) { 10 navigator.serviceWorker.register('/sw.js').then(function() { 11 return navigator.serviceWorker.ready; 12 }).then(function(reg) { 13 14 reg.pushManager.subscribe({ 15 userVisibleOnly: true, 16 applicationServerKey: "BOw5hIuGSMUHIDpKZNRX4PaGBlklPlhJhQeIhKATQfysNtksthiesDhVDeMLoE9z-Pr9jYDGyYFRzoiyzYZLp7w", 17 }).then(function(sub) { 18 19 let params = JSON.parse(JSON.stringify(sub)); 20 let replaced = 'https://android.googleapis.com/gcm/send/'; 21 22 23 let form = new FormData(); 24 form.append('registration_id', params.endpoint); 25 form.append('p256dh', params.keys.p256dh); 26 form.append('auth', params.keys.auth); 27 28 fetch('/srv/service/guest/registerNotificationList', { 29 method: 'POST', 30 body:form 31 }) 32 .then(response => response.json()) 33 .then(json => { 34 console.log(json); 35 }) 36 .catch(err => { 37 console.log(err); 38 }); 39 40 _this.setCookie('webpush', 1, 30); 41 42 }); 43 }). 44 catch (function(error) { 45 console.log('Service Worker error :^(', error); 46 }); 47 } 48 } 49 50 setCookie(c_name, value, exdays) { 51 let exdate = new Date(); 52 exdate.setDate(exdate.getDate() + exdays); 53 let c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString()); 54 if(location.protocol == 'https:'){ 55 c_value += "; secure"; 56 } 57 document.cookie = c_name + "=" + c_value; 58 } 59 60 getCookie(c_name) { 61 let i, x, y, ARRcookies = document.cookie.split(";"); 62 for (i = 0; i < ARRcookies.length; i++) { 63 x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); 64 y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); 65 x = x.replaceAll(/^\s+|\s+$/g, ""); 66 if (x == c_name) { 67 return unescape(y); 68 } 69 } 70 } 71 72} 73
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.