system-bus-radio/docs/airgap.js

28 lines
800 B
JavaScript
Raw Normal View History

2016-11-27 06:51:16 +01:00
var player; // Define "player" var to make my code linter happy
2016-03-04 18:41:03 +01:00
2016-11-27 06:51:16 +01:00
function start() { // Start Web Worker & send song data to player
2017-11-12 02:16:54 +01:00
var logs = document.getElementById('progress'); // Define log element
window.logs = logs; // Make variable Global
window.logs.value = "";
2016-03-04 18:41:03 +01:00
2016-11-27 06:51:16 +01:00
// Create Web Worker if it doesn't already exist
if (window.Worker && typeof(player) == "undefined") {
var player = new Worker("worker.js");
window.player = player; // Make variable Global
player.onmessage = function(event) {
var data = event.data;
2017-11-12 02:16:54 +01:00
console.log(data)
window.logs.value += "x\n";
};
2016-03-04 18:41:03 +01:00
2016-11-27 06:51:16 +01:00
// Send song data to player
2017-11-12 02:16:54 +01:00
var song = document.getElementById("tune").innerHTML;
player.postMessage(song);
}
2016-03-04 18:41:03 +01:00
}
2016-11-27 06:51:16 +01:00
function end() { // Stops the Web Worker
2017-11-12 02:16:54 +01:00
window.logs.value = "";
player.terminate();
2016-03-04 18:41:03 +01:00
}