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
Linha 3: Linha 3:
   const url = window.location.origin;
   const url = window.location.origin;
   const date = new Date();
   const date = new Date();
   date.setHours(date.getHours() - 7.3);
   const merchantCard = document.getElementById('merchant-card');
 
  if(date.getDay() === 1) {
    if(date.getHours() < 7 && date.getMinutes() < 40) date.setDate(date.getDate() - 1);
  }
 
   const weekDay = date.getDay();
   const weekDay = date.getDay();
  const merchantCard = document.getElementById('merchant-card');


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

Edição das 11h48min de 8 de maio de 2023

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

 const url = window.location.origin;
 const date = new Date();
 const merchantCard = document.getElementById('merchant-card');
 if(date.getDay() === 1) {
   if(date.getHours() < 7 && date.getMinutes() < 40) 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>