-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
495 lines (444 loc) · 18.9 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
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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
<!DOCTYPE html>
<html lang="en">
<head>
<!-- <script data-ad-client="ca-pub-5290227775393401" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> -->
<meta charset="UTF-8">
<meta name="darkreader" content="someUIDhere">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="description" content="A big countdown timer for keeping an eye on when the steam deck is releasing" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>YOU DONT HAVE JAVASCRIPT</title>
<!-- Handled by js for single page goodness -->
<!-- <link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,"> -->
<style>
/* css might be broken during the multipage move */
/* general styling */
:root {
--smaller: .75;
--vw: 200%;
--vh: 200%;
}
* {
/* box-sizing: border-box; */
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
margin: 0;
}
body {
text-shadow: 6px 6px 15px black;
/* background-color: #6A5DF8; */
}
/* This is now the background for your body above
As such some of the styling elements have made their way over to here */
section.gradient {
align-items: center;
display: flex;
font-family: -apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen-Sans,
Ubuntu,
Cantarell,
"Helvetica Neue",
sans-serif;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(137.42deg, #1a75ff, #6a5df8, #c957e6, #d2486b, #bf44ac, #ab47d0, #9460f3, #46aced, #4ec4a3, #b8ba05, #d2486b);
background-size: 2200% 2200%;
-webkit-animation: DeckGradient 60s ease infinite;
-moz-animation: DeckGradient 60s ease infinite;
animation: DeckGradient 60s ease infinite;
}
@-webkit-keyframes DeckGradient {
0%{background-position:0% 50%}
50%{background-position:100% 50%}
100%{background-position:0% 50%}
}
@-moz-keyframes DeckGradient {
0%{background-position:0% 50%}
50%{background-position:100% 50%}
100%{background-position:0% 50%}
}
@keyframes DeckGradient {
0%{background-position:0% 50%}
50%{background-position:100% 50%}
100%{background-position:0% 50%}
}
section.gradient.inverted p,
section.gradient.inverted li {
color: #FFFFFF;
}
/* This animation is simply rotating the gradient above, whilst sliding the image over and zooming in slightly.
This gives the effect that the colours are shifting rather than just sliding across the screen or rotating..
Nothing major, just a subtle effect! */
/* @keyframes gradient {
0% {
transform: rotate(0deg) translateX(-25%) scale(2);
}
50% {
transform: rotate(360deg) translateX(100%) scale(3);
}
100% {
transform: rotate(720deg) translateX(-25%) scale(2);
}
} */
.container {
color: rgb(255, 255, 255);
margin: 0 auto;
text-align: center;
}
h1 {
font-weight: normal;
letter-spacing: .125rem;
text-transform: uppercase;
}
li {
display: inline-block;
font-size: 1.5em;
list-style-type: none;
padding: 1em;
text-transform: uppercase;
}
li span {
display: block;
font-size: 4.5rem;
}
.emoji {
display: none;
padding: 1rem;
}
.emoji span {
font-size: 4rem;
padding: 0 .5rem;
}
@media all and (max-width: 768px) {
h1 {
font-size: calc(1.5rem * var(--smaller));
}
li {
font-size: calc(1.125rem * var(--smaller));
}
li span {
font-size: calc(3.375rem * var(--smaller));
}
}
.corners {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: whitesmoke;
/* font-size: 160%; */
padding: 15px;
position: absolute;
}
#visits {
max-width: 90%;
bottom: 0px;
right: 0px;
text-align: right;
}
@media only screen and (max-device-width: 490px) {
#visits {
bottom: 40px;
}
}
#marketing {
bottom: 0px;
left: 0px;
max-width: 60%;
}
#credits {
top: 0px;
right: 0px;
text-align: right;
}
#selfpromo {
top: 0px;
left: 0px;
}
a {
color: #c4dcfd;
}
#bag {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
}
#credits-wholepage {
/* Center vertically and horizontally */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: max-content;
text-align: center;
color: whitesmoke;
}
</style>
</head>
<body>
<script>
function fillMain(goback) {
console.log("Filling Main");
// Fill Default HTML
f = `
<section class="inverted gradient home" id="handson">
<div id="visits" class="corners">Loading fun data...</div>
<div id="credits" class="corners">
<a href="[pathcalloutcred]" onclick="setTimeout(() => { defaultLoad(); }, 50);">
Credits
</a>
</div>
<div id="selfpromo" class="corners">
My
<a href="https://github.com/PeterHindes/steam-deck-countdown.live" target="_blank" rel="noopener noreferrer"> Code on Github</a>
<br> and
<a href="https://www.youtube.com/channel/UCNfYqDetbEI3rVREc5MhUmg" target="_blank" rel="noopener noreferrer">
YouTube
</a>
</div>
<div id="marketing" class="corners">
<a href="https://amzn.to/34bB4kj" target="_blank" rel="noopener noreferrer">Get a TypeC Charging <br> Dongle for your Deck</a>
</div>
<div class="container">
<h1 id="headline"></h1>
<div id="countdown">
<ul>
<li><span id="days"></span>days</li>
<li><span id="hours"></span>Hours</li>
<li><span id="minutes"></span>Minutes</li>
<li><span id="seconds"></span>Seconds</li>
</ul>
</div>
<div id="content" class="emoji">
<span>🕹️</span>
<span>👾</span>
<span>🎮</span>
</div>
<a href="https://store.steampowered.com/steamdeck/" target="_blank" rel="noopener noreferrer">
<h1>Reserve Your Spot In Line Here</h1>
</a>
<a href="[pathcalloutembargo]" onclick="setTimeout(() => { defaultLoad(); }, 50);">
<h1>And See How Long Until The Reviews Release</h1>
</a>
</div>
</section>
`.replace("[pathcalloutcred]", window.location.pathname + "#credits");
if (goback) {
f = f.replace("[pathcalloutembargo]", window.location.pathname) // Racecondition with the onclick
f = f.replace("And See How Long Untill The Previews Release", "Go Back To The Main Page")
} else {
f = f.replace("[pathcalloutembargo]", window.location.pathname + "#embargo")
}
document.body.innerHTML = f;
}
function fillCreds() {
console.log("Filling Creds");
// Fill Credits HTML (and maybe css)
document.body.innerHTML = `
<div id="bag">
<section class="inverted gradient home" id="handson">
<div id="credits-wholepage" class="corners">
<h1>Credits</h1>
<br>
<a href="https://codepen.io/AllThingsSmitty/pen/JJavZN" target="_blank" rel="noopener noreferrer">
Thanks to Matt Smith
</a>
on codepen,
<br>
<a href="https://countapi.xyz/" target="_blank" rel="noopener noreferrer">
CountAPI
</a>, and
<br>
<a href="https://stackoverflow.com/a/5568484" target="_blank" rel="noopener noreferrer">
Marcel
</a>
and
<a href="https://stackoverflow.com/a/35197259">
maowtm
</a>
from Stack Overflow
</div>
</section>
</div>
`;
}
let interv = "unset";
function defaultLoad() {
console.log("DefLoad");
console.log(window.location.href);
if (window.location.href.includes("credits")) {
clearInterval(interv);
fillCreds();
document.title = "Credits"
} else if (window.location.href.includes("embargo")) { // Embargo
fillMain(true);
countdownPage('Feb 7 2022 10:00:00 PST', "PREVIEWS OF THE STEAM DECK WILL RELEASE IN", "Preview Embargo Lifted\nGo check out the early previews!"); // Not sure
// update, this is the early preview date // polygon says embargo on release day, but reddit says embargo on 7th
document.title = "Days To Steam Deck Early Release Coverage"
} else { // Real launch
fillMain(false);
countdownPage('Feb 25 2022 10:00:00 PST', "THE STEAM DECK WILL RELEASE IN", "The Steam Deck is Right Out Now!\n Get One If You Can!");
document.title = "Days To Steam Deck Release"
}
function countdownPage(date, countHeadline, releaseMsg) {
// Thanks to Matt Smith on CodePen, https://codepen.io/AllThingsSmitty/pen/JJavZN
(function () {
const second = 1000,
minute = second * 60,
hour = minute * 60,
day = hour * 24;
let today = new Date(),
dd = String(today.getDate()).padStart(2, "0"),
mm = String(today.getMonth() + 1).padStart(2, "0"),
// yyyy = today.getFullYear(),
yyyy = "2022",
// nextYear = yyyy + 1,
//dayMonth = "02/25/", // February 25, 2022
birthday = date; // Idk probably local time relative? Update it is, checked it with this great calculator https://www.timeanddate.com/date/timezoneduration.html
//today = new Date('Feb 28 2013 19:00:00 EST')
today = mm + "/" + dd + "/" + yyyy; // Should be local time
// if (today > birthday) {
// birthday = dayMonth + nextYear;
// }
//end
const countDown = new Date(birthday).getTime()
clearInterval(interv);
console.log(interv);
document.getElementById("headline").innerText = countHeadline;
interv = setInterval(function () {
const now = new Date().getTime(),
distance = countDown - now;
document.getElementById("days").innerText = Math.floor(distance / (day)),
document.getElementById("hours").innerText = Math.floor((distance % (day)) / (hour)),
document.getElementById("minutes").innerText = Math.floor((distance % (hour)) / (minute)),
document.getElementById("seconds").innerText = Math.floor((distance % (minute)) / second);
//do something later when date is reached
if (distance < 0) {
document.getElementById("headline").innerText = releaseMsg;
document.getElementById("countdown").style.display = "none";
document.getElementById("content").style.display = "block";
clearInterval(x);
}
//seconds
}, 0)
}());
// Count api in a function
// Thanks https://www.sohamkamani.com/blog/javascript-localstorage-with-ttl-expiry/
function setWithExpiry(key, value, timeoutEnabled) {
//const now = new Date()
var d = new Date();
d.setUTCHours(24, 0, 0, 0); // next midnight
// `item` is an object which contains the original value
// as well as the time when it's supposed to expire
let item
if (timeoutEnabled) {
item = {
value: value,
expiry: d.getTime(), // Thanks https://stackoverflow.com/a/15790005 //now.getTime() + ttl,
}
} else {
item = {
value: value,
expiry: "No", // Thanks https://stackoverflow.com/a/15790005 //now.getTime() + ttl,
}
}
localStorage.setItem(key, JSON.stringify(item))
}
function getWithExpiry(key) {
const itemStr = localStorage.getItem(key)
// if the item doesn't exist, return null
if (!itemStr) {
return null
}
const item = JSON.parse(itemStr)
const now = new Date()
// compare the expiry time of the item with the current time
if (now.getTime() > item.expiry && item.expiry != "No") {
// If the item is expired, delete the item from storage
// and return null
localStorage.removeItem(key)
return null
}
return item.value
}
function counterInit(codeName, noSpam, timeOutAfterMidnight, htmlPreOnLoad, htmlPostOnload) {
var xhr = new XMLHttpRequest();
let modeName = "hit";
// Cookies (not really, now we use local storage), the europeans will be scared, but they are not for tracking
if (noSpam) {
let herebefore = getWithExpiry(codeName) == "yes";
if (herebefore) {
modeName = "get";
} else {
setWithExpiry(codeName ? codeName : "@root", "yes", timeOutAfterMidnight)
}
}
//console.log(herebefore);
console.log(modeName);
xhr.open("GET", "https://api.countapi.xyz/" + modeName + "/steam-deck-countdown.live" + (codeName ? "-" : "") + codeName + "/visits");
xhr.responseType = "json";
xhr.onload = function () { //Warning Race Condition! Its fixed now
document.getElementById("visits").innerHTML = document.getElementById("visits").innerHTML.replace(/Loading fun data\.\.\./g, "")
document.getElementById("visits").innerHTML = document.getElementById("visits").innerHTML + htmlPreOnLoad + this.response.value + htmlPostOnload
}
xhr.send();
}
counterInit("", false, false, "<br>Loaded ", " times! <a href=\"https://www.reddit.com/r/SteamDeck/comments/sgsq3x/i_made_with_a_countdown_for_the_steam_deck_since/\">The hype is real!</a>")
counterInit("uniq", true, false, "<br>", " unique visits since 1/31/22 at 6am!")
counterInit("todayuniq", true, true, "<br>", " unique visits since midnight!")
}
}
defaultLoad()
function pageKeeper() {
let lastCheck = window.location.href;
let guard = setInterval(() => {
if (lastCheck != window.location.href) { // Page changed behind my back
console.log("Page Change Detected");
console.log(window.location.href)
defaultLoad();
lastCheck = window.location.href;
}
}, 0);
}
pageKeeper();
</script>
<!-- ads
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5290227775393401"
crossorigin="anonymous"></script> -->
<!-- Bottom Of Page -->
<!-- <ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-5290227775393401"
data-ad-slot="7096253206"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
window.onresize = function(event)
{
let root = document.documentElement;
root.style.setProperty('--vw', window.outerWidth + "vmin");
root.style.setProperty('--vh', window.outerHeight + "vmin");
}
</script> -->
<script>
{
let root = document.documentElement;
root.style.setProperty('--vw', window.outerWidth + "vmin");
root.style.setProperty('--vh', window.outerHeight + "vmin");
}
</script>
</body>
</html>