1 var clock_running = false;
2 var clock_visible = false;
3 var comment_visible = false;
4 var lowerthird_visible = false;
5 var clock_left = 30 * 60;
13 document.getElementById('team1').innerHTML = state['team1'];
14 document.getElementById('team2').innerHTML = state['team2'];
16 var sheets = { 'A': state['team1'], 'B': state['team2'] };
22 document.getElementById('team1color').style.backgroundColor = state['team1color'];
23 document.getElementById('team2color').style.backgroundColor = state['team2color'];
28 scoreA = state['score1'];
29 scoreB = state['score2'];
36 clock_origin = Date.now();
44 if (!clock_running) return;
45 clock_left = time_left();
46 clock_origin = Date.now();
47 clock_running = false;
50 function setclock(amount)
53 clock_origin = Date.now();
57 function setclockfromstate()
59 var amount = parseInt(state['clock_min']) * 60 + parseInt(state['clock_sec']);
65 if (clock_visible) return;
66 var clockbug = document.getElementById('clockbug');
67 clockbug.className = 'clockbug clockbug-animate-in';
73 if (!clock_visible) return;
74 var clockbug = document.getElementById('clockbug');
75 clockbug.className = 'clockbug clockbug-animate-out';
76 clock_visible = false;
81 document.getElementById('comment').innerHTML = state['comment'];
84 function showcomment()
86 if (comment_visible) return;
87 var commentbug = document.getElementById('commentbug');
88 commentbug.className = 'commentbug commentbug-animate-in';
89 comment_visible = true;
92 function hidecomment()
94 if (!comment_visible) return;
95 var commentbug = document.getElementById('commentbug');
96 commentbug.className = 'commentbug commentbug-animate-out';
97 comment_visible = false;
100 function showlowerthird()
102 if (lowerthird_visible) return;
104 // With no flexbox, this is how it has to be...
105 var f = document.getElementById('lowerthird-headline');
106 var g = document.getElementById('lowerthird-headline-content');
107 f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px';
109 f = document.getElementById('lowerthird-subheading');
110 g = document.getElementById('lowerthird-subheading-content');
111 f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px';
113 f = document.getElementById('lowerthird-picture');
114 g = document.getElementById('lowerthird-picture-content');
115 f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px';
117 document.getElementById('lowerthird-headline').className = 'lowerthird-headline lowerthird-headline-animate-in';
118 document.getElementById('lowerthird-headline-content').className = 'lowerthird-headline-content lowerthird-headline-content-animate-in';
119 document.getElementById('lowerthird-subheading').className = 'lowerthird-subheading lowerthird-subheading-animate-in';
120 document.getElementById('lowerthird-subheading-content').className = 'lowerthird-subheading-content lowerthird-subheading-content-animate-in';
121 document.getElementById('lowerthird-picture').className = 'lowerthird-picture lowerthird-picture-animate-in';
122 document.getElementById('lowerthird-picture-content').className = 'lowerthird-picture-content lowerthird-picture-content-animate-in';
123 lowerthird_visible = true;
126 function setandshowlowerthird()
128 document.getElementById('lowerthird-headline-content').innerHTML = state['text1'];
129 document.getElementById('lowerthird-subheading-content').innerHTML = state['text2'];
130 var img = document.getElementById('lowerthird-img');
131 if (state['image'] === undefined) {
132 img.style.display = 'none';
134 img.src = state['image'];
135 img.style.display = 'inline';
140 function hidelowerthird()
142 if (!lowerthird_visible) return;
143 document.getElementById('lowerthird-headline').className = 'lowerthird-headline lowerthird-headline-hidden lowerthird-headline-animate-out';
144 document.getElementById('lowerthird-headline-content').className = 'lowerthird-headline-content lowerthird-headline-content-animate-out';
145 document.getElementById('lowerthird-subheading').className = 'lowerthird-subheading lowerthird-subheading-animate-out';
146 document.getElementById('lowerthird-subheading-content').className = 'lowerthird-subheading-content lowerthird-subheading-content-animate-out';
147 document.getElementById('lowerthird-picture').className = 'lowerthird-picture lowerthird-picture-hidden lowerthird-picture-animate-out';
148 document.getElementById('lowerthird-picture-content').className = 'lowerthird-picture-content lowerthird-picture-content-animate-out';
149 lowerthird_visible = false;
154 var elapsed = (Date.now() - clock_origin) * 1e-3;
155 if (elapsed > clock_left) return 0;
156 return Math.ceil(clock_left - elapsed);
159 function update_clock()
161 var left = time_left();
162 var min = Math.floor(left / 60);
165 if (sec < 10) sec = "0" + sec;
166 document.getElementById('clock').innerHTML = min + ":" + sec;
183 if (scoreA > 0) --scoreA;
189 if (scoreB > 0) --scoreB;
193 function resetscore()
199 function update_score()
201 document.getElementById('score').innerHTML = scoreA + " – " + scoreB;
204 /* called by caspar only */
207 document.getElementById('manualcontrols').style.display = 'none';
208 document.getElementById('area').style.display = 'none';
210 // Old CEF workaround
211 document.getElementById('lowerthird-subheading').style.top = '638px';
216 console.log('[[[' + v + ']]]');
217 var j = JSON.parse(v);
218 for(var key in j) state[key] = j[key];
221 setInterval(function() {