Widget:InitPageDzScript
<script> document.addEventListener('DOMContentLoaded', function () {
function getWeekNumber(date) { let d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())); let dayNum = d.getUTCDay() || 7; d.setUTCDate(d.getUTCDate() + 4 - dayNum); let yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1)); return Math.ceil((((d - yearStart) / 86400000) + 1) / 7); }
const url = window.location.origin; let actualWeekNumber = getWeekNumber(new Date()); const dzCard = document.getElementById('dz-card'); const today = new Date();
// Verifica se é sexta-feira antes das 7h40 if (today.getDay() === 5 && (today.getHours() < 7 || (today.getHours() === 7 && today.getMinutes() < 40))) { actualWeekNumber--; }
const dzWeeks = [ { name: 'Décima primeira semana', image: '/images/4/49/Card_DZ_D%C3%A9cima-Primeira-Semana.png' }, { name: 'Décima segunda semana', image: '/images/1/11/Card_DZ_D%C3%A9cima-Segunda-Semana.png' }, { name: 'Primeira semana', image: '/images/b/b2/Card_DZ_Primeira-Semana.png' }, { name: 'Segunda semana', image: '/images/9/97/Card_DZ_Segunda-Semana.png' }, { name: 'Terceira semana', image: '/images/f/fd/Card_DZ_Terceira-Semana.png' }, { name: 'Quarta semana', image: '/images/1/17/Card_DZ_Quarta-Semana.png' }, { name: 'Quinta semana', image: '/images/4/40/Card_DZ_Quinta-Semana.png' }, { name: 'Sexta semana', image: '/images/2/23/Card_DZ_Sexta-Semana.png' }, { name: 'Sétima semana', image: '/images/f/f2/Card_DZ_S%C3%A9tima-Semana.png' }, { name: 'Oitava semana', image: '/images/9/97/Card_DZ_Oitava-Semana.png' }, { name: 'Nona semana', image: '/images/b/b3/Card_DZ_Nona-Semana.png' }, { name: 'Décima semana', image: '/images/3/30/Card_DZ_D%C3%A9cima-Semana.png' }, ];
const selectedWeek = dzWeeks[actualWeekNumber % 12]; if (dzCard) { dzCard.src = url + selectedWeek.image; dzCard.alt = selectedWeek.name; }
});
</script>