5 805
edições
Sem resumo de edição Etiqueta: Revertido |
Sem resumo de edição Etiqueta: Reversão manual |
||
Linha 15: | Linha 15: | ||
{ name: 'Nona semana', image: '/images/b/b3/Card_DZ_Nona-Semana.png' } // 12ª semana | { name: 'Nona semana', image: '/images/b/b3/Card_DZ_Nona-Semana.png' } // 12ª semana | ||
]; | ]; | ||
const url = window.location.origin; | const url = window.location.origin; | ||
const dzCard = document.getElementById('dz-card'); | const dzCard = document.getElementById('dz-card'); | ||
const storedWeekNumber = localStorage.getItem('currentWeekNumber'); | |||
let currentWeekNumber = storedWeekNumber ? parseInt(storedWeekNumber) : 0; | |||
const today = new Date(); | const today = new Date(); | ||
Linha 24: | Linha 25: | ||
const lastUpdateDate = lastUpdate ? new Date(lastUpdate) : null; | const lastUpdateDate = lastUpdate ? new Date(lastUpdate) : null; | ||
// Hora alvo para a atualização semanal (sexta-feira às 07:40) | |||
const targetHour = 7; | const targetHour = 7; | ||
const targetMinute = 40; | const targetMinute = 40; | ||
// Verifica se hoje é sexta-feira e já passou das 07: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)) { | ||
// Incrementa o contador de semanas e atualiza o armazenamento | |||
currentWeekNumber = (currentWeekNumber + 1) % dzWeeks.length; | currentWeekNumber = (currentWeekNumber + 1) % dzWeeks.length; | ||
localStorage.setItem('currentWeekNumber', currentWeekNumber); | localStorage.setItem('currentWeekNumber', currentWeekNumber); | ||
Linha 37: | Linha 41: | ||
} | } | ||
// Define a imagem e alt do cartão | |||
dzCard.src = url + dzWeeks[currentWeekNumber].image; | dzCard.src = url + dzWeeks[currentWeekNumber].image; | ||
dzCard.alt = dzWeeks[currentWeekNumber].name; | dzCard.alt = dzWeeks[currentWeekNumber].name; | ||
}); | }); | ||
</script> |