site-progress-bar/content/display.md

41 lines
1.3 KiB
Markdown

---
title: Display Page
description: This is a page that displays a progress bar
---
<script>
function addJS(name, type) {
var node=document.createElement('script');
node.setAttribute('type', type || 'text/javascript');
node.setAttribute('src', name);
document.head.appendChild(node);
}
function addCSS(name) {
var node=document.createElement('link');
node.setAttribute('rel', 'stylesheet');
node.setAttribute('type', 'text/css');
node.setAttribute('href', name);
document.head.appendChild(node);
}
var stylesheet = Array.from(document.getElementsByTagName('link')).filter(x=>x.getAttribute('rel')=='stylesheet')[0];
stylesheet.parentElement.removeChild(stylesheet);
function eraseCanvas() {
for (var headNode of Array.from(document.head.getElementsByTagName('script')))
document.head.removeChild(headNode);
for (var childNode of Array.from(document.body.childNodes))
document.body.removeChild(childNode);
document.body.removeAttribute('class')
}
var nextStyle = document.createElement('style');
nextStyle.setAttribute('id', 'nextStyle');
document.head.appendChild(nextStyle);
setTimeout(()=>{
eraseCanvas();
addCSS('/css/display.css');
addJS('/js/sprintf.min.js');
addJS('/js/sharedWebSocket.js');
addJS('/js/countup.mjs', 'module');
addJS('/js/display.js');
}, 10);
</script>