Mercurial > hg > fapweb
annotate show.js @ 1067:82ecea33c477
Various cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 24 Jan 2017 16:43:58 +0200 |
parents | 511147c1e119 |
children |
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. 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 |
1067 | 52 function setTickUpdate(qtime) |
53 { | |
54 if (!timeOutSet) | |
55 { | |
56 timeOutSet = true; | |
57 setTimeout(function() { tickMain(); }, qtime); | |
58 } | |
59 } | |
60 | |
61 | |
1065
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 // 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
|
64 // |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 function tickMain() |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 { |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 timeOutSet = false; |
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 var msuccess = function(txt) |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 { |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 failCount = 0; |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 if (txt == "changed") |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 { |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 viewChanged(); |
1067 | 75 setTickUpdate(250); |
1065
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 } |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 else |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 if (txt == "reload") |
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 location.reload(); |
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 else |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 { |
1067 | 84 setTickUpdate(500); |
1065
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(); |
1067 | 91 setTickUpdate(5000); |
1065
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 |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 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
|
95 } |
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 |
1067 | 97 var timeOutSet = false; |
98 setTickUpdate(100); | |
1065
511147c1e119
Move some of the show.php javascript code to show.js.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 viewChanged(); |