Mercurial > hg > fapweb
diff show.php @ 1065:511147c1e119
Move some of the show.php javascript code to show.js.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 24 Jan 2017 13:13:48 +0200 |
parents | f188caaedf0f |
children | 5f92fa5e683a |
line wrap: on
line diff
--- a/show.php Thu Nov 17 14:20:00 2016 +0200 +++ b/show.php Tue Jan 24 13:13:48 2017 +0200 @@ -17,8 +17,6 @@ stCommonAJAX("showajax.php", "show.php"); ?> -<!-- ========================== --> - <noscript> <div class="notice"> <h1>Javascript required</h1> @@ -32,108 +30,7 @@ <div class="showView" id="mainView"></div> -<!-- ========================== --> - -<script type="text/javascript"> - -var failCount = 0; -var lastUpdate = 0; -var errorView = false; - - -function updateView(txt) -{ - var view = document.getElementById("mainView"); - if (view && txt != false && txt != "") - view.innerHTML = txt; -} - - -function displayError() -{ - // Increase failure count - if (++failCount >= 3 && !errorView) - { - errorView = true; - updateView("<div class=\"slideHeader\"><div class=\"slideHeaderDiv\"></div></div><div class=\"slideText\"><div class=\"guru\">Software Failure. Press left mouse button to continue.<br />Guru Meditation #00000004.0000AAC0</div></div>"); - } -} - - -// -// Update view when triggered by main tick -// -function viewChanged() -{ - var msuccess2 = function(txt) - { - // Successfully fetched new data, initiate view update - updateView(txt); - } - - var msuccess1 = function(txt) - { - lastUpdate = txt; - jsSendPOSTRequest("action=get&type=slide", msuccess2, displayError); - } - - jsSendPOSTRequest("action=get&type=update", 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(); - if (!timeOutSet) - { - setTimeout("tickMain();", 250); - timeOutSet = true; - } - } - else - if (txt == "reload") - { - location.reload(); - } - else - { - if (!timeOutSet) - { - setTimeout("tickMain();", 500); - timeOutSet = true; - } - } - } - - var mfail = function(txt) - { - displayError(); - if (!timeOutSet) - { - setTimeout("tickMain();", 5000); - timeOutSet = true; - } - } - - jsSendPOSTRequest("action=check&lastUpdate="+lastUpdate, msuccess, mfail); -} - -setTimeout("tickMain();", 100); -viewChanged(); - -</script> +<script type="text/javascript" src="show.js"></script> <? cmPrintPageFooter(FALSE); ?> \ No newline at end of file