-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtock.min.js
4 lines (4 loc) · 1.87 KB
/
tock.min.js
1
2
3
4
(function(j){var g,h,a={},f=0,i=0;h={isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},each:function(a,e,b){var e=void 0!==b?e.bind(b):e,d;if(this.isArray(a))if(void 0!==Array.forEach)a.forEach(e);else for(d=0;d<a.length;d+=1)e(a[d],d,a);else for(d in a)a.hasOwnProperty(d)&&e(a[d],d,a)}};g={wind:function(c,e,b,d){if(!(void 0===b||""===b)&&void 0===a[b])void 0!==d&&(c=c.bind(d)),a[b]={},a[b].wait=e,a[b].msRun=0,a[b].isInterval=!1,a[b].timeout=setTimeout(function(){c();
a[b].isInterval||g.unwind(b)},e),a[b].countInterval=setInterval(function(){a[b].secondsRun>=a[b].wait&&clearInterval(a[b].countInterval);a[b].msRun+=1E3},1E3),a[b].secondsLeft=function(){var c=a[b].wait-a[b].msRun;0>c&&(c=0);return c/1E3},f+=1},windInterval:function(c,e,b,d){if(!(void 0===b||""===b)&&void 0===a[b])void 0!==d&&(c=c.bind(d)),a[b]={},a[b].wait=e,a[b].msRun=0,a[b].isInterval=!0,a[b].timeout=setInterval(function(){a[b].msRun=0;c();a[b].isInterval||g.unwind(b)},e),a[b].countInterval=setInterval(function(){a[b].msRun+=
1E3},1E3),a[b].secondsLeft=function(){var c=a[b].wait-a[b].msRun;0>c&&(c=0);return c/1E3},f+=1},secondsLeft:function(c){var e=0;void 0!==a[c]&&(e=a[c].secondsLeft());return e},unwind:function(c){void 0!==a[c]&&(a[c].isInterval?clearInterval(a[c].timeout):clearTimeout(a[c].timeout),clearInterval(a[c].countInterval),f-=1,i+=1,delete a[c])},numTicking:function(){return f},numComplete:function(){return i},tockStatus:function(){var c="No clocks wound.",e;0<f&&(c="",h.each(a,function(b,d){e=a[d].isInterval?
"interval":"timeout";c+=d+" ("+e+"): "+b.secondsLeft()+" seconds left\n"}),c=c.slice(0,c.length-1));return c},unwindAll:function(){var c=this;h.each(a,function(a,b){c.unwind(b)})},destroy:function(){this.unwindAll();delete j.Tock},version:function(){return"0.1"}};j.Tock=g})(void 0!==this.process&&void 0!==this.process.title&&void 0!==this.exports?this.exports:window);