2020-11-12 14:59:40 +08:00
|
|
|
var i=0;
|
|
|
|
var update = null;
|
|
|
|
function timedCount(){
|
|
|
|
|
|
|
|
onmessage = (e) => {
|
|
|
|
|
|
|
|
|
|
|
|
if(e.data[0] == "on"){
|
2020-11-13 09:36:14 +08:00
|
|
|
update = "1";
|
2020-11-12 14:59:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if(e.data[0] == "off"){
|
|
|
|
clearInterval(update);
|
|
|
|
}
|
|
|
|
if(e.data[0] == "changespeed"){
|
|
|
|
if(update){
|
|
|
|
clearInterval(update);
|
2020-11-13 09:36:14 +08:00
|
|
|
if(e.data[1] == 0){
|
|
|
|
|
|
|
|
}else{
|
|
|
|
let speed = 900/e.data[1];
|
|
|
|
update = setInterval("stationupdate()", speed);
|
|
|
|
}
|
|
|
|
|
2020-11-12 14:59:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
function stationupdate(){
|
|
|
|
|
|
|
|
postMessage("up");
|
|
|
|
}
|
|
|
|
|
|
|
|
timedCount();
|