-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
162 lines (132 loc) · 5.15 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>โค้ดดิ้ง ปิ้งไก่</title>
<meta name="title" content="โค้ดดิ้ง ปิ้งไก่">
<meta name="description" content="Algorithm Learning for everyone!">
<link rel="icon" href="/favicon.ico">
<link rel="icon" type="image/svg+xml" href="/logos/logo.svg" />
<link rel="apple-touch-icon" href="/logos/apple-touch-icon.png" sizes="180x180">
<link rel="mask-icon" href="/logos/mask-icon.svg" color="#FFF4CE">
<meta name="theme-color" content="#ededed">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pikai.devpixels.xyz/">
<meta property="og:title" content="โค้ดดิ้ง ปิ้งไก่">
<meta property="og:description" content="อัลกอริทึม สำหรับทุกคน!">
<meta property="og:image" content="https://pikai.devpixels.xyz/metabanner.png">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pikai.devpixels.xyz/">
<meta property="twitter:title" content="โค้ดดิ้ง ปิ้งไก่">
<meta property="twitter:description" content="อัลกอริทึม สำหรับทุกคน!">
<meta property="twitter:image" content="https://pikai.devpixels.xyz/metabanner.png">
<style>
#preload-i {
background-color: #F3F3F3;
position: fixed;
top: 0;
left: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.preload-loaded {
animation: preloadLoaded 0.5s cubic-bezier(0.16, 1, 0.3, 1);
animation-fill-mode: forwards;
}
#updateBtn {
display: inline-block;
background-color: #FF7733;
color: white;
border: none;
border-radius: 10px;
padding: 10px 20px;
cursor: pointer;
}
#updatesFound {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
opacity: 0;
}
#updatesFound.foundUpdate {
opacity: 1;
}
#updateBtn:disabled {
opacity: 0.5;
pointer-events: none;
}
@keyframes preloadLoaded {
to {
transform: scale(1.2);
opacity: 0;
background-color: #f3f3f300
}
}
</style>
</head>
<body>
<div id="preload-i" style="width: 100vw;height: 100vh;z-index: 9999999;">
<img src="/logo_preload.png" width="100" height="100" alt="กำลังโหลด..."
style="position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);" />
<div id="updatesFound"
style="position: absolute;top: calc(50% + 110px);left: 50%;transform: translate(-50%, -50%);">
<p style="margin-top: 10px;">ตรวจพบการอัปเดต กรุณาอัปเดตแอปพลิเคชันเพื่อไปต่อ</p>
<button id="updateBtn">อัปเดต</button>
</div>
</div>
<script defer>
async function waitAppVer() {
console.log("Waiting for __APP_VERSION__");
while (!window.hasOwnProperty("__APP_VERSION__"))
await new Promise(resolve => setTimeout(resolve, 1000));
console.log("__APP_VERSION__ Defined");
}
async function mainBackupUpdater() {
console.log("Backup checking for updates...")
await waitAppVer()
const versionRes = await fetch("/version.json", { cache: "no-store" })
const versionData = await versionRes.json()
const backupAppUpdate = async () => {
console.log("Updating")
if ('serviceWorker' in navigator) {
const registrations = await navigator.serviceWorker.getRegistrations()
let prog = 0
for (let registration of registrations) {
registration.update()
console.log("Updating Register ", prog)
prog++
}
const names = await caches.keys()
prog = 0
for (let name of names) {
caches.delete(name)
console.log("Clearing Cache ", name)
}
}
location.href = location.href
}
if (versionData.version != __APP_VERSION__) {
document.querySelector("#updatesFound").classList.add('foundUpdate')
document.querySelector("#updateBtn").addEventListener('click', () => {
document.querySelector("#updateBtn").textContent = "กำลังอัปเดต"
document.querySelector("#updateBtn").setAttribute('disabled', 'disabled')
backupAppUpdate()
})
}
}
mainBackupUpdater()
</script>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8"
crossorigin="anonymous"></script>
</body>
</html>