3 let clock_running = false;
4 let clock_visible = false;
5 let comment_visible = false;
6 let lowerthird_visible = false;
8 let clock_limit = 30 * 60;
16 document.getElementById('team1').innerHTML = state['team1'];
17 document.getElementById('team2').innerHTML = state['team2'];
19 let sheets = { 'A': state['team1'], 'B': state['team2'] };
25 document.getElementById('team1color').style.backgroundColor = state['team1color'];
26 document.getElementById('team2color').style.backgroundColor = state['team2color'];
31 scoreA = state['score1'];
32 scoreB = state['score2'];
39 clock_origin = Date.now();
47 if (!clock_running) return;
48 clock_elapsed = time_elapsed();
49 clock_origin = Date.now();
50 clock_running = false;
53 function setclock(amount)
55 clock_elapsed = amount;
56 clock_origin = Date.now();
60 function setclockfromstate()
62 let amount = parseInt(state['clock_min']) * 60 + parseInt(state['clock_sec']);
68 if (clock_visible) return;
69 let clockbug = document.getElementById('clockbug');
70 clockbug.className = 'clockbug clockbug-animate-in';
76 if (!clock_visible) return;
77 let clockbug = document.getElementById('clockbug');
78 clockbug.className = 'clockbug clockbug-animate-out';
79 clock_visible = false;
84 document.getElementById('comment').innerHTML = state['comment'];
87 function showcomment()
89 if (comment_visible) return;
90 let commentbug = document.getElementById('commentbug');
91 commentbug.className = 'commentbug commentbug-animate-in';
92 comment_visible = true;
95 function hidecomment()
97 if (!comment_visible) return;
98 let commentbug = document.getElementById('commentbug');
99 commentbug.className = 'commentbug commentbug-animate-out';
100 comment_visible = false;
103 function showlowerthird()
105 if (lowerthird_visible) return;
107 // With no flexbox, this is how it has to be...
108 let f = document.getElementById('lowerthird-headline');
109 let g = document.getElementById('lowerthird-headline-content');
110 f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px';
112 f = document.getElementById('lowerthird-subheading');
113 g = document.getElementById('lowerthird-subheading-content');
114 f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px';
116 f = document.getElementById('lowerthird-picture');
117 g = document.getElementById('lowerthird-picture-content');
118 f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px';
120 document.getElementById('lowerthird-headline').className = 'lowerthird-headline lowerthird-headline-animate-in';
121 document.getElementById('lowerthird-headline-content').className = 'lowerthird-headline-content lowerthird-headline-content-animate-in';
122 document.getElementById('lowerthird-subheading').className = 'lowerthird-subheading lowerthird-subheading-animate-in';
123 document.getElementById('lowerthird-subheading-content').className = 'lowerthird-subheading-content lowerthird-subheading-content-animate-in';
124 document.getElementById('lowerthird-picture').className = 'lowerthird-picture lowerthird-picture-animate-in';
125 document.getElementById('lowerthird-picture-content').className = 'lowerthird-picture-content lowerthird-picture-content-animate-in';
126 lowerthird_visible = true;
129 function setandshowlowerthird()
131 document.getElementById('lowerthird-headline-content').innerHTML = state['text1'];
132 document.getElementById('lowerthird-subheading-content').innerHTML = state['text2'];
133 let img = document.getElementById('lowerthird-img');
134 if (state['image'] === undefined) {
135 img.style.display = 'none';
137 img.src = state['image'];
138 img.style.display = 'inline';
143 function hidelowerthird()
145 if (!lowerthird_visible) return;
146 document.getElementById('lowerthird-headline').className = 'lowerthird-headline lowerthird-headline-hidden lowerthird-headline-animate-out';
147 document.getElementById('lowerthird-headline-content').className = 'lowerthird-headline-content lowerthird-headline-content-animate-out';
148 document.getElementById('lowerthird-subheading').className = 'lowerthird-subheading lowerthird-subheading-animate-out';
149 document.getElementById('lowerthird-subheading-content').className = 'lowerthird-subheading-content lowerthird-subheading-content-animate-out';
150 document.getElementById('lowerthird-picture').className = 'lowerthird-picture lowerthird-picture-hidden lowerthird-picture-animate-out';
151 document.getElementById('lowerthird-picture-content').className = 'lowerthird-picture-content lowerthird-picture-content-animate-out';
152 lowerthird_visible = false;
155 function time_elapsed()
157 let elapsed = (Date.now() - clock_origin) * 1e-3;
158 if (clock_elapsed + elapsed >= clock_limit) {
159 clock_elapsed = clock_limit;
160 clock_origin = Date.now();
161 clock_running = false;
164 return Math.floor(clock_elapsed + elapsed);
167 function update_clock()
169 let elapsed = time_elapsed();
170 let min = Math.floor(elapsed / 60);
171 let sec = elapsed % 60;
173 if (sec < 10) sec = "0" + sec;
174 document.getElementById('clock').innerHTML = min + ":" + sec;
191 if (scoreA > 0) --scoreA;
197 if (scoreB > 0) --scoreB;
201 function resetscore()
207 function update_score()
209 document.getElementById('score').innerHTML = scoreA + " – " + scoreB;
212 /* called by caspar only */
215 document.getElementById('manualcontrols').style.display = 'none';
216 document.getElementById('area').style.display = 'none';
218 // Old CEF workaround
219 document.getElementById('lowerthird-subheading').style.top = '638px';
224 console.log('[[[' + v + ']]]');
225 let j = JSON.parse(v);
226 for(let key in j) state[key] = j[key];
229 setInterval(function() {