pi-rfid-jukebox/static/jukebox.js

19 lines
516 B
JavaScript
Raw Normal View History

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(/:.*/, '');
2017-04-08 16:05:39 +00:00
var ws = new WebSocket('ws://' + host + ':' + jukebox.port);
ws.onmessage = function (event) {
updateLog(JSON.parse(event.data));
};
};