KOSASIH / SilkRoad

Use $interval instead of setInterval JS-0557
Anti-pattern
Minor
8 months agoa year old
You should use the $interval service instead of the default window.setInterval method
28TLib.setFocus=function(id){if(!TLib.getObj(id)) return;TLib.getObj(id).focus();}
29TLib.getTopPosition=function(target){var top=0;if(target.offsetParent){while(1){top+=target.offsetTop;if(!target.offsetParent){break;}target=target.offsetParent;}}else if(target.y){top+=target.y;}return top;}
30TLib.getLeftPosition=function(target){var left=0;if(target.offsetParent){while(1){left+=target.offsetLeft;if(!target.offsetParent){break;}target=target.offsetParent;}}else if(target.x){left+=target.x;}return left;}
31TLib.showMessage=function(target,message,autohide){var msg;var msgcontent;if(!top.message){var MSGTIMER=10;var MSGSPEED=5;var MSGOFFSET=1;var MSGHIDE=2;msg=document.createElement('div');msg.id='msg';msgcontent=document.createElement('div');msgcontent.id='msgcontent';document.body.appendChild(msg);msg.appendChild(msgcontent);msg.style.filter='alpha(opacity=0)';msg.style.opacity=0;msg.alpha=0;top.message=msg;msg.show=function(flag){var value;if(flag==1){value=msg.alpha+MSGSPEED;}else{value=msg.alpha-MSGSPEED;}msg.alpha=value;msg.style.opacity=(value/100);msg.style.filter='alpha(opacity='+value+')';if(value>=99){clearInterval(msg.timer);msg.timer=null;}else if(value<=1){msg.style.display="none";clearInterval(msg.timer);}};msg.hide=function(){var msg=TLib.getObj('msg');if(msg){if(!msg.timer){msg.timer=setInterval("top.message.show(0)",MSGTIMER);}}}}else{msg=TLib.getObj('msg');msgcontent=TLib.getObj('msgcontent');}msgcontent.innerHTML=message;msg.style.display='block';var msgheight=msg.offsetHeight;var targetdiv=TLib.getObj(target);targetdiv.focus();var targetheight=targetdiv.offsetHeight;var targetwidth=targetdiv.offsetWidth;var topposition=TLib.getTopPosition(targetdiv)-((msgheight-targetheight)/2);var leftposition=TLib.getLeftPosition(targetdiv)+targetwidth+MSGOFFSET;msg.style.top=topposition+'px';msg.style.left=leftposition+'px';clearInterval(msg.timer);msg.timer=setInterval("top.message.show(1)",MSGTIMER);if(!autohide){autohide=MSGHIDE;}window.setTimeout("top.message.hide()",(autohide*5000));}32TLib.isEmail=function(val){if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(val)){return true;}return false;}
33TLib.isEmpty=function(val){return TLib.trim(val)=='';}
34TLib.isNumber=function(val){var reg=/^\d+$/;return (reg.test(val));}
You should use the $interval service instead of the default window.setInterval method
28TLib.setFocus=function(id){if(!TLib.getObj(id)) return;TLib.getObj(id).focus();}
29TLib.getTopPosition=function(target){var top=0;if(target.offsetParent){while(1){top+=target.offsetTop;if(!target.offsetParent){break;}target=target.offsetParent;}}else if(target.y){top+=target.y;}return top;}
30TLib.getLeftPosition=function(target){var left=0;if(target.offsetParent){while(1){left+=target.offsetLeft;if(!target.offsetParent){break;}target=target.offsetParent;}}else if(target.x){left+=target.x;}return left;}
31TLib.showMessage=function(target,message,autohide){var msg;var msgcontent;if(!top.message){var MSGTIMER=10;var MSGSPEED=5;var MSGOFFSET=1;var MSGHIDE=2;msg=document.createElement('div');msg.id='msg';msgcontent=document.createElement('div');msgcontent.id='msgcontent';document.body.appendChild(msg);msg.appendChild(msgcontent);msg.style.filter='alpha(opacity=0)';msg.style.opacity=0;msg.alpha=0;top.message=msg;msg.show=function(flag){var value;if(flag==1){value=msg.alpha+MSGSPEED;}else{value=msg.alpha-MSGSPEED;}msg.alpha=value;msg.style.opacity=(value/100);msg.style.filter='alpha(opacity='+value+')';if(value>=99){clearInterval(msg.timer);msg.timer=null;}else if(value<=1){msg.style.display="none";clearInterval(msg.timer);}};msg.hide=function(){var msg=TLib.getObj('msg');if(msg){if(!msg.timer){msg.timer=setInterval("top.message.show(0)",MSGTIMER);}}}}else{msg=TLib.getObj('msg');msgcontent=TLib.getObj('msgcontent');}msgcontent.innerHTML=message;msg.style.display='block';var msgheight=msg.offsetHeight;var targetdiv=TLib.getObj(target);targetdiv.focus();var targetheight=targetdiv.offsetHeight;var targetwidth=targetdiv.offsetWidth;var topposition=TLib.getTopPosition(targetdiv)-((msgheight-targetheight)/2);var leftposition=TLib.getLeftPosition(targetdiv)+targetwidth+MSGOFFSET;msg.style.top=topposition+'px';msg.style.left=leftposition+'px';clearInterval(msg.timer);msg.timer=setInterval("top.message.show(1)",MSGTIMER);if(!autohide){autohide=MSGHIDE;}window.setTimeout("top.message.hide()",(autohide*5000));}32TLib.isEmail=function(val){if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(val)){return true;}return false;}
33TLib.isEmpty=function(val){return TLib.trim(val)=='';}
34TLib.isNumber=function(val){var reg=/^\d+$/;return (reg.test(val));}
You should use the $interval service instead of the default window.setInterval method
15935		// event.
15936		// Adds the check to add the timers only when both delay and track options are set (#14682)
15937		if ( this.options.track && this.options.show && this.options.show.delay ) {
15938			delayedShow = this.delayedShow = setInterval( function() {15939				if ( tooltip.is( ":visible" ) ) {15940					position( positionOption.of );15941					clearInterval( delayedShow );15942				}15943			}, $.fx.interval );15944		}
15945
15946		this._trigger( "open", event, { tooltip: tooltip } );
You should use the $interval service instead of the default window.setInterval method
 8090
 8091jQuery.fx.start = function() {
 8092	if ( !timerId ) {
 8093		timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); 8094	}
 8095};
 8096
You should use the $interval service instead of the default window.setInterval method
4050		t.elem = this.elem;
4051
4052		if ( t() && jQuery.timers.push(t) && !timerId ) {
4053			timerId = setInterval(function(){4054				var timers = jQuery.timers;40554056				for ( var i = 0; i < timers.length; i++ )4057					if ( !timers[i]() )4058						timers.splice(i--, 1);40594060				if ( !timers.length ) {4061					clearInterval( timerId );4062					timerId = undefined;4063				}4064			}, 13);4065		}
4066	},
4067