annotate show.js @ 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
children 82ecea33c477
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1065
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 //
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 // FAPWeb - Simple Web-based Demoparty Management System
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 // Party main screen viewer
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 // (C) Copyright 2012-2017 Tecnic Software productions (TNSP)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 //
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 var failCount = 0;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 var lastUpdate = 0;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 var errorView = false;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 function updateView(txt)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 var view = document.getElementById("mainView");
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 if (view && txt != false && txt != "")
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 view.innerHTML = txt;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 function displayError()
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 // Increase failure count
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 if (++failCount >= 3 && !errorView)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 errorView = true;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 updateView("<div class=\"slideHeader\"><div class=\"slideHeaderDiv\"></div></div><div class=\"slideText\"><div class=\"guru\">Software Failure.&nbsp;&nbsp;&nbsp;Press left mouse button to continue.<br />Guru Meditation #00000004.0000AAC0</div></div>");
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 //
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 // Update view when triggered by main tick
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 //
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 function viewChanged()
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 var msuccess2 = function(txt)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 // Successfully fetched new data, initiate view update
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 updateView(txt);
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 var msuccess1 = function(txt)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 lastUpdate = txt;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 jsSendPOSTRequest("action=get&type=slide", msuccess2, displayError);
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 jsSendPOSTRequest("action=get&type=update", msuccess1, displayError);
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 //
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 // Main tick function, check for updates from server
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 //
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 var timeOutSet = false;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 function tickMain()
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 timeOutSet = false;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 var msuccess = function(txt)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 failCount = 0;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 if (txt == "changed")
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 viewChanged();
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 if (!timeOutSet)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 setTimeout("tickMain();", 250);
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 timeOutSet = true;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 else
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 if (txt == "reload")
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 location.reload();
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 else
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 if (!timeOutSet)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 setTimeout("tickMain();", 500);
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 timeOutSet = true;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 var mfail = function(txt)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 displayError();
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 if (!timeOutSet)
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 {
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 setTimeout("tickMain();", 5000);
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 timeOutSet = true;
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 jsSendPOSTRequest("action=check&lastUpdate="+lastUpdate, msuccess, mfail);
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 }
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 setTimeout("tickMain();", 100);
511147c1e119 Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 viewChanged();