Description:
- Show current week in Event Calendar
- buy me a coffee

Use code to Code Injection > Footer (or Page Header Injection)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
let currentWeekIndex = 0;
let calendarCheckInterval;
function findCurrentWeek() {
$('.yui3-calendar-row').each(function(index) {
const weekRow = $(this);
let foundToday = false;
weekRow.find('td').each(function() {
if ($(this).hasClass('today')) {
currentWeekIndex = index;
foundToday = true;
return false;
}
});
if (foundToday) return false;
});
return currentWeekIndex;
}
function showOnlyCurrentWeek() {
$('.yui3-calendar-row').hide();
$('.yui3-calendar-row').eq(currentWeekIndex).show();
}
function showPreviousWeek() {
if (currentWeekIndex > 0) {
currentWeekIndex--;
showOnlyCurrentWeek();
}
}
function showNextWeek() {
const totalWeeks = $('.yui3-calendar-row').length;
if (currentWeekIndex < totalWeeks - 1) {
currentWeekIndex++;
showOnlyCurrentWeek();
}
}
function initCalendarWeekView() {
if ($('.yui3-calendar-row').length > 0 && $('.yui3-calendar-grid').length > 0) {
findCurrentWeek();
showOnlyCurrentWeek();
console.log('Calendar loadded - Show:', currentWeekIndex + 1);
if (calendarCheckInterval) {
clearInterval(calendarCheckInterval);
}
return true;
}
return false;
}
calendarCheckInterval = setInterval(function() {
initCalendarWeekView();
}, 500);
setTimeout(function() {
initCalendarWeekView();
}, 1000);
setTimeout(function() {
initCalendarWeekView();
}, 3000);
setTimeout(function() {
initCalendarWeekView();
}, 5000);
$(document).on('click', '.yui3-calendarnav-prevmonth', function() {
setTimeout(function() {
initCalendarWeekView();
}, 500);
});
$(document).on('click', '.yui3-calendarnav-nextmonth', function() {
setTimeout(function() {
initCalendarWeekView();
}, 500);
});
$(window).on('load', function() {
setTimeout(function() {
initCalendarWeekView();
}, 1000);
});
window.showPreviousWeek = showPreviousWeek;
window.showNextWeek = showNextWeek;
});
</script>