Skip to content

Instantly share code, notes, and snippets.

@vicariousdrama
Created March 14, 2023 15:59
Show Gist options
  • Save vicariousdrama/5ca7d945d7af07dcb44e60f5bb9af7c9 to your computer and use it in GitHub Desktop.
Save vicariousdrama/5ca7d945d7af07dcb44e60f5bb9af7c9 to your computer and use it in GitHub Desktop.
Kiosk Website Cycler
<!DOCTYPE html><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Vicarious Drama Kiosker</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body, html {
margin: 0;
height: 100%;
}
iframe {
display: block;
background: #000;
border: none;
height: 100vh;
width: 100vw;
}
.dframe {overflow:hidden;height:100%;width:100%;}
</style>
<script language="javascript">
var timeouts = [];
activedframe = '';
function clearTimeouts() {
for (var i=0; i<timeouts.length; i++) {
clearTimeout(timeouts[i]);
}
}
function rotateDisplay() {
var da = document.querySelectorAll(".dframe");
timeout = 5000;
l = da.length;
if (l == 0) {
alert('did not get matches for selector');
return;
}
// find active
var ai = -1;
for (var idx=0; idx<l; idx++) {
cs = da[idx].getAttribute('src');
if (cs.indexOf(activedframe) > -1) {
ai = idx;
break;
}
}
// increment
ai = ai + 1
// wrap as needed
if (ai >= l) {
ai = 0;
}
// capture new activedframe
activedframe = da[ai].getAttribute('src');
// toggle display
for (var idx=0; idx<l; idx++) {
if (ai != idx) {
da[idx].style.display = 'none';
} else {
da[idx].style.display = 'block';
}
}
clearTimeouts();
timeouts.push(setTimeout(function() {rotateDisplay();}, timeout));
}
function addIFrames() {
fs = [
'https://bits.monospace.live/',
'https://timechaincalendar.com/',
'https://sat-cent.vercel.app/',
'https://coin360.com/',
'https://bitbo.io/',
]
/* the following blocks due to headers
'https://bitcoin.clarkmoody.com/dashboard/',
'https://mempool.space/',
'https://bisq.markets/',
*/
var b = document.getElementsByTagName('body')[0];
for (var fi=0; fi<fs.length; fi ++) {
f = document.createElement('iframe');
f.src = fs[fi];
f.setAttribute('src', fs[fi]);
f.className = 'dframe';
f.style.borderWidth = 0;
f.setAttribute('frameborder',0);
f.setAttribute('allowfullscreen', true);
f.setAttribute('class', 'dframe');
b.appendChild(f);
}
}
window.addEventListener('load',addIFrames);
window.addEventListener('load',rotateDisplay);
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment