Mercurial > hg > fapweb
diff show.js @ 1067:82ecea33c477
Various cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 24 Jan 2017 16:43:58 +0200 |
parents | 511147c1e119 |
children |
line wrap: on
line diff
--- a/show.js Tue Jan 24 13:13:48 2017 +0200 +++ b/show.js Tue Jan 24 16:43:58 2017 +0200 @@ -49,11 +49,19 @@ } +function setTickUpdate(qtime) +{ + if (!timeOutSet) + { + timeOutSet = true; + setTimeout(function() { tickMain(); }, qtime); + } +} + + // // Main tick function, check for updates from server // -var timeOutSet = false; - function tickMain() { timeOutSet = false; @@ -64,11 +72,7 @@ if (txt == "changed") { viewChanged(); - if (!timeOutSet) - { - setTimeout("tickMain();", 250); - timeOutSet = true; - } + setTickUpdate(250); } else if (txt == "reload") @@ -77,26 +81,19 @@ } else { - if (!timeOutSet) - { - setTimeout("tickMain();", 500); - timeOutSet = true; - } + setTickUpdate(500); } } var mfail = function(txt) { displayError(); - if (!timeOutSet) - { - setTimeout("tickMain();", 5000); - timeOutSet = true; - } + setTickUpdate(5000); } jsSendPOSTRequest("action=check&lastUpdate="+lastUpdate, msuccess, mfail); } -setTimeout("tickMain();", 100); +var timeOutSet = false; +setTickUpdate(100); viewChanged();