summaryrefslogtreecommitdiff
path: root/frontend/permissionrequest.js
blob: 1a9010989c3be252833ea82f3a3726d62d88a96a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const notif = document.getElementById("notif-panel");
const notbtn = document.getElementById("notbtn");

(async function () {
	cookie = await cookieStore.get("subscription_endpoint");
	if (cookie) {
		notif.style.display = "none";
	}
})();

notbtn.addEventListener("click", () => requestPermission());
async function requestPermission() {
	const sub_result = await subscribe();
	
	if (!sub_result) {
		return;
	}

	notif.style.display = "none";

	// this is disgusting
	if (typeof startbtn !== 'undefined') {
		startbtn.disabled = false;
	}
}