pi-rfid-jukebox/static/jukebox.js

20 lines
536 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(/:.*/, '');
var ws = new WebSocket('ws://' + host + ':80');
ws.onmessage = function (event) {
console.log(event.data);
updateLog(JSON.parse(event.data));
};
};