MediaWiki:Common.js

$(function{       eventTimeLeft;        if(top.location != location) {	        $('a, form').each(function { if(!this.target) { this.target = '_top'; }	       });	}; }); var eTimeout; function eventTimeLeft{ $("#currentEvents .eStart").each(function{		var start=$(this).text;		var end=$(this).next(".eEnd").text;		var rows=$(this).attr("rowspan");		var s=start.match(/(\d+)\/(\d+) (\d+):00/);		var e=end.match(/(\d+)\/(\d+) (\d+):00/);		var now=new Date;		if (s && e){			if (now.getMonth==11 && parseInt(s[1])==1){				var startDate=new Date((now.getFullYear+1)+"-"+s[1]+"-"+s[2]+" "+s[3]+":00:00-7:00");			}else{				var startDate=new Date(now.getFullYear+"-"+s[1]+"-"+s[2]+" "+s[3]+":00:00-7:00");			}			if (now.getMonth==11 && parseInt(e[1])==1){				var endDate=new Date((now.getFullYear+1)+"-"+e[1]+"-"+e[2]+" "+e[3]+":00:00-7:00");			}else{				var endDate=new Date(now.getFullYear+"-"+e[1]+"-"+e[2]+" "+e[3]+":00:00-7:00");			}			var timeLeft=(startDate.getTime-now.getTime)/1000;			if (timeLeft>0){				if (timeLeft<3600) timeLeft="STARTS "+Math.ceil(timeLeft/60)+" min"; else if (timeLeft<86400) timeLeft="STARTS "+Math.floor(timeLeft/3600)+" hr "+Math.ceil(timeLeft%3600/60)+" min"; else timeLeft="STARTS "+Math.floor(timeLeft/86400)+" day "+Math.floor(timeLeft%86400/3600)+" hr"; }else{ timeLeft=(endDate.getTime-now.getTime)/1000; if (timeLeft>0){ if (timeLeft<3600) timeLeft=Math.ceil(timeLeft/60)+" min  "; else if (timeLeft<86400) timeLeft=Math.floor(timeLeft/3600)+" hr "+Math.ceil(timeLeft%3600/60)+" min LEFT "; else timeLeft=Math.floor(timeLeft/86400)+" day "+Math.floor(timeLeft%86400/3600)+" hr LEFT "; }else{ timeLeft=" EXPIRED "; }			}			$(this).before(""+timeLeft+" "); }else{ $(this).next(".eEnd").removeClass("eEnd"); $(this).removeClass("eStart"); }		setInterval(function{			$("#currentEvents .eLeft").hide;			$("#currentEvents .eStart, #currentEvents .eEnd").fadeIn;		}, 10000); setTimeout(function{			setInterval(function{ $("#currentEvents .eStart, #currentEvents .eEnd").hide; $("#currentEvents .eLeft").fadeIn; }, 10000);			$("#currentEvents .eStart, #currentEvents .eEnd").hide;			$("#currentEvents .eLeft").fadeIn;		}, 5000); }); }