summaryrefslogtreecommitdiff
path: root/frontend/start.js
blob: 374c68d72e1d9967a7c53fcc7fea34a7062793aa (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
26
27
28
29
30
const notif = document.getElementById("notif-panel");
const notbtn = document.getElementById("notbtn");
const startbtn = document.getElementById("startbtn");

startbtn.addEventListener("click", () => {
	start();
});

const urlParams = new URLSearchParams(window.location.search);
data.machine_id = urlParams.get('machine');
console.log(urlParams);

startUpdateMachines();

OneSignalDeferred.push(async function(OneSignal) {
	if (OneSignal.Notifications.permission) {
		notif.remove();
		startbtn.disabled = false;
	}
});

notbtn.addEventListener("click", () => requestPermission())
async function requestPermission() {
	console.log("Requesting permission...");
	const onesignal_result = await OneSignal.Notifications.requestPermission();
	if (onesignal_result) {
		notif.remove();
		startbtn.disabled = false;
	}
}