1window.notificationsEnabled = true; 2 3 4const firebaseConfig = { 5 apiKey: "AIzaSyDwudRAEWLOyCeXCvP603tsTe9fRzYHuKk", 6 authDomain: "arguschat.firebaseapp.com", 7 projectId: "arguschat", 8 storageBucket: "arguschat.appspot.com", 9 messagingSenderId: "182281139407", 10 appId: "1:182281139407:web:a943d9b5d25c837165b3ba", 11 measurementId: "G-3RW9MM7KDD" 12}; 13// Initialize Firebase 14firebase.initializeApp(firebaseConfig); 15 16const messaging = firebase.messaging(); 17 18messaging.onMessage(function (payload) { 19 20 if (document?.getElementById("chat-main-view") != null) 21 return; 22 23 navigator.serviceWorker.getRegistration('/firebase-cloud-messaging-push-scope').then(registration => { 24 registration.showNotification( 25 payload.notification.title, 26 payload.notification 27 ) 28 }); 29}); 30 31window.getPushToken = async function() { 32 try { 33 var currentToken = await messaging.getToken(); 34 35 if (currentToken) 36 return currentToken; 37 38 // Show permission request. 39 if (await requestPermission()) 40 return await window.getPushToken(); 41 42 } 43 catch (e) { 44 console.error("Error during getPushToken", e); 45 } 46 47 return null; 48} 49 50window.setNotificationsEnabled = function (enabled) { 51 window.notificationsEnabled = enabled; 52} 53 54async function requestPermission() { 55 try { 56 var permission = await messaging.requestPermission(); 57 58 if (permission === 'granted') 59 return true; 60 61 } 62 catch (e) { 63 console.error("Error during RequestPermission", e); 64 } 65 66 return false; 67} 68 69function sendTokenToServer(token) { 70 if (!isTokensendTokenToServer()) { 71 //$.ajax({ 72 // url: URL, 73 // type: 'POST', 74 // data: { 75 // //whatever you wanna send 76 // push_token: token, 77 // }, 78 // success: function (response) { 79 // setTokenSentToServer(true); 80 // }, 81 // error: function (err) { 82 // setTokenSentToServer(false); 83 // }, 84 //}); 85 } 86} 87function isTokensendTokenToServer() { 88 return window.localStorage.getItem('sendTokenToServer') === '1'; 89} 90function setTokenSentToServer(sent) { 91 window.localStorage.setItem('sendTokenToServer', sent ? '1' : '0'); 92}
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.