X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=score.js;h=1d28e4cf2308015377b98626ea629003bb7e3b4c;hb=3c3a5c028bed3922840a2b5ad7ab861fca092582;hp=deae9d8ad9824a4da5c7e7e514daaeb1049e193f;hpb=06af07af77abe93004a384298edbc19178c1068e;p=ultimatescore diff --git a/score.js b/score.js index deae9d8..1d28e4c 100644 --- a/score.js +++ b/score.js @@ -110,19 +110,6 @@ function showlowerthird() { if (lowerthird_visible) return; - // With no flexbox, this is how it has to be... - let f = document.getElementById('lowerthird-headline'); - let g = document.getElementById('lowerthird-headline-content'); - f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px'; - - f = document.getElementById('lowerthird-subheading'); - g = document.getElementById('lowerthird-subheading-content'); - f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px'; - - f = document.getElementById('lowerthird-picture'); - g = document.getElementById('lowerthird-picture-content'); - f.style.paddingTop = Math.round((f.clientHeight - g.clientHeight) / 2) + 'px'; - document.getElementById('lowerthird-headline').className = 'lowerthird-headline lowerthird-headline-animate-in'; document.getElementById('lowerthird-headline-content').className = 'lowerthird-headline-content lowerthird-headline-content-animate-in'; document.getElementById('lowerthird-subheading').className = 'lowerthird-subheading lowerthird-subheading-animate-in'; @@ -153,7 +140,7 @@ function hidelowerthird() document.getElementById('lowerthird-headline-content').className = 'lowerthird-headline-content lowerthird-headline-content-animate-out'; document.getElementById('lowerthird-subheading').className = 'lowerthird-subheading lowerthird-subheading-animate-out'; document.getElementById('lowerthird-subheading-content').className = 'lowerthird-subheading-content lowerthird-subheading-content-animate-out'; - document.getElementById('lowerthird-picture').className = 'lowerthird-picture lowerthird-picture-hidden lowerthird-picture-animate-out'; + document.getElementById('lowerthird-picture').className = 'lowerthird-picture lowerthird-picture-animate-out'; document.getElementById('lowerthird-picture-content').className = 'lowerthird-picture-content lowerthird-picture-content-animate-out'; lowerthird_visible = false; } @@ -220,9 +207,6 @@ function play() { document.getElementById('manualcontrols').style.display = 'none'; document.getElementById('area').style.display = 'none'; - - // Old CEF workaround - document.getElementById('lowerthird-subheading').style.top = '638px'; } function update(v) @@ -241,3 +225,40 @@ update_score(); //play(); //startclock(); + +let websocket = null; + +function open_ws() +{ + console.log("Connecting..."); + try { + if (websocket) + websocket.close(); + websocket = new WebSocket("ws://127.0.0.1:5250/"); + websocket.onopen = function(evt) { + console.log("Connected to client."); + }; + websocket.onclose = function(evt) { + console.log("Disconnected from client."); + setTimeout(open_ws, 100); + }; + websocket.onmessage = function(evt) { + let msg = evt.data; + let m = msg.match(/^update (.*)/); + if (m !== null) { + update(m[1]); + } + m = msg.match(/^eval (.*)/); + if (m !== null) { + eval(m[1]); + } + }; + websocket.onerror = function(evt) { + console.log('Error: ' + evt.data); + }; + } catch (exception) { + console.log('Error: ' + exception); + setTimeout(open_ws, 100); + } +}; +open_ws();