create PWA

This commit is contained in:
Lurkars 2024-05-05 08:02:29 +02:00
parent 027e223e7e
commit 21aefb1710
2 changed files with 31 additions and 4 deletions

View File

@ -2,13 +2,30 @@
<html lang="en">
<meta charset="UTF-8">
<title>RPG Dices</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<meta name="apple-mobile-web-app-status-bar" content="#ffffff" />
<link rel="apple-touch-icon" href="assets/icons/icon-72x72.png" />
<link rel="apple-touch-icon" href="assets/icons/icon-96x96.png" />
<link rel="apple-touch-icon" href="assets/icons/icon-128x128.png" />
<link rel="apple-touch-icon" href="assets/icons/icon-144x144.png" />
<link rel="apple-touch-icon" href="assets/icons/icon-152x152.png" />
<link rel="apple-touch-icon" href="assets/icons/icon-192x192.png" />
<link rel="apple-touch-icon" href="assets/icons/icon-384x384.png" />
<link rel="apple-touch-icon" href="assets/icons/icon-512x512.png" />
<link rel="manifest" href="manifest.json" />
<link rel="stylesheet" href="style.css">
<script src="js/libs/moment.js"></script>
<script src="js/libs/sidebar/sidebar.js"></script>
<link href="js/libs/sidebar/sidebar.css" type="text/css" rel="stylesheet" />
<style>
</style>
<body>
<label id="sidebar-toggle" class="sidebar-toggle" for="sidebar-toggle-input"><img src="./assets/menu.svg"></label>
@ -77,7 +94,7 @@
<button id="history-button" onclick="clearHistory()"><img src="./assets/history.svg"> Clear
History</button>
<button id="roll-add-button" onclick="addSelected()"><img src="./assets/add.svg"> Add Selected</button>
<button id="roll-button" onclick="rollSelected()"><img src="./assets/roll.svg"> Roll Selected</button>
<button id="roll-button" onclick="rollSelected()"><img src="./assets/roll.svg"> Roll Selected</button>
</div>
<div class="history" id="history"></div>

View File

@ -471,4 +471,14 @@ if (darkMode) {
document.body.classList.add("dark");
document.getElementById("dark-mode-icon").src = "./assets/light.svg";
document.getElementById("dark-mode-text").innerText = "Light Mode";
}
}
if ("serviceWorker" in navigator) {
window.addEventListener("load", function() {
navigator.serviceWorker
.register("/sw.js")
.then(res => console.trace("service worker registered"))
.catch(err => console.error("service worker not registered", err))
})
}