11'use strict' ;
2- /*global events, module, require, __plugin, setInterval, clearInterval, setTimeout, addUnloadHandler*/
32var utils = require ( 'utils' ) ;
43/************************************************************************
54## The at Module
@@ -14,11 +13,11 @@ The utils.at() function will perform a given task at a given time in the
1413
1514#### Parameters
1615
17- * time24hr : The time in 24hr form - e.g. 9:30 in the morning is '09:30' while
16+ * time24hr : The time in 24hr form - e.g. 9:30 in the morning is '09:30' while
1817 9:30 pm is '21:30', midnight is '00:00' and midday is '12:00'
19- * callback : A javascript function which will be invoked at the given time.
20- * worlds : (optional) An array of worlds. Each world has its own clock. If no array of worlds is specified, all the server's worlds are used.
21- * repeat : (optional) true or false, default is true (repeat the task every day)
18+ * callback : A javascript function which will be invoked at the given time.
19+ * worlds : (optional) An array of worlds. Each world has its own clock. If no array of worlds is specified, all the server's worlds are used.
20+ * repeat : (optional) true or false, default is true (repeat the task every day)
2221
2322#### Example
2423
@@ -67,7 +66,7 @@ function at(time24hr, callback, pWorlds, repeat) {
6766 utils . foreach ( pWorlds , function ( world ) {
6867 atAddTask ( timeMins , callback , world , repeat ) ;
6968 } ) ;
70- } ;
69+ }
7170var atTasks = { } ;
7271
7372function tasksToString ( ) {
@@ -77,16 +76,16 @@ function tasksToString(){
7776 for ( var time in atTasks [ world ] ) {
7877 var scheduledFuncs = atTasks [ world ] [ time ] ;
7978 for ( var i = 0 ; i < scheduledFuncs . length ; i ++ ) {
80- result += ' ' + time + ': ' + scheduledFuncs [ i ] . constructor + '\n' ;
79+ result += ' ' + time + ': ' + scheduledFuncs [ i ] . constructor + '\n' ;
8180 }
8281 }
8382 result += '(current world time: ' + utils . time24 ( world ) + ')\n' ;
8483 }
8584 return result ;
8685}
8786/*
88- constructs a function which will be called every x ticks to
89- track the schedule for a given world
87+ constructs a function which will be called every x ticks to
88+ track the schedule for a given world
9089*/
9190function atMonitorFactory ( world ) {
9291 var worldName = '' + world . name ;
@@ -110,16 +109,16 @@ function atMonitorFactory(world){
110109
111110 var tasks = worldSchedule [ lastRun ++ ] ;
112111 if ( ! tasks ) {
113- continue ;
112+ continue ;
114113 }
115114 utils . foreach ( tasks , function ( task , i ) {
116- if ( ! task ) {
117- return ;
118- }
119- setTimeout ( task . callback . bind ( null , timeMins , world ) , 1 ) ;
120- if ( ! task . repeat ) {
121- tasks [ i ] = null ;
122- }
115+ if ( ! task ) {
116+ return ;
117+ }
118+ setTimeout ( task . callback . bind ( null , timeMins , world ) , 1 ) ;
119+ if ( ! task . repeat ) {
120+ tasks [ i ] = null ;
121+ }
123122 } ) ;
124123 }
125124 } ;
0 commit comments