Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

This resource has not currently been approved, and is not currently linked to from our directory of resources. It is being displayed here for preview by the author and moderators only.
Rated
Read 752 times

Related Categories

multi-time-tracker - Multi Time Tracker

\\.\

Multi Time Tracker

/*     Multi-timer by \\.\PhysicalDevice0   */
timer={
    
id:[], 
     set:function(evtname,callback,interval){
          if(typeof(this.id[evtname])=='undefined') this.id[evtname]={ timer: setInterval(callback,interval)}
     },
     out:function(evtname,callback,interval){
          if(typeof(this.id[evtname])=='undefined') this.id[evtname]={ timer:setTimeout(callback,interval)}
    
},
    
kill:function(evtname){
          if(arguments.length) if(typeof(this.id[evtname])!='undefined'){
              
clearInterval(this.id[evtname].timer);
               delete this.id[evtname];
          }
     },
     msg:function(message){
          alert(message)
     },
     ids:function(){
          var tmp=[];
          for(i in this.id){
               if(this.id[i]) tmp.push(i);
          };
     return !tmp.length?false:tmp;
     }
};

/*  timer.set('ref',function,interval); // sets an interval timer

To set an intervalTimer

     example...

     timer.set('clock',updateClock,1000);
     timer.set('bannerRotate',rotate,20000);
     timer.set('hasloaded',hasloaded,60000);

To set a timeOut event...

     example...

     timer.out('alert3',showAlert,30000); // sets a timeout event timer, if the event exists, ignor request

To kill a timer...

     example...

     timer.kill('clock'); // kills the timer reference "clock", if it does not exist, the request is ignored

To get a list of set timers...

     example...

     x=timer.ids(); // returns an array current timers ID's that are running
  
To show an alert box

     example...

     timer.msg('Hello World!'); // outputs to an alert box with Hello World! as the message

The functions are self contained, they do not rely on anything additional or other libraries so you can simply paste into your existing code.

*/

Comments