Team:UNITN-Trento/JS/Library/onTimeChange

From 2013.igem.org

/**

* 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);
   })();

}