pi-rfid-jukebox/static/jukebox.js
Annika Backstrom e25670d426 websocket-powered tag history in browser
also upgrade from jade 1.11 to pug 2 (project changed names due to
copyright issues)
2017-03-26 01:45:57 +00:00

20 lines
536 B
JavaScript

window.onload = function() {
console.log('window.onload');
var play_log = document.getElementById('play-log');
var last_tag = document.getElementById('last_tag');
function updateLog(data) {
last_tag.innerHTML = data.tag;
play_log.innerHTML = data.html;
}
var host = window.document.location.host.replace(/:.*/, '');
var ws = new WebSocket('ws://' + host + ':80');
ws.onmessage = function (event) {
console.log(event.data);
updateLog(JSON.parse(event.data));
};
};