Widget:DzScript: mudanças entre as edições
Ir para navegação
Ir para pesquisar
(Criou página com '<script> document.addEventListener('DOMContentLoaded', function () { const dzWeeks = [ { name: 'Décima semana', image: '/images/3/30/Card_DZ_D%C3%A9cima-Semana.png' }, // 1ª semana { name: 'Décima primeira semana', image: '/images/4/49/Card_DZ_D%C3%A9cima-Primeira-Semana.png' }, // 2ª semana { name: 'Décima segunda semana', image: '/images/1/11/Card_DZ_D%C3%A9cima-Segunda-Semana.png' }, // 3ª semana { name: 'Primeira semana', image: '/images/b/b2/...') |
Sem resumo de edição Etiqueta: Revertido |
||
Linha 1: | Linha 1: | ||
document.addEventListener('DOMContentLoaded', function () { | document.addEventListener('DOMContentLoaded', function () { | ||
const dzWeeks = [ | const dzWeeks = [ | ||
{ name: 'Décima semana', image: '/images/3/30/Card_DZ_D%C3%A9cima-Semana.png' }, // 1ª semana | { name: 'Décima semana', image: '/images/3/30/Card_DZ_D%C3%A9cima-Semana.png' }, // 1ª semana | ||
{ name: 'Décima primeira semana', image: '/images/4/49/Card_DZ_D%C3%A9cima-Primeira-Semana.png' }, // 2ª semana | { name: 'Décima primeira semana', image: '/images/4/49/Card_DZ_D%C3%A9cima-Primeira-Semana.png' }, // 2ª semana | ||
// ... restante das semanas | |||
]; | ]; | ||
const url = window.location.origin; | const url = window.location.origin; | ||
const dzCard = document.getElementById('dz-card'); | const dzCard = document.getElementById('dz-card'); | ||
let currentWeekNumber = parseInt(localStorage.getItem('currentWeekNumber')) || 0; | |||
const today = new Date(); | const today = new Date(); | ||
Linha 25: | Linha 16: | ||
const lastUpdateDate = lastUpdate ? new Date(lastUpdate) : null; | const lastUpdateDate = lastUpdate ? new Date(lastUpdate) : null; | ||
const targetHour = 7; | const targetHour = 7; | ||
const targetMinute = 40; | const targetMinute = 40; | ||
if (today.getDay() === 5 && | if (today.getDay() === 5 && | ||
(today.getHours() > targetHour || (today.getHours() === targetHour && today.getMinutes() >= targetMinute))) { | (today.getHours() > targetHour || (today.getHours() === targetHour && today.getMinutes() >= targetMinute))) { | ||
if (!lastUpdateDate || lastUpdateDate < today.setHours(targetHour, targetMinute, 0, 0)) { | if (!lastUpdateDate || lastUpdateDate < today.setHours(targetHour, targetMinute, 0, 0)) { | ||
currentWeekNumber = (currentWeekNumber + 1) % dzWeeks.length; | currentWeekNumber = (currentWeekNumber + 1) % dzWeeks.length; | ||
localStorage.setItem('currentWeekNumber', currentWeekNumber); | localStorage.setItem('currentWeekNumber', currentWeekNumber); | ||
Linha 41: | Linha 29: | ||
} | } | ||
dzCard.src = url + dzWeeks[currentWeekNumber].image; | dzCard.src = url + dzWeeks[currentWeekNumber].image; | ||
dzCard.alt = dzWeeks[currentWeekNumber].name; | dzCard.alt = dzWeeks[currentWeekNumber].name; | ||
}); | }); | ||
Edição das 15h08min de 26 de agosto de 2024
document.addEventListener('DOMContentLoaded', function () {
const dzWeeks = [ { name: 'Décima semana', image: '/images/3/30/Card_DZ_D%C3%A9cima-Semana.png' }, // 1ª semana { name: 'Décima primeira semana', image: '/images/4/49/Card_DZ_D%C3%A9cima-Primeira-Semana.png' }, // 2ª semana // ... restante das semanas ];
const url = window.location.origin; const dzCard = document.getElementById('dz-card'); let currentWeekNumber = parseInt(localStorage.getItem('currentWeekNumber')) || 0;
const today = new Date(); const lastUpdate = localStorage.getItem('lastUpdate'); const lastUpdateDate = lastUpdate ? new Date(lastUpdate) : null;
const targetHour = 7; const targetMinute = 40;
if (today.getDay() === 5 && (today.getHours() > targetHour || (today.getHours() === targetHour && today.getMinutes() >= targetMinute))) { if (!lastUpdateDate || lastUpdateDate < today.setHours(targetHour, targetMinute, 0, 0)) { currentWeekNumber = (currentWeekNumber + 1) % dzWeeks.length; localStorage.setItem('currentWeekNumber', currentWeekNumber); localStorage.setItem('lastUpdate', new Date().toISOString()); } }
dzCard.src = url + dzWeeks[currentWeekNumber].image; dzCard.alt = dzWeeks[currentWeekNumber].name;
});