1 var clock_running = false;
2 var clock_visible = false;
3 var comment_visible = false;
4 var lowerthird_visible = false;
5 var clock_left = 25 * 60;
13 document.getElementById('team1').innerHTML = state['team1'];
14 document.getElementById('team2').innerHTML = state['team2'];
19 document.getElementById('team1color').style.backgroundColor = state['team1color'];
20 document.getElementById('team2color').style.backgroundColor = state['team2color'];
25 scoreA = state['score1'];
26 scoreB = state['score2'];
33 clock_origin = Date.now();
41 if (!clock_running) return;
42 clock_left = time_left();
43 clock_origin = Date.now();
44 clock_running = false;
47 function setclock(amount)
50 clock_origin = Date.now();
54 function setclockfromstate()
56 var amount = parseInt(state['clock_min']) * 60 + parseInt(state['clock_sec']);
62 if (clock_visible) return;
63 var clockbug = document.getElementById('clockbug');
64 clockbug.className = 'clockbug clockbug-animate-in';
70 if (!clock_visible) return;
71 var clockbug = document.getElementById('clockbug');
72 clockbug.className = 'clockbug clockbug-animate-out';
73 clock_visible = false;
78 document.getElementById('comment').innerHTML = state['comment'];
81 function showcomment()
83 if (comment_visible) return;
84 var commentbug = document.getElementById('commentbug');
85 commentbug.className = 'commentbug commentbug-animate-in';
86 comment_visible = true;
89 function hidecomment()
91 if (!comment_visible) return;
92 var commentbug = document.getElementById('commentbug');
93 commentbug.className = 'commentbug commentbug-animate-out';
94 comment_visible = false;
97 function showlowerthird()
99 if (lowerthird_visible) return;
101 // With no flexbox, this is how it has to be...
102 var f = document.getElementById('lowerthird-headline');
103 var g = document.getElementById('lowerthird-headline-content');
104 f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px';
106 f = document.getElementById('lowerthird-subheading');
107 g = document.getElementById('lowerthird-subheading-content');
108 f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px';
110 document.getElementById('lowerthird-headline').className = 'lowerthird-headline lowerthird-headline-animate-in';
111 document.getElementById('lowerthird-headline-content').className = 'lowerthird-headline-content lowerthird-headline-content-animate-in';
112 document.getElementById('lowerthird-subheading').className = 'lowerthird-subheading lowerthird-subheading-animate-in';
113 document.getElementById('lowerthird-subheading-content').className = 'lowerthird-subheading-content lowerthird-subheading-content-animate-in';
114 lowerthird_visible = true;
117 function setandshowlowerthird()
119 document.getElementById('lowerthird-headline-content').innerHTML = state['text1'];
120 document.getElementById('lowerthird-subheading-content').innerHTML = state['text2'];
124 function hidelowerthird()
126 if (!lowerthird_visible) return;
127 document.getElementById('lowerthird-headline').className = 'lowerthird-headline lowerthird-headline-hidden lowerthird-headline-animate-out';
128 document.getElementById('lowerthird-headline-content').className = 'lowerthird-headline-content lowerthird-headline-content-animate-out';
129 document.getElementById('lowerthird-subheading').className = 'lowerthird-subheading lowerthird-subheading-animate-out';
130 document.getElementById('lowerthird-subheading-content').className = 'lowerthird-subheading-content lowerthird-subheading-content-animate-out';
131 lowerthird_visible = false;
136 var elapsed = (Date.now() - clock_origin) * 1e-3;
137 if (elapsed > clock_left) return 0;
138 return Math.ceil(clock_left - elapsed);
141 function update_clock()
143 var left = time_left();
144 var min = Math.floor(left / 60);
147 if (sec < 10) sec = "0" + sec;
148 document.getElementById('clock').innerHTML = min + ":" + sec;
165 if (scoreA > 0) --scoreA;
171 if (scoreB > 0) --scoreB;
175 function resetscore()
181 function update_score()
183 document.getElementById('score').innerHTML = scoreA + " – " + scoreB;
186 /* called by caspar only */
189 document.getElementById('manualcontrols').style.display = 'none';
190 document.getElementById('area').style.display = 'none';
192 // Old CEF workaround
193 document.getElementById('lowerthird-subheading').style.top = '638px';
198 console.log('[[[' + v + ']]]');
199 var j = JSON.parse(v);
200 for(var key in j) state[key] = j[key];
203 setInterval(function() {