forked from ggerganov/wordle-bg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-tmpl.html
257 lines (216 loc) · 10.8 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
<!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-128.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-128.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();
var dataAttempts = Module.get_attempts();
if (dataAttempts.length > 0) {
localStorage.attempts = 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);
copyToClipboard(dataClipboard);
if (navigator.share) {
navigator.share({
title: document.title,
text: dataClipboard
//,url: window.location.href
})
.then(() => console.log('Successful share'))
.catch(error => console.log('Error sharing:', error));
}
}
}
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() {
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);
Module.set_timestamp((new Date().getTime()/1000));
if (localStorage.getItem('attempts') !== null) {
Module.set_attempts(localStorage.attempts);
}
if (localStorage.getItem('statistics') !== null) {
Module.set_statistics(localStorage.statistics);
}
if (localStorage.getItem('settings') !== null) {
Module.set_settings(localStorage.settings);
}
if (Module.do_init() == false) {
failedToInitialize = true;
window.onerror('Failed to initialize WASM module');
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-@[email protected]"></script>
<!--
<script>document.write('<script async type="text/javascript" src="wordle.js?dev=' + Math.floor(Math.random() * 1000) + '"\><\/script>');</script>
-->
</body>
</html>