-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFezClockTowerSim.html
578 lines (547 loc) · 19.9 KB
/
FezClockTowerSim.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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="author" content="Jenna Sloan">
<title>FEZ Clock Tower Simulator</title>
<link rel="manifest" href='data:application/javascript,{
"name": "FEZ Clock Tower Simulator",
"short_name": "FEZ Clock Tower Sim",
"start_url": "https://jenna1337.github.io/FezTools/FezClockTowerSim.html",
"display": "standalone",
"description": "FEZ Clock Tower Simulator",
"icons": [
{
"src": "data:image/png;base64,TODO/InsertClockIconHere",
"sizes": "64x64",
"type": "image/png",
"purpose": "any",
"orientation": "any"
}
]
}' />
<!--Note: some browsers (including Safari for iOS) don't like the following favicon for whatever reason-->
<link rel="icon" type="image/x-icon" href="data:image/x-icon;base64,TODO/InsertClockIconHere" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="color-scheme" content="dark light" />
<style>
:root {
--clock-face-fill-opacity: 0.05;
}
body {
font-family: monospace;
padding: 0;
margin: 0;
}
noscript {
position: absolute;
z-index: 9999999;
color: white;
background-color: black;
height: 100vh;
width: 100vw;
font-size: min(100vh, calc(100vw / 30));
line-height: 100vh;
text-align: center;
}
#clockcontainer {
display: flex;
gap: 0px;
max-width: min(100em, 200vh);
/*max-height: 50vh;*/
}
svg {
height: auto;
width: min(100%, 50vh);
aspect-ratio: 1 / 1;
/*max-height: 256px;*/
/*max-width: 256px;*/
--color: attr(data-color);
}
.handinfo{
display: block;
}
.handinfoname{
outline: 1px solid var(--color);
background-color: color-mix(in srgb, transparent 100%, var(--color) var(--clock-face-fill-opacity)%);
padding-inline: 0.5ex;
}
span[data-valid]{
text-decoration: underline;
text-decoration-style: solid;
text-decoration-line: underline;
}
span[data-valid="true"]{
background-color: #0F02;
text-decoration-color: #0F0D;
/*doesn't work in Safari*/
/*text-decoration: underline #0F0D;*/
}
span[data-valid="false"]{
background-color: #F002;
text-decoration-color: #F00D;
}
#interactive-area {
padding-inline: 1ex;
}
#interactive-area > * {
margin-block: 1ex;
}
/* Media Queries for responsiveness */
@media (max-width: 60vh) {
#clockcontainer {
display: grid;
grid-template-columns: repeat(2, 1fr); /* 2 squares per row */
}
}
@media (max-width: 13vh) {
#clockcontainer {
display: grid;
grid-template-columns: 1fr; /* 1 square per row */
}
}
</style>
<script>
Element.prototype.appendStuff = function(...stuff){
stuff.forEach(c=>{
if(c instanceof Node){
this.appendChild(c);
}
else if((typeof c).toLowerCase()=="string")
{
this.insertAdjacentHTML("beforeend", c);
}
else
{
this.append(c);
debugger
}
})
}
</script>
<script id="clockscript">
let actualstarttime = Date.now();
Object.defineProperty(window, 'starttime', {
get: function() {
return actualstarttime;
},
set: function(value) {
actualstarttime = Number(value);
const elem = document.getElementById("starttimeinput");
elem.value = value;
elem.onchange();
document.querySelectorAll("[data-nextstamp]").forEach(a=>a.removeAttribute("data-nextstamp"));
document.querySelectorAll("[data-nextstampend]").forEach(a=>a.removeAttribute("data-nextstampend"));
}
});
let actualoffsettime = 0;
Object.defineProperty(window, 'offsettime', {
get: function() {
return actualoffsettime;
},
set: function(value) {
actualoffsettime = Number(value);
const elem = document.getElementById("offetfromsysteminput");
elem.value = value;
elem.onchange();
document.querySelectorAll("[data-nextstamp]").forEach(a=>a.removeAttribute("data-nextstamp"));
document.querySelectorAll("[data-nextstampend]").forEach(a=>a.removeAttribute("data-nextstampend"));
}
});
function resetStartTime(){
starttime = Date.now();
}
document.addEventListener("DOMContentLoaded",function(){
starttime = Date.now();
offsettime = 0;
const handinfobox = document.getElementById("handinfobox");
const clock_inner_template = document.getElementById("clock_inner_template");
const clock_inner_template_elems = Array.from(clock_inner_template.children);
const template_clockvalidarea = document.getElementById("clockvalidarea");
const template_clockhand = document.getElementById("clockhand");
const template_clockhandback = document.getElementById("clockhandback");
const handstuff = [];
document.querySelectorAll(".clock").forEach(clock=>{
const titletext = clock.getAttribute("title") || clock.getAttribute("alt") || clock.getAttribute("aria-label") || clock.dataset.name;
if(!clock.hasAttribute("title")){
clock.setAttribute("title", titletext);
}
if(!clock.hasAttribute("alt")){
clock.setAttribute("alt", titletext);
}
if(!clock.hasAttribute("aria-label")){
clock.setAttribute("aria-label", titletext);
}
//if(!Array.prototype.find.call(clock.children, a=>a.tagName.toLowerCase()=="title")){
if(!clock.querySelector(":scope>title")){
const titleelem = document.createElementNS("http://www.w3.org/2000/svg", "title");
titleelem.textContent = titletext;
clock.appendChild(titleelem);
}
clock_inner_template_elems.forEach(elem=>clock.appendChild(elem.cloneNode(true)));
const handback = template_clockhandback.cloneNode();
handback.removeAttribute("id");
clock.insertBefore(handback, clock.lastElementChild);
const hand = template_clockhand.cloneNode();
hand.removeAttribute("id");
clock.insertBefore(hand, clock.lastElementChild);
const validarea = template_clockvalidarea.cloneNode();
validarea.removeAttribute("id");
clock.insertBefore(validarea, clock.lastElementChild);
const handinfoname = document.createElement("span");
handinfoname.classList.add("handinfoname");
handinfoname.textContent = clock.dataset.name;
const handinfovalid = document.createElement("span");
handinfovalid.textContent = "false";
const handinfonextvalid = document.createElement("span");
handinfonextvalid.classList.add("timestamp");
handinfonextvalid.textContent = "000";
const handinfonextinvalid = document.createElement("span");
handinfonextinvalid.classList.add("timestamp");
handinfonextinvalid.textContent = "000";
const colorval = window.getComputedStyle(clock).getPropertyValue("--color");
const handinfo = document.createElement("p");
handinfo.style.setProperty("--color", colorval)
handinfo.appendStuff(
handinfoname,
" hand is valid? ",
handinfovalid,
". Will next be <span data-valid=\"true\">valid</span> at about: ",
handinfonextvalid,
". Will next be <span data-valid=\"false\">invalid</span> at about: ",
handinfonextinvalid,
);
handinfo.classList.add("handinfo");
handinfo.ariaRelevant="text";
handinfo.ariaAtomic="true";
handinfo.ariaRole="status";
handinfobox.appendChild(handinfo);
handstuff.push([clock, handback, hand, handinfovalid, handinfonextvalid, handinfonextinvalid, validarea]);
});
function getXY(cx, cy, radius, theta){
return [cx + radius*Math.cos(theta),
cy + radius*Math.sin(theta)];
}
function createWedge(cx, cy, radius, validThetaStart, validThetaEnd) {
const [sx,sy] = getXY(cx, cy, radius, validThetaStart);
const [ex,ey] = getXY(cx, cy, radius, validThetaEnd);
const largeArcFlag = Math.abs(validThetaEnd - validThetaStart)>Math.PI ? 1 : 0;
return `M${cx},${cy}L${sx},${sy}A${radius},${radius} 0 ${largeArcFlag} 1 ${ex},${ey}z`;
}
function setHandLine(cx, cy, hand, radius, theta){
hand.setAttribute("x1", cx+"px");
hand.setAttribute("y1", cy+"px");
const [x2,y2] = getXY(cx, cy, radius, theta);
hand.setAttribute("x2", x2 +"px");
hand.setAttribute("y2", y2 +"px");
//hand.setAttribute("data-angle", (theta+Math.PI)%(2*Math.PI));
}
function moveHand(handmeta, currtime){
const [clock, handback, hand, handinfovalid, handinfonextvalid, handinfonextinvalid, validarea] = handmeta;
const radius = Number(window.getComputedStyle(clock).getPropertyValue("--radius").replace("px",""));
//const radius = 48;
const clockbox = clock.viewBox.animVal;
const cx = (clockbox.x + clockbox.width)/2;
const cy = (clockbox.y + clockbox.height)/2;
const val = currtime - starttime;
const valmod = Number(clock.dataset.scale);
const theta = ((val) / valmod) * (2 * Math.PI) - (Math.PI);
//adjust the hands
{
const handstyle = window.getComputedStyle(hand);
const handstrokewidth = Number(handstyle.strokeWidth.replace("px",""));
const handlinecap = handstyle.strokeLinecap;
const radiusadjust = (handlinecap=="butt" || handlinecap=="") ? 0 : handstrokewidth;
setHandLine(cx, cy, hand, radius-radiusadjust, theta, val);
setHandLine(cx, cy, handback, radius-radiusadjust, theta, val);
}
const validThetaLeeway = Number(clock.dataset.validThetaLeeway);
const validThetaStart = Number(clock.dataset.validThetaStart ?? ((Math.PI/2)-validThetaLeeway));
const validThetaEnd = Number(clock.dataset.validThetaEnd ?? ((Math.PI/2)+validThetaLeeway));
//update validity information
{
let thetaAdjusted = (theta - Math.PI)%(2*Math.PI);
while(thetaAdjusted<0){
thetaAdjusted += (2*Math.PI);
}
validarea.setAttribute("d", createWedge(cx, cy, radius, validThetaStart + Math.PI, validThetaEnd + Math.PI));
const inTheZone = thetaAdjusted >= validThetaStart && thetaAdjusted <= validThetaEnd;
if(String(handinfovalid.dataset.valid) != String(inTheZone) || String(clock.dataset.valid) != String(inTheZone)){
clock.dataset.valid = inTheZone;
handinfovalid.dataset.valid = inTheZone;
handinfovalid.textContent = inTheZone;
}
}
//check the next valid timestamps
{
const startOffset = valmod*(Math.PI/2-validThetaStart)/(Math.PI*2);
const endOffset = valmod*(Math.PI/2-validThetaEnd)/(Math.PI*2);
//const curval = (val+.75*valmod)%valmod;
//hand.setAttribute("data-value", curval);
let stampchanged = !hand.dataset.nextstamp;
let stampchangedend = !hand.dataset.nextstampend;
let nextstamp = Number(hand.dataset.nextstamp ?? (starttime+.25*valmod - startOffset));
let nextstampend = Number(hand.dataset.nextstampend ?? (starttime+.25*valmod - endOffset));
while(nextstamp<currtime){
nextstamp += valmod;
stampchanged = true;
}
while(nextstampend<currtime){
nextstampend += valmod;
}
hand.setAttribute("data-nextstamp", nextstamp);
hand.setAttribute("data-nextstampend", nextstampend);
if(stampchanged){
formatTimeLabel(handinfonextvalid, new Date(nextstamp));
}
if(stampchanged){
formatTimeLabel(handinfonextinvalid, new Date(nextstampend));
}
}
}
function moveHands(timestamp){
const currtime = Date.now() + offsettime;
formatTimeLabel(document.getElementById("currtime"), new Date(currtime));
//Note: using promises here is slower due to overhead
handstuff.forEach(handmeta=>{
moveHand(handmeta, currtime);
});
window.requestAnimationFrame(moveHands);
}
window.requestAnimationFrame(moveHands);
});
</script>
</head>
<body>
<div id="clockcontainer" style="--hand-width: 4px; --radius: 48px; --core-size: 8px;" aria-live="off">
<svg style="/*display: none !important;*/ height: 0; width: 0; overflow: hidden;" hidden="hidden" aria-hidden="true" focusable="false">
<style><![CDATA[
#clockfacebackgroundrect {
stroke-width: 4px;
fill-opacity: var(--clock-face-fill-opacity);
fill: var(--color);
stroke: var(--color);
}
.centered-in-clock {
width: var(--core-size);
height: var(--core-size);
transform: translate(-50%, -50%);
transform-box: fill-box;
stroke-linejoin: miter;
stroke-miterlimit: 1;
stroke-linejoin: bevel;
}
.clockhand{
stroke-width: var(--hand-width);
stroke: var(--color);
stroke-linecap: square;
}
.clockhandback{
stroke-width: calc(var(--hand-width) + 2px);
stroke: color-mix(in srgb, var(--color), white 20%);
stroke-linecap: square;
}
.clockvalidarea{
stroke: none;
fill-opacity: 0.05;
fill: black;
fill: currentColor;
}
]]></style>
<defs>
<!-- use these with the <use> element -->
<g id="clockface">
<rect id="clockfacebackgroundrect" x="0" y="0" width="100%" height="100%" />
</g>
<rect id="clockcorebase" class="centered-in-clock" x="50%" y="50%" stroke-width="2" />
<g id="clockcore">
<use href="#clockcorebase" fill="#525" />
<use href="#clockcorebase" fill="none" stroke="#101" />
</g>
<!-- Note: These elements are templates to be cloned and animated with JavaScript -->
<line id="clockhandback" class="clockhand clockhandback" />
<line id="clockhand" class="clockhand" />
<path id="clockvalidarea" class="clockvalidarea" />
<g id="clock_inner_template" >
<use href="#clockface" ></use>
<use href="#clockcore" ></use>
</g>
</defs>
</svg>
<svg class="clock" viewbox="0 0 100 100" style="--color:red" data-name="Minute clock (Red)" data-scale="60000" data-valid-theta-start="1.19579637" data-valid-theta-end="1.69579637" role="img"></svg>
<svg class="clock" viewbox="0 0 100 100" style="--color:#0A0" data-name="Hour clock (Green)" data-scale="3600000" data-valid-theta-leeway="0.125" role="img"></svg>
<svg class="clock" viewbox="0 0 100 100" style="--color:blue" data-name="Day clock (Blue)" data-scale="86400000" data-valid-theta-leeway="0.125" role="img"></svg>
<svg class="clock" viewbox="0 0 100 100" style="--color:#888" data-name="Week clock (White)" data-scale="604800000" data-valid-theta-leeway="0.125" role="img"></svg>
</div>
<div id="interactive-area">
<script>
var timeformat = window.localStorage?.timeformat ?? "Locale_time_string";
window.setTimeout(()=>{
//set selected item on timeformatselector to whatever matched window.localStorage.timeformat
const timeformatselector = document.getElementById("timeformatselector");
timeformatselector.value = window.localStorage?.timeformat ?? "Locale_time_string";
timeformatselector.onchange();
}, 1000);
function formatTimeLabel(timelabel, dt){
var ofst = dt.getTimezoneOffset();
timelabel.dataset['local_time'] = dt.toString();
timelabel.dataset['Locale_time_string'] = dt.toLocaleString();//doesn't display fractions of seconds
timelabel.dataset['ISO_8601_-_UTC'] = dt.toISOString();
timelabel.dataset['ISO_8601_-_local_time_zone'] = (new Date(dt - ofst * 60 * 1000)).toISOString().replace('Z',(-Math.sign(ofst) < 0 ? '-' : '+')+String(Math.abs(ofst/60*100)).padStart(4,'0').split(/(?=..$)/).join(':'));
timelabel.dataset['Unix_timestamp_-_seconds_since_epoch'] = Math.floor(dt.getTime()/1000);
timelabel.dataset['Unix_timestamp_-_milliseconds_since_epoch'] = dt.getTime();
timelabel.textContent = timelabel.dataset[timeformat];
}
var doneloading = false;
var hashbrowns = ({});
function updateHashbrowns(inputelem){
if(doneloading){
hashbrowns[inputelem.id] = inputelem.value;
setHashbrownsObject(hashbrowns);
}
}
function loadHashbrowns(){
var arrhashbrowns = getHashbrowns();
var elemmeta = [];
arrhashbrowns.forEach(a=>{
var elem = document.getElementById(a[0]);
if(elem){
elem.value = a[1];
hashbrowns[a[0]] = a[1];
}else{
delete arrhashbrowns[a[0]];
}
});
doneloading = true;
}
window.addEventListener("load", loadHashbrowns);
document.addEventListener("load", loadHashbrowns);
function timeformatselectorchanged(formatselector){
timeformat = formatselector.value;
window.localStorage.timeformat = timeformat;
//force refresh all timestamps
document.querySelectorAll("[data-nextstamp]").forEach(a=>a.removeAttribute("data-nextstamp"));
document.querySelectorAll("[data-nextstampend]").forEach(a=>a.removeAttribute("data-nextstampend"));
document.querySelectorAll("input[type=\"number\"]").forEach(a=>a.onchange(a));
updateHashbrowns(formatselector);
}
function timeinput_change(timeinput, valcallback, updatelabel=true){
if(timeinput.dataset.changing != "changing"){
timeinput.dataset.changing = "changing";
const t= Number(timeinput.value);
valcallback(t);
if(updatelabel){
const timelabel = document.querySelector(".timelabel[for=\""+timeinput.id+"\"]");
if(timelabel){
var dt = new Date(t);
formatTimeLabel(timelabel, dt);
}
}
updateHashbrowns(timeinput);
}
timeinput.dataset.changing = "";
}
function creationtimeinput_change(timeinput){
timeinput_change(timeinput, dt=>starttime=dt);
}
function offetfromsysteminput_change(timeinput){
timeinput_change(timeinput, dt=>offsettime=dt, false);
}
const hash_sep_kv = "=";
const hash_sep_entries = "&";
function getHashbrowns(){
var h = window.location.hash;
if(h.startsWith("#")){
h = h.slice(1);
}
return h.split(hash_sep_entries).filter(c=>c.length>0).map(a=>a.split(hash_sep_kv));
}
function setHashbrownsObject(hashbrowns){
window.location.hash = Object.entries(hashbrowns).map(a=>a.join(hash_sep_kv)).join(hash_sep_entries)
}
</script>
<label for="timeformatselector">Display times in the format:</label>
<select id="timeformatselector" onchange="timeformatselectorchanged(this)">
<option value="local_time">local time</option>
<option value="ISO_8601_-_UTC">ISO 8601 - UTC</option>
<option value="ISO_8601_-_local_time_zone">ISO 8601 - local time zone</option>
<option value="Locale_time_string" selected="">Locale time string</option>
<option value="Unix_timestamp_-_seconds_since_epoch">Unix timestamp - seconds since epoch</option>
<option value="Unix_timestamp_-_milliseconds_since_epoch">Unix timestamp - milliseconds since epoch</option>
<!--
TODO use js to add choices from the keys mentioned for timelabel.dataset
to affect the outcome of the content set by formatTimeLabel
-->
</select><br />
<span for="currtime">Current time: </span>
<span class="timestamp" id="currtime" aria-live="off"></span><br />
<label for="starttimeinput">File start time: </label>
<input id="starttimeinput" type="number" min="0" step="1000" onchange="creationtimeinput_change(this)" />
<label for="starttimeinput" class="timestamp timelabel"></label>
<br />
<label for="offetfromsysteminput">Adjust current time: </label>
<input id="offetfromsysteminput" type="number" step="1000" onchange="offetfromsysteminput_change(this)" />
<label for="offetfromsysteminput" class="">milliseconds ahead</label>
<br />
<button onclick="resetStartTime()" type="button">Reset clocks to current time</button>
<br />
<div id="handinfobox" aria-live="polite">
</div>
<br />
<br />
<noscript>
This page requires JavaScript
</noscript>
<div id="viewsourcebox" style="max-width: 40ch">
This web app created by <span id="createdbyspan">Jenna Sloan</span>
Last Modified: <span id="lastmodifiedspan"></span>
<a id="viewsource" target="_blank" href="https://github.com/Jenna1337/FezTools/blob/main/FezClockTowerSim.html">
View Source
<span> on GitHub</span><span><svg role="presentation" style="display: inline-block; width: 1em; height: 1em; vertical-align: top; fill: currentcolor;" viewbox="0 0 48 48">
<path d="M36 24c-1.2 0-2 0.8-2 2v12c0 1.2-0.8 2-2 2h-22c-1.2
0-2-0.8-2-2v-22c0-1.2 0.8-2 2-2h12c1.2 0 2-0.8 2-2s-0.8-2-2-2h-12c-3.4
0-6 2.6-6 6v22c0 3.4 2.6 6 6 6h22c3.4 0 6-2.6
6-6v-12c0-1.2-0.8-2-2-2z"></path>
<path d="M43.8 5.2c-0.2-0.4-0.6-0.8-1-1-0.2-0.2-0.6-0.2-0.8-0.2h-12c-1.2
0-2 0.8-2 2s0.8 2 2 2h7.2l-18.6 18.6c-0.8 0.8-0.8 2 0 2.8 0.4 0.4 0.8
0.6 1.4 0.6s1-0.2 1.4-0.6l18.6-18.6v7.2c0 1.2 0.8 2 2 2s2-0.8
2-2v-12c0-0.2 0-0.6-0.2-0.8z"></path>
</svg></span>
</a>
</div>
</body>
<script>
document.addEventListener("DOMContentLoaded",function(){
try{
var lm = document.getElementById("lastmodifiedspan");
lm.textContent = (new Date(document.lastModified)).toISOString();
lm.after(document.createElement("br"));
}
catch(error){
console.error(error);
}
try{
var cb = document.getElementById("createdbyspan");
cb.textContent = Array.from(document.getElementsByTagName("meta"))
.filter(function(a){var n=a.getAttribute("name"); return n && n.toLowerCase()==="author";})
.map(a=>a.getAttribute("content"))
.join(", ");
cb.after(document.createElement("br"));
}
catch(error){
console.error(error);
}
});
function GetGithubSourceHref(){
let h=window.location.hostname.split(".");
let p=window.location.pathname.split("/").filter(a=>a.length>0);
return "https://"+h[1]+".com/"+h[0]+"/"+p[0]+"/blob/main/"+(p[1] ?? "index.html");
}
if(window.location.hostname){
let href = GetGithubSourceHref();
if(href){
document.getElementById("viewsource").href = href;
}
}
</script>
</html>