Team:UNITN-Trento/JS/Library/onTimeChange

From 2013.igem.org

(Difference between revisions)
(Created page with "/** * onTimeChange (oTch) event handler * @version onTimeChange 1.0 * @copyright Copyright (c) 2010-2012, Gabriele Girelli * @author ggirelli <g.girelli@studenti.unitn.it> *...")
 

Latest revision as of 16:36, 8 August 2013

/**

* onTimeChange (oTch) event handler
* @version onTimeChange 1.0
* @copyright Copyright (c) 2010-2012, Gabriele Girelli
* @author ggirelli <g.girelli@studenti.unitn.it>
*/

function oTch(event) {

   var getTimeValue = function() {
       var d = new Date();
       return d.getTime();
   }
       var lastTime = getTimeValue();
   (function listenTime() {
       var time = getTimeValue();
       if (time !== lastTime) {
           event();
           lastTime = time;
       }
       var t = setTimeout(listenTime, 100);
   })();

}