Mudanças entre as edições de "MediaWiki:Common.js"

De Wiki Gla
Ir para navegação Ir para pesquisar
Linha 1: Linha 1:
   $(document).ready(function() {
   $(document).ready(function() {
  //------- COUNTDOWN MAINPAGE---------
  // //------- COUNTDOWN MAINPAGE---------
  
  
  const timer = $('#event-time');
  // const timer = $('#event-time');
  const eventImage = $('.event-image');
  // const eventImage = $('.event-image');
  const brazilOffset = -3;
  // const brazilOffset = -3;
  
  
  //Informações dos eventos
  // //Informações dos eventos
  const eventsInfo = {
  // const eventsInfo = {
  sunday: [
  // sunday: [
  {name: 'Foxy race (ship)', time: '09:30:00', src: '/images/9/93/Event_raceship.png'},
  // {name: 'Foxy race (ship)', time: '09:30:00', src: '/images/9/93/Event_raceship.png'},
  {name: 'Foxy count', time: '15:00:00', src: '/images/e/e4/Event_count.png'},
  // {name: 'Foxy count', time: '15:00:00', src: '/images/e/e4/Event_count.png'},
  {name: 'Foxy quiz', time: '19:00:00', src: '/images/6/6f/Event_quiz.png'},
  // {name: 'Foxy quiz', time: '19:00:00', src: '/images/6/6f/Event_quiz.png'},
  {name: 'Deathmatch', time: '22:00:00', src: '/images/8/84/Event_dm.png'},
  // {name: 'Deathmatch', time: '22:00:00', src: '/images/8/84/Event_dm.png'},
  ],
  // ],
  monday: [
  // monday: [
  {name: 'Foxy count', time: '09:30:00', src: '/images/e/e4/Event_count.png'},
  // {name: 'Foxy count', time: '09:30:00', src: '/images/e/e4/Event_count.png'},
  {name: 'Foxy quiz', time: '15:00:00', src: '/images/6/6f/Event_quiz.png'},
  // {name: 'Foxy quiz', time: '15:00:00', src: '/images/6/6f/Event_quiz.png'},
  {name: 'Deathmatch', time: '19:00:00', src: '/images/8/84/Event_dm.png'},
  // {name: 'Deathmatch', time: '19:00:00', src: '/images/8/84/Event_dm.png'},
  {name: 'Foxy race (ship)', time: '22:00:00', src: '/images/9/93/Event_raceship.png'},
  // {name: 'Foxy race (ship)', time: '22:00:00', src: '/images/9/93/Event_raceship.png'},
  ],
  // ],
  tuesday: [
  // tuesday: [
  {name: 'Foxy quiz', time: '09:30:00', src: '/images/6/6f/Event_quiz.png'},
  // {name: 'Foxy quiz', time: '09:30:00', src: '/images/6/6f/Event_quiz.png'},
  {name: 'Deathmatch', time: '15:00:00', src: '/images/8/84/Event_dm.png'},
  // {name: 'Deathmatch', time: '15:00:00', src: '/images/8/84/Event_dm.png'},
  {name: 'Foxy race', time: '19:00:00', src: '/images/0/03/Event_race.png'},
  // {name: 'Foxy race', time: '19:00:00', src: '/images/0/03/Event_race.png'},
  {name: 'Foxy count', time: '22:00:00', src: '/images/e/e4/Event_count.png'},
  // {name: 'Foxy count', time: '22:00:00', src: '/images/e/e4/Event_count.png'},
  ],
  // ],
  wednesday: [
  // wednesday: [
  {name: 'Deathmatch', time: '09:30:00', src: '/images/8/84/Event_dm.png'},
  // {name: 'Deathmatch', time: '09:30:00', src: '/images/8/84/Event_dm.png'},
  {name: 'Foxy race (ship)', time: '15:00:00', src: '/images/9/93/Event_raceship.png'},
  // {name: 'Foxy race (ship)', time: '15:00:00', src: '/images/9/93/Event_raceship.png'},
  {name: 'Foxy count', time: '19:00:00', src: '/images/e/e4/Event_count.png'},
  // {name: 'Foxy count', time: '19:00:00', src: '/images/e/e4/Event_count.png'},
  {name: 'Foxy quiz', time: '22:00:00', src: '/images/6/6f/Event_quiz.png'},
  // {name: 'Foxy quiz', time: '22:00:00', src: '/images/6/6f/Event_quiz.png'},
  ],
  // ],
  thursday: [
  // thursday: [
  {name: 'Foxy race', time: '09:30:00', src: '/images/0/03/Event_race.png'},
  // {name: 'Foxy race', time: '09:30:00', src: '/images/0/03/Event_race.png'},
  {name: 'Foxy count', time: '15:00:00', src: '/images/e/e4/Event_count.png'},
  // {name: 'Foxy count', time: '15:00:00', src: '/images/e/e4/Event_count.png'},
  {name: 'Foxy quiz', time: '19:00:00', src: '/images/6/6f/Event_quiz.png'},
  // {name: 'Foxy quiz', time: '19:00:00', src: '/images/6/6f/Event_quiz.png'},
  {name: 'Deathmatch', time: '22:00:00', src: '/images/8/84/Event_dm.png'},
  // {name: 'Deathmatch', time: '22:00:00', src: '/images/8/84/Event_dm.png'},
  ],
  // ],
  friday: [
  // friday: [
  {name: 'Foxy count', time: '09:30:00', src: '/images/e/e4/Event_count.png'},
  // {name: 'Foxy count', time: '09:30:00', src: '/images/e/e4/Event_count.png'},
  {name: 'Foxy quiz', time: '15:00:00', src: '/images/6/6f/Event_quiz.png'},
  // {name: 'Foxy quiz', time: '15:00:00', src: '/images/6/6f/Event_quiz.png'},
  {name: 'Deathmatch', time: '19:00:00', src: '/images/8/84/Event_dm.png'},
  // {name: 'Deathmatch', time: '19:00:00', src: '/images/8/84/Event_dm.png'},
  {name: 'Foxy race (ship)', time: '22:00:00', src: '/images/9/93/Event_raceship.png'},
  // {name: 'Foxy race (ship)', time: '22:00:00', src: '/images/9/93/Event_raceship.png'},
  ],
  // ],
  saturday: [
  // saturday: [
  {name: 'Foxy quiz', time: '09:30:00', src: '/images/6/6f/Event_quiz.png'},
  // {name: 'Foxy quiz', time: '09:30:00', src: '/images/6/6f/Event_quiz.png'},
  {name: 'Deathmatch', time: '15:00:00', src: '/images/8/84/Event_dm.png'},
  // {name: 'Deathmatch', time: '15:00:00', src: '/images/8/84/Event_dm.png'},
  {name: 'Foxy race', time: '19:00:00', src: '/images/0/03/Event_race.png'},
  // {name: 'Foxy race', time: '19:00:00', src: '/images/0/03/Event_race.png'},
  {name: 'Foxy count', time: '22:00:00', src: '/images/e/e4/Event_count.png'},
  // {name: 'Foxy count', time: '22:00:00', src: '/images/e/e4/Event_count.png'},
  ]
  // ]
  };
  // };
  
  
  var dayEvents;
  // var dayEvents;
  var distance;
  // var distance;
  var eventTime = new Date();
  // var eventTime = new Date();
  var eventStarting = new Date();
// var eventStarting = new Date();
  
  
  
  
  function pad(d) {
  // function pad(d) {
    return (d < 10) ? '0' + String(d) : String(d);
//    return (d < 10) ? '0' + String(d) : String(d);
  }
  // }
  
  
  function startTimer(eventTime, name){
  // function startTimer(eventTime, name){
setInterval(function() {
// setInterval(function() {
  distance = eventTime - new Date();
// distance = eventTime - new Date();
 
 
  if(distance > 0){
// if(distance > 0){
  hour = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
// hour = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  minute = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
// minute = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  seconds = Math.floor((distance % (1000 * 60)) / 1000);
// seconds = Math.floor((distance % (1000 * 60)) / 1000);
 
 
  timer.html(pad(hour) + ":" + pad(minute) + ":" + pad(seconds));
// timer.html(pad(hour) + ":" + pad(minute) + ":" + pad(seconds));
  }else {
// }else {
  setDayEvents(dayEvents);
// setDayEvents(dayEvents);
  return false;
// return false;
  }
// }
  }, 1000);
// }, 1000);
}
// }
  
  
  function setDayEvents (array) {
  // function setDayEvents (array) {
  dayEvents = array;
  // dayEvents = array;
  var split;
  // var split;
  const date = new Date()
  // const date = new Date()
  const utcTime = date.getTime() + (date.getTimezoneOffset() + 6000);
// const utcTime = date.getTime() + (date.getTimezoneOffset() + 6000);
  const currentTime = new Date(utcTime + (3600000 * brazilOffset));
// const currentTime = new Date(utcTime + (3600000 * brazilOffset));
 
 
  $.each(array, function (key, item) {
  // $.each(array, function (key, item) {
  split = item.time.split(":");
  // split = item.time.split(":");
  eventTime.setHours(split[0], split[1], split[2]);
  // eventTime.setHours(split[0], split[1], split[2]);
  eventStarting.setHours(split[0], (Number(split[1]) + 5), split[2]);
// eventStarting.setHours(split[0], (Number(split[1]) + 5), split[2]);
 
 
  if(currentTime <= eventTime){
// if(currentTime <= eventTime){
  var distance = eventTime - currentTime;
// var distance = eventTime - currentTime;
  hour = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
// hour = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  minute = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
// minute = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  seconds = Math.floor((distance % (1000 * 60)) / 1000);
// seconds = Math.floor((distance % (1000 * 60)) / 1000);
 
 
  timer.html(pad(hour) + ":" + pad(minute) + ":" + pad(seconds));
// timer.html(pad(hour) + ":" + pad(minute) + ":" + pad(seconds));
  eventImage.attr('src', item.src);
// eventImage.attr('src', item.src);
  startTimer(eventTime, item.name);
// startTimer(eventTime, item.name);
  return false;
// return false;
  }else if(eventTime < currentTime  && currentTime < eventStarting){
// }else if(eventTime < currentTime  && currentTime < eventStarting){
  eventImage.attr('src', item.src);
// eventImage.attr('src', item.src);
  timer.html('Evento está começando!');
// timer.html('Evento está começando!');
  return false;
// return false;
  }else if(eventTime < currentTime){
// }else if(eventTime < currentTime){
  eventImage.attr('src', "/images/a/a5/AnyEvent.png");
// eventImage.attr('src', "/images/a/a5/AnyEvent.png");
  timer.html('');
// timer.html('');
  }
// }
  });
// });
  }
  // }
  
  
  switch(new Date().getDay()) {
  // switch(new Date().getDay()) {
  case 0:
  // case 0:
  setDayEvents(eventsInfo.sunday);
  // setDayEvents(eventsInfo.sunday);
  break;
  // break;
  case 1:
  // case 1:
  setDayEvents(eventsInfo.monday);
  // setDayEvents(eventsInfo.monday);
  break;
  // break;
  case 2:
  // case 2:
  setDayEvents(eventsInfo.tuesday);
  // setDayEvents(eventsInfo.tuesday);
  break;
  // break;
  case 3:
  // case 3:
  setDayEvents(eventsInfo.wednesday);
  // setDayEvents(eventsInfo.wednesday);
  break;
  // break;
  case 4:
  // case 4:
  setDayEvents(eventsInfo.thursday);
  // setDayEvents(eventsInfo.thursday);
  break;
  // break;
  case 5:
  // case 5:
  setDayEvents(eventsInfo.friday);
  // setDayEvents(eventsInfo.friday);
  break;
  // break;
  case 6:
  // case 6:
  setDayEvents(eventsInfo.saturday);
  // setDayEvents(eventsInfo.saturday);
  break;
  // break;
  default:
  // default:
  setDayEvents(eventsInfo.sunday);
  // setDayEvents(eventsInfo.sunday);
  }
  // }
   });
   //});
    
    
   //------- COUNTDOWN MAINPAGE---------
   //------- COUNTDOWN MAINPAGE---------

Edição das 22h42min de 6 de junho de 2022

  $(document).ready(function() {
  //		//------- COUNTDOWN MAINPAGE---------
  		
  //		const timer = $('#event-time');
  //		const eventImage = $('.event-image');
  //		const brazilOffset = -3;
  		
  //		//Informações dos eventos
  //		const eventsInfo = {
  //			sunday: [
  //				{name: 'Foxy race (ship)', time: '09:30:00', src: '/images/9/93/Event_raceship.png'},
  //				{name: 'Foxy count', time: '15:00:00', src: '/images/e/e4/Event_count.png'},
  //				{name: 'Foxy quiz', time: '19:00:00', src: '/images/6/6f/Event_quiz.png'},
  //				{name: 'Deathmatch', time: '22:00:00', src: '/images/8/84/Event_dm.png'},
  //			],
  //			monday: [
  //				{name: 'Foxy count', time: '09:30:00', src: '/images/e/e4/Event_count.png'},
  //				{name: 'Foxy quiz', time: '15:00:00', src: '/images/6/6f/Event_quiz.png'},
  //				{name: 'Deathmatch', time: '19:00:00', src: '/images/8/84/Event_dm.png'},
  //				{name: 'Foxy race (ship)', time: '22:00:00', src: '/images/9/93/Event_raceship.png'},
  //			],
  //			tuesday: [
  //				{name: 'Foxy quiz', time: '09:30:00', src: '/images/6/6f/Event_quiz.png'},
  //				{name: 'Deathmatch', time: '15:00:00', src: '/images/8/84/Event_dm.png'},
  //				{name: 'Foxy race', time: '19:00:00', src: '/images/0/03/Event_race.png'},
  //				{name: 'Foxy count', time: '22:00:00', src: '/images/e/e4/Event_count.png'},
  //			],
  //			wednesday: [
  //				{name: 'Deathmatch', time: '09:30:00', src: '/images/8/84/Event_dm.png'},
  //				{name: 'Foxy race (ship)', time: '15:00:00', src: '/images/9/93/Event_raceship.png'},
  //				{name: 'Foxy count', time: '19:00:00', src: '/images/e/e4/Event_count.png'},
  //				{name: 'Foxy quiz', time: '22:00:00', src: '/images/6/6f/Event_quiz.png'},
  //			],
  //			thursday: [
  //				{name: 'Foxy race', time: '09:30:00', src: '/images/0/03/Event_race.png'},
  //				{name: 'Foxy count', time: '15:00:00', src: '/images/e/e4/Event_count.png'},
  //				{name: 'Foxy quiz', time: '19:00:00', src: '/images/6/6f/Event_quiz.png'},
  //				{name: 'Deathmatch', time: '22:00:00', src: '/images/8/84/Event_dm.png'},
  //			],
  //			friday: [
  //				{name: 'Foxy count', time: '09:30:00', src: '/images/e/e4/Event_count.png'},
  //				{name: 'Foxy quiz', time: '15:00:00', src: '/images/6/6f/Event_quiz.png'},
  //				{name: 'Deathmatch', time: '19:00:00', src: '/images/8/84/Event_dm.png'},
  //				{name: 'Foxy race (ship)', time: '22:00:00', src: '/images/9/93/Event_raceship.png'},
  //			],
  //			saturday: [
  //				{name: 'Foxy quiz', time: '09:30:00', src: '/images/6/6f/Event_quiz.png'},
  //				{name: 'Deathmatch', time: '15:00:00', src: '/images/8/84/Event_dm.png'},
  //				{name: 'Foxy race', time: '19:00:00', src: '/images/0/03/Event_race.png'},
  //				{name: 'Foxy count', time: '22:00:00', src: '/images/e/e4/Event_count.png'},
  //			]
  //		};
  		
  //		var dayEvents;
  //		var distance;
  //		var eventTime = new Date();
	 // 	var eventStarting = new Date();
  		
  		
  //		function pad(d) {
		//     return (d < 10) ? '0' + String(d) : String(d);
  //		}
  		
  //		function startTimer(eventTime, name){
		// 	setInterval(function() {
	 // 			distance = eventTime - new Date();
	  			
	 // 			if(distance > 0){
	 // 				hour = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
	 // 				minute = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
	 // 				seconds = Math.floor((distance % (1000 * 60)) / 1000);
	  				
	 // 				timer.html(pad(hour) + ":" + pad(minute) + ":" + pad(seconds));
	 // 			}else {
	 // 				setDayEvents(dayEvents);
	 // 				return false;
	 // 			}
	 // 		}, 1000);
		// }
  		
  //		function setDayEvents (array) {
  //			dayEvents = array;
  //			var split;
  //			const date = new Date()
	 // 		const utcTime = date.getTime() + (date.getTimezoneOffset() + 6000);
	 // 		const currentTime = new Date(utcTime + (3600000 * brazilOffset));
	  		
  //			$.each(array, function (key, item) {
  //				split = item.time.split(":");
  //				eventTime.setHours(split[0], split[1], split[2]);
	 // 			eventStarting.setHours(split[0], (Number(split[1]) + 5), split[2]);
	  			
	 // 			if(currentTime <= eventTime){
	 // 				var distance = eventTime - currentTime;
	 // 				hour = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
	 // 				minute = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
	 // 				seconds = Math.floor((distance % (1000 * 60)) / 1000);
	  				
	 // 				timer.html(pad(hour) + ":" + pad(minute) + ":" + pad(seconds));
	 // 				eventImage.attr('src', item.src);
	 // 				startTimer(eventTime, item.name);
	 // 				return false;
	 // 			}else if(eventTime < currentTime  && currentTime < eventStarting){
	 // 				eventImage.attr('src', item.src);
	 // 				timer.html('Evento está começando!');
	 // 				return false;
	 // 			}else if(eventTime < currentTime){
	 // 				eventImage.attr('src', "/images/a/a5/AnyEvent.png");
	 // 				timer.html('');
	 // 			}
	 // 		});
  //		}
  		
  //		switch(new Date().getDay()) {
  //			case 0:
  //				setDayEvents(eventsInfo.sunday);
  //			break;
  //			case 1:
  //				setDayEvents(eventsInfo.monday);
  //			break;
  //			case 2:
  //				setDayEvents(eventsInfo.tuesday);
  //			break;
  //			case 3:
  //				setDayEvents(eventsInfo.wednesday);
  //			break;
  //			case 4:
  //				setDayEvents(eventsInfo.thursday);
  //			break;
  //			case 5:
  //				setDayEvents(eventsInfo.friday);
  //			break;
  //			case 6:
  //				setDayEvents(eventsInfo.saturday);
  //			break;
  //			default:
  //				setDayEvents(eventsInfo.sunday);
  //		}
  //});
  
  //------- COUNTDOWN MAINPAGE---------