Compare commits
12 Commits
a037e4afec
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e5e59f6aa | ||
|
|
b240278e91 | ||
|
|
ab346408c9 | ||
|
|
0ab61c3007 | ||
|
|
5f5555eb50 | ||
|
|
2e9c4f1dc7 | ||
|
|
85053cbf97 | ||
|
|
a6e3ea3737 | ||
|
|
432566354b | ||
|
|
d84800138d | ||
|
|
5f5f9aaed9 | ||
|
|
729588d37c |
@@ -85,7 +85,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
<footer>
|
||||
<a href="https://scm.dairydemon.net/filifa/mcalc">source</a>
|
||||
<a href="/legal.html">legal</a>
|
||||
<a href="./legal.html">legal</a>
|
||||
</footer>
|
||||
|
||||
<script type="module" src="main.js"></script>
|
||||
|
||||
13
main.js
13
main.js
@@ -149,3 +149,16 @@ document.querySelector("#clear").addEventListener("click", clear);
|
||||
document.querySelector("#enter").addEventListener("click", evaluate);
|
||||
|
||||
document.querySelector("#backspace").addEventListener("click", backspace);
|
||||
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.register("workers/service.js").then(
|
||||
(registration) => {
|
||||
console.log("Service worker registration successful:", registration);
|
||||
},
|
||||
(error) => {
|
||||
console.error(`Service worker registration failed: ${error}`);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
console.error("Service workers are not supported.");
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
{
|
||||
"short_name": "mcalc",
|
||||
"name": "mcalc",
|
||||
"scope": "/mcalc",
|
||||
"id": "/mcalc",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icon.svg"
|
||||
"src": "icon.svg",
|
||||
"sizes": "any",
|
||||
"purpose": "maskable",
|
||||
"type": "image/svg+xml"
|
||||
}
|
||||
],
|
||||
"start_url": "/index.html",
|
||||
"start_url": "/mcalc/index.html",
|
||||
"display": "standalone"
|
||||
}
|
||||
|
||||
60
workers/service.js
Normal file
60
workers/service.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (C) 2025 filifa
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const VERSION = "v1";
|
||||
|
||||
const CACHE_NAME = `mcalc-${VERSION}`;
|
||||
|
||||
const APP_STATIC_RESOURCES = [
|
||||
"../index.html",
|
||||
"../legal.html",
|
||||
"../styles.css",
|
||||
"../main.js",
|
||||
"evaluate.js",
|
||||
"lexer.js",
|
||||
"math.js",
|
||||
"parser.js",
|
||||
"../icon.svg"
|
||||
];
|
||||
|
||||
// On install, cache the static resources
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const cache = await caches.open(CACHE_NAME);
|
||||
cache.addAll(APP_STATIC_RESOURCES);
|
||||
})(),
|
||||
);
|
||||
});
|
||||
|
||||
// delete old caches on activate
|
||||
self.addEventListener("activate", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const names = await caches.keys();
|
||||
await Promise.all(
|
||||
names.map((name) => {
|
||||
if (name !== CACHE_NAME) {
|
||||
return caches.delete(name);
|
||||
}
|
||||
return undefined;
|
||||
}),
|
||||
);
|
||||
await clients.claim();
|
||||
})(),
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user