diff --git a/wwwroot/index.html b/wwwroot/index.html index bfb0817..6304722 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -18,7 +18,7 @@ - + diff --git a/wwwroot/js/csharp.js b/wwwroot/js/csharp.js deleted file mode 100644 index d18fc90..0000000 --- a/wwwroot/js/csharp.js +++ /dev/null @@ -1,47 +0,0 @@ -window.injectCSharp = async function (helper) { - window.CSHARP = helper -} - - -async function delay(t) { - return new Promise((resolve) => { - setTimeout(resolve, t); - }); -} - -async function removeElementById(id) { - document.getElementById(id)?.remove() -} - -function scrollToId(id) { - const element = document.getElementById(id); - if (element instanceof HTMLElement) { - element.scrollIntoView({ - behavior: "smooth", - block: "start", - inline: "nearest" - }); - } -} - -function toggleDetails(id) { - const element = document.getElementById(id) - if (element instanceof HTMLDetailsElement) - element.open = !element.open -} - -function cacheBust(url) { - fetch(new Request(url), { - headers: new Headers({ - "pragma": "no-cache", - "cache-control": "no-cache" - }), - mode: 'no-cors', - cache: 'no-cache', - }) - .finally(() => { - let els = document.querySelectorAll(`[src="${url}"]`) - els.forEach(el => el.removeAttribute('src')) - els.forEach(el => el.src = url) - }) -} \ No newline at end of file diff --git a/wwwroot/js/script.js b/wwwroot/js/script.js new file mode 100644 index 0000000..5351165 --- /dev/null +++ b/wwwroot/js/script.js @@ -0,0 +1,32 @@ +window.injectCSharp = async function (helper) { window.CSHARP = helper } + +async function delay(t) { return new Promise((resolve) => { setTimeout(resolve, t) }) } + +async function removeElementById(id) { document.getElementById(id)?.remove() } + +function scrollToId(id) { + const element = document.getElementById(id) + if (element instanceof HTMLElement) + element.scrollIntoView({behavior: "smooth",block: "start",inline: "nearest"}) +} + +function toggleDetails(id) { + const element = document.getElementById(id) + if (element instanceof HTMLDetailsElement) element.open = !element.open +} + +function cacheBust(url) { + fetch(new Request(url), { + headers: new Headers({ + "pragma": "no-cache", + "cache-control": "no-cache" + }), + mode: 'no-cors', + cache: 'no-cache', + }) + .finally(() => { + let els = document.querySelectorAll(`[src="${url}"]`) + els.forEach(el => el.removeAttribute('src')) + els.forEach(el => el.src = url) + }) +} \ No newline at end of file