问题:detectLocationtimersset()逻辑似乎不工作。我知道子例程被解雇,但我猜如果其他人错了?HTML5 Javascript嵌套如果其他工作没有按预期工作
detectLocationtimersset()的原因是有一些逻辑来确保没有设置多个定时器。
我创建了第一个if/else来根据datatime设置定时器,然后我写了第二个if/else来进行检测。
detectLocation()已经过测试并在其自身的工作。
var detectLocationtimerset = 0;
var datatime = 1;
function detectLocationtimersset() {
// Setup timer to check for new data start
// check and see if set
if (detectLocationtimerset = 0) {
detectLocationtimerset = 1;
if (datatime == null) {
datatime = 9;
milliseconds = (datatime * 60000)
setInterval(function() {
detectLocation();
console.log("detectLocation() timer set");
}, milliseconds);
} else {
detectLocationtimerset = 1;
milliseconds = (datatime * 60000)
setInterval(function() {
detectLocation();
console.log("detectLocation() timer set");
}, milliseconds);
}
}
};
这是什么,你不指望? –