/
index.html
95 lines (81 loc) · 3.1 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
<!DOCTYPE html>
<html lang="cs">
<meta charset="utf-8">
<title>Geohry ŠkolaZdola</title>
<script>
// https redirect
if (location.protocol !== "https:") location.protocol = "https:";
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="manifest" href="geohry.webmanifest.json">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="ui/forms.css">
<link rel="stylesheet" href="ui/table.css">
<link rel="stylesheet" href="ui/loader.css">
<script src="ui/router.js"></script>
<script src="main.js"></script>
<script src="texts.js"></script>
<script src="https://api.mapy.cz/loader.js"></script>
<script>Loader.load();</script>
<script src="ui/sort.js"></script>
<script src="ui/maps.js"></script>
<script src="ui/mapsimg.js"></script>
<script src="ui/sprite.js"></script>
<script src="ui/play.js"></script>
<script src="ui/qrcode.min.js"></script>
<script src="ui/html5-qrcode.min.js"></script>
<script src="ui/fetch.js"></script>
<script src="cache.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-LEGC2DDQDW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-LEGC2DDQDW');
</script>
<main id="main"></main>
<script>
var currentVersion = localStorage.getItem("VERSION.current");
fetch("version.txt").then(res => res.text()).then(res => {
res = res.trim();
function cacheReset() {
var theCache;
return caches.open('store')
.then(cache => theCache = cache)
.then(cache => cache.keys())
.then(keys => {
var stack = [];
keys.forEach(request => stack.push(theCache.delete(request)));
return Promise.all(stack);
})
.then(_ => theCache.addAll(cached)) // cached defined in cache.js
}
if (!currentVersion || res != currentVersion) {
localStorage.clear();
localStorage.setItem("VERSION.current", res);
console.log("PAGE WAS RESETED BY VERSION NUMBER!");
cacheReset().then(() => {
pageWasLoaded();
});
} else {
pageWasLoaded();
}
});
function pageWasLoaded() {
// load the cache
var cacheurl = _ => `cache.js?t=${+new Date()}`;
navigator.serviceWorker.register(cacheurl()).then(reg => {
console.log('Cache Service Worker Registered');
});
var url = new URL(location.href);
STATE.game = url.searchParams.get("game");
if(STATE.game) setContent("loadGame");
else if(LS.get("G", "demo")) setContent("playDemo");
else if(LS.get("G", "game") && LS.get("G", "questions")) setContent("playHome");
else if(LS.get("U", "login")) setContent("homeUser");
else if(LS.get("E", "login")) setContent("homeGame");
else setContent("home");
}
</script>
</html>