Mercurial > hg > fapweb
diff show.php @ 144:c030c3cf0d80
More work on display system.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 23 Oct 2013 01:42:21 +0300 |
parents | d2e9285b69ad |
children | 66b485431cac |
line wrap: on
line diff
--- a/show.php Wed Oct 23 01:21:12 2013 +0300 +++ b/show.php Wed Oct 23 01:42:21 2013 +0300 @@ -37,6 +37,7 @@ var failCount = 0; var prevView = -1, activeView = 0; +var activeSlide = -1, activeSlideMode = -1; var errorView = false; @@ -77,47 +78,72 @@ // function viewChanged() { - var msuccess = function(txt) + var msuccess3 = function(txt) { // Successfully fetched new data, initiate view update - failCount = 0; - errorView = false; updateView(txt); } - sendPOSTRequest("action=get", msuccess, displayError); + var msuccess2 = function(txt) + { + activeSlide = txt; + sendPOSTRequest("action=get&type=slide", msuccess3, displayError); + } + + var msuccess1 = function(txt) + { + activeSlideMode = txt; + sendPOSTRequest("action=get&type=activeSlide", msuccess2, displayError); + } + + sendPOSTRequest("action=get&type=activeSlideMode", msuccess1, displayError); } // // Main tick function, check for updates from server // +var timeOutSet = false; + function tickMain() { + timeOutSet = false; + var msuccess = function(txt) { failCount = 0; if (txt == "changed") { viewChanged(); - setTimeout("tickMain();", 500); + if (!timeOutSet) + { + setTimeout("tickMain();", 500); + timeOutSet = true; + } } else { - setTimeout("tickMain();", 2000); + if (!timeOutSet) + { + setTimeout("tickMain();", 2000); + timeOutSet = true; + } } } var mfail = function(txt) { displayError(); - setTimeout("tickMain();", 5000); + if (!timeOutSet) + { + setTimeout("tickMain();", 5000); + timeOutSet = true; + } } - sendPOSTRequest("action=check", msuccess, mfail); + sendPOSTRequest("action=check&activeSlide="+activeSlide+"&activeSlideMode="+activeSlideMode, msuccess, mfail); } - setTimeout("tickMain();", 1000); setInterval("tickAnim();", 25); viewChanged();