1gfTimer.instances = []; 2 3function gfTimer(func, param, delayMs, times) { 4 // console.log(func); 5 if(times == undefined) times = -1; 6 if(delayMs == undefined) delayMs = 10; 7 8 this.func = func; 9 10 var times = times / 1000; 11 var timesCount = 0; 12 var ticks = (delayMs / 10)|0; 13 var count = 0; 14 15 gfTimer.instances.push(this); 16 17 this.tick = function() { 18 if(count >= ticks) { 19 this.func(param); 20 count = 0; 21 22 if(times > -1) { 23 24 timesCount++; 25 if(timesCount >= times) { 26 this.stop(); 27 } 28 } 29 } 30 count++; 31 }; 32 33 this.stop = function() { 34 var index = gfTimer.instances.indexOf(this); 35 gfTimer.instances.splice(index, 1); 36 }; 37} 38 39gfTimer.ontick = function() { 40 for(var i in gfTimer.instances) { 41 gfTimer.instances[i].tick(); 42 } 43} 44 45 46function gfTransTime(e, s) { 47 if(isEmpty(s)) s = moment(); 48 else s = moment(s, 'YYYY-MM-DD HH:mm:ss'); 49 50 if(isEmpty(e)) return false; 51 e = moment(e, 'YYYY-MM-DD HH:mm:ss'); 52 53 this.getTimeStamp = function() { 54 return e - s > 0 ? e - s : 0; 55 }; 56 this.getDate = function() { 57 return moment.duration(e.diff(s)).days() > 0 ? moment.duration(e.diff(s)).days() : 0; 58 }; 59 this.getHours = function() { 60 return moment.duration(e.diff(s)).hours() > 0 ? moment.duration(e.diff(s)).hours() : 0; 61 }; 62 63 this.getMinutes = function() { 64 return moment.duration(e.diff(s)).minutes() > 0 ? moment.duration(e.diff(s)).minutes() : 0; 65 }; 66 67 this.getSeconds = function() { 68 return moment.duration(e.diff(s)).seconds() > 0 ? moment.duration(e.diff(s)).seconds() : 0; 69 }; 70} 71 72const gfTimerV2 = function(func, params, intervalMillisecond, stopDateTime) { 73 const _this = this; 74 75 this._func = func; 76 this._params = params; 77 this._intervalMillisecond = intervalMillisecond === null || intervalMillisecond === '' || intervalMillisecond === undefined ? 10 : intervalMillisecond; 78 this._stopDateTime = stopDateTime; 79 80 this.countdown = function() { 81 if(!document.contains(_this._params)) { 82 _this.stop(); 83 } 84 const diffTime = new gfTransTime(_this._stopDateTime, null); 85 86 if(diffTime.getTimeStamp() > 0) { 87 _this._func(_this._params); 88 } else { 89 _this.stop(); 90 } 91 }; 92 93 this.stop = function() { 94 clearInterval(_this.timer); 95 }; 96 97 this.countdown(); 98 99 this.timer = setInterval(_this.countdown, _this._intervalMillisecond); 100};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.