-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
58 lines (52 loc) · 1.65 KB
/
index.html
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!doctype html>
<html lang="fi">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Kalkki</title>
<meta name="description" content="Selainpohjainen tieteislaskin">
<meta name="theme-color" content="#1D2D35">
<link rel="icon" type="image/svg+xml" href="/kalkki.svg" />
<link rel="mask-icon" href="/kalkki.svg" color="#B2DC5B">
<link rel="icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180">
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
window.addEventListener("appinstalled", () => {
localStorage.setItem('pwa', 'true');
window.resizeTo(500, 640);
window.moveTo(
Math.round((screen.width - 500) / 2),
Math.round((screen.height - 640) / 2)
)
});
let install = null;
window.addEventListener('beforeinstallprompt', (ev) => {
ev.preventDefault();
install = ev;
const prompt = document.querySelector('#pwa-install-prompt');
if (prompt) {
prompt.hidden = false;
}
});
async function installPWA() {
if (install !== null) {
const res = await install.prompt();
}
document.querySelector('#pwa-install-prompt').hidden = true;
}
window.addEventListener('DOMContentLoaded', () => {
if (localStorage.getItem('pwa') === 'true') {
const prompt = document.querySelector('#pwa-install-prompt');
if (prompt) {
prompt.innerHTML = 'avaamalla sen PWA-sovelluksena tai '
prompt.hidden = false;
}
}
})
</script>
</body>
</html>