Mercurial > hg > fapweb
comparison show.js @ 1067:82ecea33c477
Various cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 24 Jan 2017 16:43:58 +0200 |
parents | 511147c1e119 |
children |
comparison
equal
deleted
inserted
replaced
1065:511147c1e119 | 1067:82ecea33c477 |
---|---|
47 | 47 |
48 jsSendPOSTRequest("action=get&type=update", msuccess1, displayError); | 48 jsSendPOSTRequest("action=get&type=update", msuccess1, displayError); |
49 } | 49 } |
50 | 50 |
51 | 51 |
52 function setTickUpdate(qtime) | |
53 { | |
54 if (!timeOutSet) | |
55 { | |
56 timeOutSet = true; | |
57 setTimeout(function() { tickMain(); }, qtime); | |
58 } | |
59 } | |
60 | |
61 | |
52 // | 62 // |
53 // Main tick function, check for updates from server | 63 // Main tick function, check for updates from server |
54 // | 64 // |
55 var timeOutSet = false; | |
56 | |
57 function tickMain() | 65 function tickMain() |
58 { | 66 { |
59 timeOutSet = false; | 67 timeOutSet = false; |
60 | 68 |
61 var msuccess = function(txt) | 69 var msuccess = function(txt) |
62 { | 70 { |
63 failCount = 0; | 71 failCount = 0; |
64 if (txt == "changed") | 72 if (txt == "changed") |
65 { | 73 { |
66 viewChanged(); | 74 viewChanged(); |
67 if (!timeOutSet) | 75 setTickUpdate(250); |
68 { | |
69 setTimeout("tickMain();", 250); | |
70 timeOutSet = true; | |
71 } | |
72 } | 76 } |
73 else | 77 else |
74 if (txt == "reload") | 78 if (txt == "reload") |
75 { | 79 { |
76 location.reload(); | 80 location.reload(); |
77 } | 81 } |
78 else | 82 else |
79 { | 83 { |
80 if (!timeOutSet) | 84 setTickUpdate(500); |
81 { | |
82 setTimeout("tickMain();", 500); | |
83 timeOutSet = true; | |
84 } | |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 var mfail = function(txt) | 88 var mfail = function(txt) |
89 { | 89 { |
90 displayError(); | 90 displayError(); |
91 if (!timeOutSet) | 91 setTickUpdate(5000); |
92 { | |
93 setTimeout("tickMain();", 5000); | |
94 timeOutSet = true; | |
95 } | |
96 } | 92 } |
97 | 93 |
98 jsSendPOSTRequest("action=check&lastUpdate="+lastUpdate, msuccess, mfail); | 94 jsSendPOSTRequest("action=check&lastUpdate="+lastUpdate, msuccess, mfail); |
99 } | 95 } |
100 | 96 |
101 setTimeout("tickMain();", 100); | 97 var timeOutSet = false; |
98 setTickUpdate(100); | |
102 viewChanged(); | 99 viewChanged(); |