Widget:InitPageMerchantScript: mudanças entre as edições

De PokeXGames
Ir para navegação Ir para pesquisar
Sem resumo de edição
Sem resumo de edição
 
(4 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 2: Linha 2:
document.addEventListener('DOMContentLoaded', function () {   
document.addEventListener('DOMContentLoaded', function () {   
   const url = window.location.origin;
   const url = window.location.origin;
   const weekDay = new Date().getWeekNumber();
   const date = new Date();
  const updateTime = 7 * 60 + 40;
   const merchantCard = document.getElementById('merchant-card');
   const merchantCard = document.getElementById('merchant-card');
  if((date.getHours()*60+date.getMinutes()) < updateTime) date.setDate(date.getDate() - 1);
  const weekDay = date.getDay();


   // Indice 0 == Domingo -> Indice 6 == Sábado
   // Indice 0 == Domingo -> Indice 6 == Sábado

Edição atual tal como às 16h30min de 12 de julho de 2023

<script> document.addEventListener('DOMContentLoaded', function () {

 const url = window.location.origin;
 const date = new Date();
 const updateTime = 7 * 60 + 40;
 const merchantCard = document.getElementById('merchant-card');
 if((date.getHours()*60+date.getMinutes()) < updateTime) date.setDate(date.getDate() - 1);
 const weekDay = date.getDay();
 // Indice 0 == Domingo -> Indice 6 == Sábado
 const positions = [
   {
     alt : 'Merchant em Cerulean',
     image : '/images/8/86/Card_Merchant-Cerulean.png' 
   },
   {
     alt : 'Merchant em Pewter',
     image : '/images/1/1c/Card_Merchant-Pewter.png' 
   },
   {
     alt : 'Merchant em Viridian',
     image : '/images/c/c0/Card_Merchant-Viridian.png' 
   },
   {
     alt : 'Merchant em Fuchsia',
     image : '/images/a/aa/Card_Merchant-Fuchsia.png' 
   },
   {
     alt : 'Merchant em Cinnabar',
     image : '/images/1/1c/Card_Merchant-Cinnabar.png' 
   },
   {
     alt : 'Merchant em Pallet',
     image : '/images/6/6d/Card_Merchant-Pallet.png' 
   },
   {
     alt : 'Merchant em Lavender',
     image : '/images/2/2b/Card_Merchant-Lavender.png' 
   }
 ];
 merchantCard.src = url + positions[weekDay].image;
 merchantCard.alt = positions[weekDay].alt;

}); </script>