Files
pathfinder/js/lib/easytimer.min.js

8 lines
5.3 KiB
JavaScript

/**
* easytimer.js
* Generated: 2019-10-31
* Version: 4.0.2
*/
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).easytimer={})}(this,function(n){"use strict";function q(n){return(q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function i(n,t,e){var o,r="";if((n="number"==typeof n?String(n):n).length>t)return n;for(o=0;o<t;o+=1)r+=String(e);return(r+n).slice(-r.length)}function I(){this.secondTenths=0,this.seconds=0,this.minutes=0,this.hours=0,this.days=0,this.toString=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:["hours","minutes","seconds"],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:":",e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:2;n=n||["hours","minutes","seconds"],t=t||":",e=e||2;var o,r=[];for(o=0;o<n.length;o+=1)void 0!==this[n[o]]&&("secondTenths"===n[o]?r.push(this[n[o]]):r.push(i(this[n[o]],e,"0")));return r.join(t)}}var t="undefined"!=typeof window?window.CustomEvent:void 0;"undefined"!=typeof window&&"function"!=typeof t&&((t=function(n,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var e=document.createEvent("CustomEvent");return e.initCustomEvent(n,t.bubbles,t.cancelable,t.detail),e}).prototype=window.Event.prototype,window.CustomEvent=t);var _="secondTenths",z="seconds",R="minutes",B="hours",F="days",G=[_,z,R,B,F],H={secondTenths:100,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},J={secondTenths:10,seconds:60,minutes:60,hours:24},K="undefined"!=typeof module&&module.exports&&"function"==typeof require?require("events"):void 0;function N(){return"undefined"!=typeof document}function Q(){return K}function W(n,t){return(n%t+t)%t}function e(){var t,e,r,o,i,s,u,c,a,f,d=new I,h=new I,l=N()?document.createElement("span"):Q()?new K.EventEmitter:void 0,v=!1,p=!1,m={},y={detail:{timer:this}};function w(n,t){var e=h[t];return function(n,t){h[n]=t,d[n]=n===F?t:0<=t?W(t,J[n]):J[n]-W(t,J[n])}(t,V(n,H[t])),h[t]!==e}function n(){b(),function(){for(var n in d)d.hasOwnProperty(n)&&"number"==typeof d[n]&&(d[n]=0);for(var t in h)h.hasOwnProperty(t)&&"number"==typeof h[t]&&(h[t]=0)}()}function b(){clearInterval(t),t=void 0,p=v=!1}function g(n){k()?(a=E(),s=L(i.target)):function(n){e=function(n){if(function(n){return 0<=G.indexOf(n)}(n=typeof n==="string"?n:z))return n;throw new Error("Error in precision parameter: ".concat(n," is not a valid value"))}((n=n||{}).precision),o="function"==typeof n.callback?n.callback:function(){},c=!0===n.countdown,r=!0==c?-1:1,"object"===q(n.startValues)?function(n){u=C(n),d.secondTenths=u[0],d.seconds=u[1],d.minutes=u[2],d.hours=u[3],d.days=u[4],h=O(u,h)}(n.startValues):u=null;a=E(),S(),s="object"===q(n.target)?L(n.target):c?(n.target={seconds:0},L(n.target)):null;m={precision:e,callback:o,countdown:"object"===q(n)&&!0===n.countdown,target:s,startValues:u},i=n}(n),function(){var n=H[e];if(x(j(Date.now())))return;t=setInterval(T,n),v=!0,p=!1}()}function E(){return j(Date.now())-h.secondTenths*H[_]*r}function T(){var n=j(Date.now());!function(n){n[_]&&M("secondTenthsUpdated",y);n[z]&&M("secondsUpdated",y);n[R]&&M("minutesUpdated",y);n[B]&&M("hoursUpdated",y);n[F]&&M("daysUpdated",y)}(S()),o(y.detail.timer),x(n)&&(U(),M("targetAchieved",y))}function S(n){var t=0<arguments.length&&void 0!==n?n:j(Date.now()),e=0<r?t-a:a-t,o={};return o[_]=function(n){return w(n,_)}(e),o[z]=function(n){return w(n,z)}(e),o[R]=function(n){return w(n,R)}(e),o[B]=function(n){return w(n,B)}(e),o[F]=function(n){return w(n,F)}(e),o}function j(n){return Math.floor(n/H[e])*H[e]}function x(n){return s instanceof Array&&f<=n}function C(n){var t,e,o,r,i,s;if("object"===q(n))if(n instanceof Array){if(5!==n.length)throw new Error("Array size not valid");s=n}else{for(var u in n)if(G.indexOf(u)<0)throw new Error("Error in startValues or target parameter: ".concat(u," is not a valid input value"));s=[n.secondTenths||0,n.seconds||0,n.minutes||0,n.hours||0,n.days||0]}return t=s[0],e=s[1]+V(t,10),o=s[2]+V(e,60),r=s[3]+V(o,60),i=s[4]+V(r,24),s[0]=t%10,s[1]=e%60,s[2]=o%60,s[3]=r%24,s[4]=i,s}function V(n,t){var e=n/t;return e<0?Math.ceil(e):Math.floor(e)}function L(n){if(n){var t=O(s=C(n));return f=a+t.secondTenths*H[_]*r,s}}function O(n,t){var e=t||{};return e.days=n[4],e.hours=24*e.days+n[3],e.minutes=60*e.hours+n[2],e.seconds=60*e.minutes+n[1],e.secondTenths=10*e.seconds+n[[0]],e}function U(){n(),M("stopped",y)}function A(n,t){N()?l.addEventListener(n,t):Q()&&l.on(n,t)}function D(n,t){N()?l.removeEventListener(n,t):Q()&&l.removeListener(n,t)}function M(n,t){N()?l.dispatchEvent(new CustomEvent(n,t)):Q()&&l.emit(n,t)}function P(){return v}function k(){return p}void 0!==this&&(this.start=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};P()||(g(n),M("started",y))},this.pause=function(){b(),p=!0,M("paused",y)},this.stop=U,this.reset=function(){n(),g(i),M("reset",y)},this.isRunning=P,this.isPaused=k,this.getTimeValues=function(){return d},this.getTotalTimeValues=function(){return h},this.getConfig=function(){return m},this.addEventListener=A,this.on=A,this.removeEventListener=D,this.off=D)}n.Timer=e,n.default=e,Object.defineProperty(n,"__esModule",{value:!0})});