rt-sim-training-client/static/workertest/trainworker.js
sunzhenyu 7d98ea5f18 pull
2019-10-17 18:49:19 +08:00

32 lines
396 B
JavaScript

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();