MediaWiki:Common.js

var eTimeout; function eventTimeLeft{ $("#currentEvents .eStart").each(function{		if ($(this).parent.find(".eLeft").length) return;		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)+"-"+d2(s[1])+"-"+d2(s[2])+"T"+d2(s[3])+":00:00-07:00");			}else{				var startDate=new Date(now.getFullYear+"-"+d2(s[1])+"-"+d2(s[2])+"T"+d2(s[3])+":00:00-07:00");			}			if (now.getMonth==11 && parseInt(e[1])==1){				var endDate=new Date((now.getFullYear+1)+"-"+d2(e[1])+"-"+d2(e[2])+"T"+d2(e[3])+":00:00-07:00");			}else{				var endDate=new Date(now.getFullYear+"-"+d2(e[1])+"-"+d2(e[2])+"T"+d2(e[3])+":00:00-07: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"); }	});	startEventShow; } function startEventShow{	clearTimeout(eTimeout);	eTimeout=setTimeout(function{ $("#currentEvents .eStart, #currentEvents .eEnd").hide; $("#currentEvents .eLeft").fadeIn; setTimeout(function{			$("#currentEvents .eLeft").hide;			$("#currentEvents .eStart, #currentEvents .eEnd").fadeIn;			startEventShow;		}, 5000); }, 5000); } function d2(n){	if (parseInt(n)<10) return '0'+String(parseInt(n)); else return n; }

importScriptPage('ExternalImageLoader/code.js', 'dev');