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

32 lines
396 B
JavaScript
Raw Permalink Normal View History

var i=0;
var update = null
function timedCount(){
onmessage = (e) => {
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();