-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArbitrary.html
459 lines (378 loc) · 14.1 KB
/
Arbitrary.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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
<!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>Parkrun Token Generator</title>
<meta name="keywords" content="Parkrun, Parkrun Generator, Parkrun Tokens, Parkrun Token, Parkrun finish tokens, finish token, parkrun, Parkrun barcode, Barcode generator for parkrun">
<meta property="og:type" content="website" />
<link rel="shortcut icon" type="image/x.icon" href="favicon.ico?">
<link rel="stylesheet" href="menu.css">
<style>
body {
font-family: Arial, sans-serif;
background: #f0f0f0 url('Background.png') center/cover no-repeat;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
position: relative;
z-index: 1; /* Ensure the body is at a higher stacking order */
}
form {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: left;
position: relative;
overflow: hidden;
z-index: 2; /* Place the form above the body */
}
h2 {
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
}
input[type="text"] {
width: calc(100% - 16px);
padding: 8px;
margin-bottom: 16px;
box-sizing: border-box;
}
input[type="submit"], input[type="button"] {
background-color: #2C2947;
color: #fff;
padding: 15px 25px; /* Larger padding for larger buttons */
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 18px;
margin-top: 10px;
transition: background-color 0.3s;
}
input[type="submit"]:hover, input[type="button"]:hover {
background-color: #524f7e;
}
.token-list {
display: flex;
flex-direction: column;
max-height: 150px;
overflow-y: auto;
}
.token-list-item {
display: flex;
align-items: center;
margin-bottom: 8px;
}
.token-list-item span {
margin-right: 8px;
}
.delete-button {
cursor: pointer;
color: #fff;
background-color: #e74c3c; /* Red background color */
border: none;
font-size: 14px;
padding: 8px 12px; /* Adjust padding as needed */
border-radius: 4px;
transition: background-color 0.3s;
}
.delete-button:hover {
background-color: #c0392b; /* Darker red on hover */
}
#uiCopyright {
position: fixed;
bottom: 10px;
left: 10px;
font-size: 14px;
color: #FFFFFF;
background-color: #2C2947;
padding: 5px 10px;
border-radius: 10px; /* Rounded box */
}
#o {
margin-top: 20px;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: flex-start;
opacity: 0;
transition: opacity 0.5s ease;
}
#buttons {
display: flex;
justify-content: center;
align-items: center;
margin-top: 20px; /* Adjust as needed */
}
#buttons button {
background-color: #3498db;
color: #fff;
padding: 15px 25px; /* Larger padding for larger buttons */
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 18px;
margin-top: 10px;
transition: background-color 0.3s;
z-index: 1; /* Ensure the body is at a higher stacking order */
}
#buttons button:hover {
background-color: #524f7e;
}
.ui-enabled #animated-bg {
display: block;
}
<div id="menuContainer"></div>
@media print {
body * {
visibility: hidden;
}
#o, #o * {
visibility: visible;
}
#o {
position: absolute;
left: 0;
top: 0;
}
#animated-bg {
display: none;
}
#buttons {
display: none;
}
}
/* Add a class to show the animated background when UI is enabled */
.warning {
color: #e74c3c;
font-size: 16px;
margin-top: 5px;
}
@viewport {
zoom: 1.0 !important;
user-zoom: fixed !important;
max-zoom: 1.0 !important;
min-zoom: 1.0 !important;
}
#homeButton {
position: fixed;
top: 10px;
left: 10px;
font-size: 18px;
color: #fff;
background-color: #2C2947;
padding: 10px 15px;
border: none;
border-radius: 6px;
cursor: pointer;
z-index: 3; /* Ensure the home button is above other elements */
transition: background-color 0.3s;
}
#homeButton:hover {
background-color: #524f7e;
}
</style>
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2MCNPFMJVM"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-2MCNPFMJVM');
</script>
<body>
<form class="noPrint" action="javascript:void(0);" method="get" name="f">
<h1>Arbitrary Numbers' Position Token Printing</h1>
<p>Input numbers, then press Enter. Once finished, click on Submit to generate the print file.</p>
<label for="tokenInput">Token Numbers:</label>
<div id="tokenList" class="token-list"></div>
<input type="text" id="tokenInput" name="n" size="4" maxlength="4" placeholder="Enter missing token number here. Press Enter after each number." onkeydown="handleTokenInput(event)" onpaste="handlePaste(event)">
<input type="submit" value="Submit" onclick="generateBarcodes();">
</form>
<div id="o"></div>
<div id="uiCopyright">
© <span id="copyrightYear"></span> Jake Lofthouse ALD Print Ltd
</div>
<div id="buttons">
<input type="button" id="backButton" onclick="goBack()" value="Back" style="display: none; font-size: 45px; margin-right: 10px; ">
<div id="ii"></div>
<input type="button" id="printButton" onclick="printBarcodes()" value="Print" style="display: none; font-size: 45px;">
</div>
<button id="homeButton" onclick="goHome()">Home</button>
<script>
if ("serial" in navigator) {
console.log("Device is not a phone or tablet");
} else {
window.location.href = "https://ald-models.github.io/ParkRun-Barcode/Not_Supported";
}
function goHome() {
// Redirect the user to the specified URL
window.location.href = "https://ald-models.github.io/ParkRun-Barcode/";
}
function handleTokenInput(event) {
if (event.key === "Tab" || event.key === "Enter" || event.key === " ") {
event.preventDefault();
addTokenToList();
} else if (!/^\d+$/.test(event.key)) {
event.preventDefault();
}
}
function addTokenToList() {
var input = document.getElementById('tokenInput');
var tokenList = document.getElementById('tokenList');
var token = input.value.trim();
if (token !== "") {
var listItem = document.createElement('div');
listItem.className = 'token-list-item';
var tokenSpan = document.createElement('span');
tokenSpan.textContent = token;
listItem.appendChild(tokenSpan);
var deleteButton = document.createElement('button');
deleteButton.className = 'delete-button';
deleteButton.textContent = 'Delete';
deleteButton.onclick = function () {
listItem.remove();
};
listItem.appendChild(deleteButton);
tokenList.appendChild(listItem);
// Scroll to the bottom of the list
tokenList.scrollTop = tokenList.scrollHeight;
// Clear input after adding to the list
input.value = "";
}
}
function generateBarcodes() {
var div = document.getElementById('o');
var tokenList = document.getElementById('tokenList');
var tokens = Array.from(tokenList.getElementsByClassName('token-list-item'))
.map(function (item) {
return item.firstChild.textContent;
});
if (tokens.length > 0) {
div.innerHTML = '';
tokens.forEach(function (token) {
var x = '0000' + token;
div.innerHTML = div.innerHTML + '<img src=\'http://results-service.parkrun.com/runnerSupport/BarcodeImagery/image.php?code=P' + x.substr(x.length - 4) + '\'><br>';
});
// Hide the form and display the back and print buttons
var form = document.querySelector('form');
form.style.display = 'none';
var printButton = document.getElementById('printButton');
printButton.style.display = 'block';
var backButton = document.getElementById('backButton');
backButton.style.display = 'block';
// Hide coffee and copyright
var coffee = document.querySelector('script[data-name="BMC-Widget"]');
coffee.parentNode.removeChild(coffee);
}
}
function goBack() {
// Reset to the initial state
var form = document.querySelector('form');
form.style.display = 'block';
var printButton = document.getElementById('printButton');
printButton.style.display = 'none';
var backButton = document.getElementById('backButton');
backButton.style.display = 'none';
var div = document.getElementById('o');
div.innerHTML = '';
// Show copyright
var coffee = document.createElement('script');
coffee.setAttribute('data-message', '');
coffee.setAttribute('data-color', '#40DCA5');
coffee.setAttribute('data-position', 'Right');
coffee.setAttribute('data-x_margin', '18');
coffee.setAttribute('data-y_margin', '18');
document.body.appendChild(coffee);
var copyright = document.getElementById('uiCopyright');
copyright.style.display = 'block';
// Enable the input box
var input = document.getElementById('tokenInput');
input.disabled = false;
}
function printBarcodes() {
// Show the barcodes and hide buttons before printing
var printButton = document.getElementById('printButton');
printButton.style.display = 'none';
var backButton = document.getElementById('backButton');
backButton.style.display = 'none';
var div = document.getElementById('o');
// Open a new window with the content to print
var printWindow = window.open('', '_blank');
printWindow.document.write('<html><head><title>Print</title></head><body>' + div.innerHTML + '</body></html>');
printWindow.document.close();
// Wait for the content to load before triggering print
printWindow.onload = function() {
var result = printWindow.print();
if (!result) {
// If print is canceled or failed, restore button visibility
printButton.style.display = 'block';
backButton.style.display = 'block';
}
printWindow.onafterprint = function() {
// Restore button visibility after printing
printButton.style.display = 'block';
backButton.style.display = 'block';
printWindow.close();
};
};
}
// Function to get the current year
function getCurrentYear() {
return new Date().getFullYear();
}
// Function to update the copyright year
function updateCopyrightYear() {
document.getElementById('copyrightYear').textContent = getCurrentYear();
}
// Call the function to update the copyright year
updateCopyrightYear();
function handlePaste(event) {
// Handle pasted content
var clipboardData, pastedData;
event.stopPropagation();
event.preventDefault();
clipboardData = event.clipboardData || window.clipboardData;
pastedData = clipboardData.getData('Text');
// Split the pasted data into an array of numbers
var numbers = pastedData.split(/[,\s]+/);
// Add each number to the list
numbers.forEach(function (number) {
if (/^\d+$/.test(number)) {
// Add the number to the list
addNumberToList(number);
}
});
}
function addNumberToList(number) {
var tokenList = document.getElementById('tokenList');
var listItem = document.createElement('div');
listItem.className = 'token-list-item';
var tokenSpan = document.createElement('span');
tokenSpan.textContent = number;
listItem.appendChild(tokenSpan);
var deleteButton = document.createElement('button');
deleteButton.className = 'delete-button';
deleteButton.textContent = 'Delete';
deleteButton.onclick = function () {
listItem.remove();
};
listItem.appendChild(deleteButton);
tokenList.appendChild(listItem);
// Scroll to the bottom of the list
tokenList.scrollTop = tokenList.scrollHeight;
}
</script>
<div id="animated-bg"></div>
</body>
</html>