mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-01-24 22:01:49 +01:00
move enable notification from html
This commit is contained in:
parent
7dde4c81db
commit
8586f08adb
@ -1,5 +1,5 @@
|
||||
// SW
|
||||
navigator.serviceWorker.register("sw.js")
|
||||
navigator.serviceWorker.register("sw.js");
|
||||
|
||||
// Minecraft.id
|
||||
let urlParams = new URLSearchParams();
|
||||
@ -236,6 +236,10 @@ function refreshAccountList() {
|
||||
}
|
||||
function renderActions() {
|
||||
actions.innerHTML = "";
|
||||
if (Notification.permission == "default") {
|
||||
actions.innerHTML += '<p><a href="javascript:" id="notificate">Enable notifications</a></p>';
|
||||
$("#notificate").on("click", e => Notification.requestPermission().then(renderActions)); // i'm lazy
|
||||
}
|
||||
if (listenVisible) {
|
||||
if (mcIdUsername != null && mcauth_code != null) {
|
||||
addAction("Listen to " + mcIdUsername, () => {
|
||||
@ -435,8 +439,7 @@ $(() => {
|
||||
// Heroku sleeps in 30 minutes, let's call it every 10 minutes to keep the same address, so Mojang see it as less suspect
|
||||
setInterval(refreshCorsStatus, 10 * 60 * 1000);
|
||||
refreshCorsStatus();
|
||||
|
||||
$("#notificate").on("click", e => Notification.requestPermission());
|
||||
resetHtml();
|
||||
|
||||
connect();
|
||||
});
|
||||
|
@ -62,7 +62,6 @@
|
||||
<p>WebSocket connection status: <span id="connection_status" class="text-white bg-dark">?</span></p>
|
||||
<p>CORS Proxy status: <span id="cors_status" class="text-white bg-dark">?</span></p>
|
||||
<hr>
|
||||
<p><a href="javascript:" id="notificate">Enable notifications</a></p>
|
||||
<p><span id="actions"></span></p>
|
||||
<p><span id="listening"></span></p>
|
||||
</div>
|
||||
|
@ -1,8 +1,8 @@
|
||||
// https://stackoverflow.com/questions/42127148/service-worker-communicate-to-clients
|
||||
let viac = new BroadcastChannel('viaaas-notification');
|
||||
let viac = new BroadcastChannel("viaaas-notification");
|
||||
self.addEventListener("notificationclick", event => {
|
||||
console.log("On notification click: " + event);
|
||||
event.preventDefault();
|
||||
event.notification.close();
|
||||
viac.postMessage({tag: event.notification.tag, action: event.action});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user