Don't clear timer when no timer has been initialized yet.
This commit is contained in:
parent
b8bc3a870f
commit
016502d300
1 changed files with 9 additions and 4 deletions
|
@ -8,7 +8,7 @@ com.telldus.scheduler = function() {
|
||||||
|
|
||||||
var storedJobs = new MappedList(); //all jobs, added by "addJob"
|
var storedJobs = new MappedList(); //all jobs, added by "addJob"
|
||||||
var joblist; //sorted list containing next run time (and id) for all storedJobs
|
var joblist; //sorted list containing next run time (and id) for all storedJobs
|
||||||
var timerid; //id of currently running timer, used when timer should be aborted
|
var timerid = null; //id of currently running timer, used when timer should be aborted
|
||||||
var queuedJob; //job currently in running timer, is already removed from joblist
|
var queuedJob; //job currently in running timer, is already removed from joblist
|
||||||
|
|
||||||
//TODO (perhaps) run something on the LAST day of the month?
|
//TODO (perhaps) run something on the LAST day of the month?
|
||||||
|
@ -108,8 +108,10 @@ com.telldus.scheduler = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function runNextJob(){
|
function runNextJob(){
|
||||||
clearTimeout(timerid);
|
if(timerid != null){
|
||||||
print("Timer interrupted");
|
clearTimeout(timerid);
|
||||||
|
print("Timer interrupted");
|
||||||
|
}
|
||||||
if(joblist.length <= 0){
|
if(joblist.length <= 0){
|
||||||
print("No jobs");
|
print("No jobs");
|
||||||
return; //no jobs, abort
|
return; //no jobs, abort
|
||||||
|
@ -139,6 +141,7 @@ com.telldus.scheduler = function() {
|
||||||
print("(Now is " + new Date() + ")");
|
print("(Now is " + new Date() + ")");
|
||||||
print("Delay: " + delay);
|
print("Delay: " + delay);
|
||||||
timerid = setTimeout(runJobFunc, delay); //start the timer
|
timerid = setTimeout(runJobFunc, delay); //start the timer
|
||||||
|
|
||||||
print("Has started a job wait");
|
print("Has started a job wait");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +186,9 @@ com.telldus.scheduler = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function JobDaylightSavingReload(){}
|
function JobDaylightSavingReload(){
|
||||||
|
this.v.name = "Daylight Saving Time job";
|
||||||
|
}
|
||||||
|
|
||||||
function setDaylightSavingJobFunctions(){
|
function setDaylightSavingJobFunctions(){
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue