User:SonyaUliana/wikia.js

(function{ 	'use strict'; 	var countDown = { 		leadingZeros : function(a) { 			if(a < 10) { 				return '0'+a; 			} else { 				return ''+a; 			} 		}, 		getHour : function(t){ 			return (t.getUTCHours >= 17 ? t.getUTCHours - 17 : t.getUTCHours + 7); 		}, 		count : function{ 			this.now = new Date; 			this.time = 24*3600 - (countDown.getHour(this.now)*3600 + this.now.getUTCMinutes*60 + this.now.getUTCSeconds); 			countDown.display.innerHTML = countDown.leadingZeros(Math.floor(this.time/3600))+' hours '+ 										 countDown.leadingZeros(Math.floor(this.time/60)%60)+' minutes '+ 										  countDown.leadingZeros(this.time%60)+' seconds'; 			setTimeout(function{ countDown.count; },1000); 		}, 		start : function{ 			if(countDown.begin !== Date.now) countDown.count; 			else { 				setTimeout(function{ countDown.start; },100); 			} 		}, 		display : document.querySelector('.countDownSortie'), 		begin : Date.now, 	} 	//Do nothing if doesn't exist 	if(countDown.display) { 		//Avoid 'jumping load' 		countDown.display.innerHTML = '00 hours 00 minutes 00 seconds'; 		countDown.start; 	} });