-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex-tmpl.html
303 lines (256 loc) Β· 13 KB
/
index-tmpl.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Π£ΡΡΠ΄ΡΠ» - ΠΠΆΠ΅Π΄Π½Π΅Π²Π½Π° ΠΈΠ³ΡΠ° Π½Π° Π΄ΡΠΌΠΈ</title>
<meta name="description" content="ΠΠΎΠ·Π½Π°ΠΉ ΡΠΊΡΠΈΡΠ°ΡΠ° Π΄ΡΠΌΠ° ΠΎΡ 6 ΠΎΠΏΠΈΡΠ°. ΠΡΠ΅ΠΊΠΈ Π΄Π΅Π½ ΠΈΠΌΠ° Π½ΠΎΠ² ΠΏΡΠ·Π΅Π».">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- FB Meta Tags -->
<meta property="og:url" content="https://wordle-bg.ggerganov.com">
<meta property="og:type" content="website">
<meta property="og:title" content="Π£ΡΡΠ΄ΡΠ» - ΠΠΆΠ΅Π΄Π½Π΅Π²Π½Π° ΠΈΠ³ΡΠ° Π½Π° Π΄ΡΠΌΠΈ">
<meta property="og:description" content="ΠΠΎΠ·Π½Π°ΠΉ ΡΠΊΡΠΈΡΠ°ΡΠ° Π΄ΡΠΌΠ° ΠΎΡ 6 ΠΎΠΏΠΈΡΠ°. ΠΡΠ΅ΠΊΠΈ Π΄Π΅Π½ ΠΈΠΌΠ° Π½ΠΎΠ² ΠΏΡΠ·Π΅Π».">
<meta property="og:image" content="https://wordle-bg.ggerganov.com/logo-512.png">
<!-- Twitter Meta Tags -->
<meta name="twitter:title" content="Π£ΡΡΠ΄ΡΠ»" />
<meta name="twitter:card" content="summary">
<meta name="twitter:description" content="ΠΠΎΠ·Π½Π°ΠΉ ΡΠΊΡΠΈΡΠ°ΡΠ° Π΄ΡΠΌΠ° ΠΎΡ 6 ΠΎΠΏΠΈΡΠ°. ΠΡΠ΅ΠΊΠΈ Π΄Π΅Π½ ΠΈΠΌΠ° Π½ΠΎΠ² ΠΏΡΠ·Π΅Π»." />
<meta name="twitter:image" content="https://wordle-bg.ggerganov.com/logo-512.png" />
<meta property="twitter:domain" content="ggerganov.com">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta name="theme-color" content="#6aaa64" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-GT8KBQZW9H"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-GT8KBQZW9H');
</script>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="helpers.js"></script>
</head>
<body>
<div id="main-container">
<div id="description" align="center">
<h2>Π£ΡΡΠ΄ΡΠ»</h2>
<div id="container_status" align="center">
ΠΠ°ΡΠ΅ΠΆΠ΄Π°Π½Π΅ - ΠΌΠΎΠ»Ρ ΠΈΠ·ΡΠ°ΠΊΠ°ΠΉΡΠ΅ ...
</div>
</div>
<div id="container_canvas" hidden>
<canvas class="emscripten" id="canvas"></canvas>
</div>
</div>
<script type='text/javascript'>
var isMobile = mobileCheck();
var isInitialized = false;
var failedToInitialize = false;
function updateWindowSize() {
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
Module.set_window_size(0.99*x, 0.99*y);
}
window.setInterval(function(){
if (isInitialized == false) return;
updateWindowSize();
if (Module.get_puzzle_id() >= 0) {
var dataAttempts = Module.get_attempts();
if (dataAttempts.length > 0) {
localStorage["attempts_" + Module.get_puzzle_id()] = dataAttempts;
}
}
var dataStatistics = Module.get_statistics();
if (dataStatistics.length > 0) {
localStorage.statistics = dataStatistics;
}
var dataSettings = Module.get_settings();
if (dataSettings.length > 0) {
localStorage.settings = dataSettings;
}
}, 500);
function onkeydown(event) {
//console.log(event);
if (event.ctrlKey ||
(event.keyCode >= 112 && event.keyCode <= 123)) {
event.stopImmediatePropagation();
return;
}
if (event.keyCode == 8 || // Backspace
event.keyCode == 9 || // Tab
event.keyCode == 46 || // Delete
(event.keyCode >= 37 && event.keyCode <= 40)) { // Arrow keys
event.preventDefault();
}
}
function updateClipboard() {
var dataClipboard = Module.get_clipboard();
if (dataClipboard.length > 0) {
console.log(dataClipboard);
// Restrict share dialog to mobile devices only, since desktop OS-es tend to not feature copying to clipboard
// See: https://github.com/ggerganov/wordle-bg/issues/11
if (navigator.share && isMobile) {
navigator.share({
title: document.title,
text: dataClipboard
//,url: window.location.href
})
.then(function() {
console.log('Successful share');
Module.set_clipboard_text_visible(false);
})
.catch(function(error) {
console.log('Error sharing:', error);
// Copy to clipboard on share error, except when the share is aborted.
if (!(error instanceof AbortError)) {
Module.set_clipboard_text_visible(true);
copyToClipboard(dataClipboard);
}
});
} else {
copyToClipboard(dataClipboard);
}
}
}
function checkForActions(event) {
// on Firefox Quantum, need to call this directly, otherwise the following error is reported:
// document.execCommand('cut'/'copy') was denied because it was not called from inside a short running user-generated event handler.
updateClipboard();
// on other browsers, need to update the clipboard after a short interval
// I guess it has something to do with the ImGui::IsMouseReleased(0) logic - probably need to use the mouse-down event instead ..
setTimeout(function() {
updateClipboard();
// check if the app requested to open a URL
var dataURL = Module.get_url();
if (dataURL.length > 0) {
window.open(dataURL, '_blank').focus();
}
}, 100);
}
function init() {
// If sharing is supported, hide the "Results copied to clipboard" text by default.
// The text will be shown only if sharing fails.
if (navigator.share && isMobile) {
Module.set_clipboard_text_visible(false);
}
document.getElementById('container_status').innerHTML = "WebAssembly module initialized successfully!"
document.getElementById('container_status').style.color = "#00ff00";
window.addEventListener('keydown', onkeydown, true);
window.addEventListener('touchend', checkForActions, true);
window.addEventListener('mouseup', checkForActions, true);
}
function doInit() {
if (isInitialized == false) {
//var puzzleIdOffset = findGetParameter('p') || 0;
//Module.set_timestamp((new Date().getTime()/1000) + 24*3600*puzzleIdOffset);
// take into account EEST timezone
{
var d = new Date();
var T = (d.getTime() - (d.getTimezoneOffset() + 120)*60*1000)/1000;
Module.set_timestamp(T);
}
if (Module.do_puzzle_init() == false) {
failedToInitialize = true;
window.onerror('Failed to initialize initial puzzle!');
return;
}
// Get puzzle attempts
let attemptsKeys = Object.keys(localStorage).filter(key => key.startsWith("attempts_"));
for (const key of attemptsKeys) {
const keySplit = key.split('_');
if (keySplit[1].length == 0) {
localStorage.removeItem(key);
continue;
}
const puzzleID = Number(keySplit[1]);
if (puzzleID == NaN || puzzleID < 0) {
localStorage.removeItem(key);
continue;
}
Module.set_attempts(puzzleID, localStorage[key]);
}
if (localStorage.getItem('statistics') !== null) {
Module.set_statistics(localStorage.statistics);
}
if (localStorage.getItem('settings') !== null) {
Module.set_settings(localStorage.settings);
}
if (Module.do_game_init() == false) {
failedToInitialize = true;
window.onerror('Failed to initialize game state!');
return;
}
updateWindowSize();
isInitialized = true;
}
{
var status = document.getElementById("description");
status.hidden = true;
}
{
var canvas = document.getElementById("container_canvas");
canvas.hidden = false;
//canvas.classList.add("fade-in");
}
}
var Module = {
arguments: [],
preRun: [(function() {
console.log(
' Build time: @GIT_DATE@\n' +
' Github repo: https://github.com/ggerganov/wordle-bg\n' +
' Commit hash: https://github.com/ggerganov/wordle-bg/commit/@GIT_SHA1@"\n' +
'Commit subject: @GIT_COMMIT_SUBJECT@\n'
);
})],
postRun: [(function () {
if (failedToInitialize) return;
init();
doInit();
})],
canvas: (function() {
var canvas = document.getElementById('canvas');
canvas.addEventListener("webglcontextlost", function(e) {
alert('WebGL context lost. You will need to reload the page.'); e.preventDefault();
}, false);
return canvas;
})(),
print: function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
console.log(text);
},
printErr: function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
console.error(text);
},
setStatus: function(text) {
console.log("status: " + text);
},
monitorRunDependencies: function(left) {
// no run dependencies to log
}
};
window.onerror = function(event) {
failedToInitialize = true;
console.log("onerror: " + JSON.stringify(event));
document.getElementById('container_status').innerHTML = JSON.stringify(event);
document.getElementById('container_status').innerHTML += '<br>This browser is not supported. Please try a different browser';
document.getElementById('container_status').style.color = "#ff0000";
};
</script>
<script async type="text/javascript" src="wordle-@GIT_SHA1@.js"></script>
<!--
<script>document.write('<script async type="text/javascript" src="wordle.js?dev=' + Math.floor(Math.random() * 1000) + '"\><\/script>');</script>
-->
</body>
</html>