-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
112 lines (110 loc) · 3.44 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PWA test</title>
<link rel="manifest" href="/manifest.json" />
<link rel="stylesheet" href="https://unpkg.com/98.css" />
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<h3>Menu <span class="pwaInlineContent">of PWA 🚀</span></h3>
<nav>
<ul>
<li>Home</li>
<li>About</li>
<li>Pictures</li>
<li>Impressum</li>
</ul>
</nav>
<pwa-install-button>
<button>Install PWA</button>
</pwa-install-button>
<pwa-update-button>
<button>Force Update SW and reload</button>
</pwa-update-button>
<hr />
<h3>Content</h3>
<div class="content">
<div class="window" style="width: 300px;">
<div class="title-bar">
<div class="title-bar-text">A Window With Stuff In It</div>
<div class="title-bar-controls">
<button aria-label="Close"></button>
</div>
</div>
<div class="window-body">
<p>
<button class="installSW1">Install SW 1</button>
</p>
</div>
</div>
<div class="window" style="width: 300px;">
<div class="title-bar">
<div class="title-bar-text">A Window With Stuff In It</div>
<div class="title-bar-controls">
<button aria-label="Close"></button>
</div>
</div>
<div class="window-body">
<p><button class="installSW2">Install SW 2</button></p>
</div>
</div>
<div class="window" style="width: 300px;">
<div class="title-bar">
<div class="title-bar-text">Styled by 98.css</div>
<div class="title-bar-controls">
<button aria-label="Close"></button>
</div>
</div>
<div class="window-body">
<p>
Check it out at
<a href="https://jdan.github.io/98.css/" target="_blank"
>https://jdan.github.io/98.css/</a
>
</p>
</div>
</div>
</div>
<hr />
<footer>
<h3>Footer</h3>
<pwa-install-button>
<button>Install PWA</button>
</pwa-install-button>
<pwa-update-button>
<button>Force Update SW & reload</button>
</pwa-update-button>
</footer>
<script>
const installSW1 = document.querySelector('.installSW1');
const installSW2 = document.querySelector('.installSW2');
const init = async () => {
const installSW1Promise = installSW1.addEventListener('click', () => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js');
}
});
const installSW2Promise = installSW2.addEventListener('click', () => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw2.js');
}
});
const reg = await navigator.serviceWorker.getRegistration();
if (reg) {
if (reg.active.scriptURL.includes('sw.js')) {
installSW1.style.display = 'none';
} else {
installSW2.style.display = 'none';
}
}
};
init();
</script>
<script type="module" src="/pwa-install-button.js"></script>
<script type="module" src="/pwa-update-button.js"></script>
<script type="module" src="/index.js"></script>
</body>
</html>