Mercurial > hg > fapweb
changeset 1066:2d7d5940ec47
Merged.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 24 Jan 2017 15:49:54 +0200 |
parents | 755c1acae3f3 (current diff) 511147c1e119 (diff) |
children | 50d005dd22d8 |
files | |
diffstat | 2 files changed, 103 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/show.js Tue Jan 24 15:49:54 2017 +0200 @@ -0,0 +1,102 @@ +// +// FAPWeb - Simple Web-based Demoparty Management System +// Party main screen viewer +// (C) Copyright 2012-2017 Tecnic Software productions (TNSP) +// + +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();
--- a/show.php Sat Nov 19 03:31:10 2016 +0200 +++ b/show.php Tue Jan 24 15:49:54 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