X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=kiosk.py;h=6003165a674e1f2ed76f18f8ffe8812f7c67b6e5;hb=37b72e72c59140c4a6f7f541c716e4b0bc254b08;hp=0c8cce09f3a6b0bc92a636ada326cee71eb27cf7;hpb=f2f05b2edb16cc6a8c4e183e5ae3451d291cc428;p=kiosk.git diff --git a/kiosk.py b/kiosk.py index 0c8cce0..6003165 100755 --- a/kiosk.py +++ b/kiosk.py @@ -172,30 +172,46 @@ def emit_wrapped(f, filename): return new Promise(resolve => setTimeout(resolve, milliseconds)) } - var loaded = false; var loadedDate = new Date(); addLoadEvent(zoomScreen); addLoadEvent(runClock); addLoadEvent(lateLoadImages); - addLoadEvent(function() { - loaded = true; - }); - // Reload the page after a certain amount of time has passed or - // immediately if told to do so. - (function poll() { + // Runs the countdown line at the bottom and is responsible for + // normal page reloads caused by the expiration of a timer. + (function countdown() { setTimeout( function() { var now = new Date(); var deltaMs = now.getTime() - loadedDate.getTime(); + var totalMs = %d; + var remainingMs = (totalMs - deltaMs); - // Reload unconditionally after 22 sec. - if (deltaMs > %d) { + if (remainingMs > 0) { + var hr = document.getElementById("countdown"); + var width = (remainingMs / (totalMs - 5000)) * 100.0; + if (width <= 100) { + hr.style.visibility = "visible"; + hr.style.width = " ".concat(width, "%%"); + hr.style.backgroundColor = "maroon"; + } + } else { + // Reload unconditionally after 22 sec. window.location.reload(); } - // Reload immediately if told. + // Brief sleep before doing it all over again. + sleep(50).then(() => { + countdown(); + }); + }, 50) + })(); + + // Periodically checks for emergency reload events. + (function poll() { + setTimeout( + function() { var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://wannabe.house/kiosk/pages/reload_immediately.html'); @@ -238,6 +254,14 @@ def emit_wrapped(f, filename):

%s @ %s ago.

+