Skip to content
Snippets Groups Projects
Commit 5daceb87 authored by Miniontoby's avatar Miniontoby :writing_hand_tone1:
Browse files

Fixed links for pages and added compatibility for tauri

parent 6ec0e4df
No related branches found
No related tags found
No related merge requests found
Pipeline #114043 passed
......@@ -4,11 +4,11 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Plan2Go Calandar</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="./style.css">
<script src="https://kit.fontawesome.com/a0d8d27dcc.js" crossorigin="anonymous"></script>
<link rel="manifest" href="/manifest.json">
<link rel="manifest" href="../manifest.json">
<meta name="theme-color" content="#264a8a"/>
<meta name="apple-touch-icon" content="/images/icon.png">
<meta name="apple-touch-icon" content="../images/icon.png">
</head>
<body>
<!--
......
......@@ -4,15 +4,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Index of Plan2Go</title>
<!--<meta http-equiv="refresh" content="2;url=demo/" />-->
<link rel="manifest" href="/manifest.json">
<link rel="manifest" href="./manifest.json">
<meta name="theme-color" content="#264a8a"/>
<meta name="apple-touch-icon" content="/images/icon.png">
<meta name="apple-touch-icon" content="./images/icon.png">
</head>
<body>
<h1>Under construction</h1>
<a href="/demo/">See the demo</a>
<a href="./demo/">See the demo</a>
<button id="notification-button">Notify</button>
<button id="notification-cancel">Cancel</button>
<script src="pwa.js"></script>
<script src="./pwa.js"></script>
</body>
</html>
......@@ -3,10 +3,21 @@ window.addEventListener("load", () => {
navigator.serviceWorker.register("service-worker.js");
navigator.serviceWorker.addEventListener('message', event => console.log(event.data));
}
if ("__TAURI__" in window) {
Notification.showNotification = (title, option={}) => {
if (typeof(title) == 'object') option = title;
if (!("title" in option)) option.title = title;
new Notification(option.title, option);
}
class TimestampTrigger{
constructor(timestamp) {}
}
}
});
document.querySelector('#notification-button').onclick = async () => {
const reg = await navigator.serviceWorker.getRegistration();
let reg = await navigator.serviceWorker.getRegistration();
if ("__TAURI__" in window) reg = Notification;
Notification.requestPermission().then(permission => {
if (permission !== 'granted') {
alert('you need to allow push notifications');
......@@ -39,11 +50,13 @@ document.querySelector('#notification-button').onclick = async () => {
});
};
document.querySelector('#notification-cancel').onclick = async () => {
const reg = await navigator.serviceWorker.getRegistration();
const notifications = await reg.getNotifications({
includeTriggered: true
});
notifications.forEach(notification => notification.close());
alert(`${notifications.length} notification(s) cancelled`);
if (!("__TAURI__" in window)) {
const reg = await navigator.serviceWorker.getRegistration();
const notifications = await reg.getNotifications({
includeTriggered: true
});
notifications.forEach(notification => notification.close());
alert(`${notifications.length} notification(s) cancelled`);
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment