rt-sim-training-client/static/workertest/trainworker.js

33 lines
424 B
JavaScript
Raw Normal View History

var i=0;
var update = null
function timedCount(){
onmessage = (e) => {
// console.log(e.data);
if(e.data.type){
for(let i=e.data.body.length-1;i>=0;i--){
postMessage(e.data.body[i]);
}
}
if(e.data == "on"){
update = setInterval("uptrain()", 50);
}
if(e.data == "off"){
clearInterval(update);
}
}
}
function uptrain(){
postMessage(i);
}
timedCount();