// Base URL for channel redirection
const baseUrl = 'https://player32-ss.blogspot.com/#';
// Match status constants
const STATUS = {
LIVE: { text: 'LIVE', color: '#10b981' },
END: { text: 'END', color: '#dc2626' },
UPCOMING: { color: '#1f2937' }
};
// DOM loaded event listener
document.addEventListener('DOMContentLoaded', function() {
// Initialize match status and set interval for updates
updateMatchStatus();
setInterval(updateMatchStatus, 60000); // Update every minute instead of every second
// Add event delegation for all play buttons
document.addEventListener('click', function(event) {
if (event.target.classList.contains('play-button')) {
const channelName = event.target.getAttribute('data-channel');
if (channelName) {
// ---- BARIS INI YANG DIUBAH ----
window.open(baseUrl + channelName, '_blank');
// ------------------------------
}
}
});
});
/**
* Updates the match status for all time elements
*/
function updateMatchStatus() {
const timeElements = document.querySelectorAll('.time');
const now = new Date();
timeElements.forEach(element => {
if (!element.hasAttribute('data-start') || !element.hasAttribute('data-date')) {
return;
}
const startTime = element.getAttribute('data-start');
const matchDate = element.getAttribute('data-date');
// Parse match date and time
const [startHours, startMinutes] = startTime.split(':').map(Number);
const [matchYear, matchMonth, matchDay] = matchDate.split('-').map(Number);
// Create Date objects for match start and end
const matchStart = new Date(matchYear, matchMonth - 1, matchDay, startHours, startMinutes);
const matchEnd = new Date(matchStart.getTime() + 130 * 60 * 1000); // 2h10m (130min) after start
// Update display based on current time
if (now >= matchStart && now < matchEnd) {
updateTimeElement(element, STATUS.LIVE.text, STATUS.LIVE.color);
} else if (now >= matchEnd) {
updateTimeElement(element, STATUS.END.text, STATUS.END.color);
} else {
updateTimeElement(element, startTime, STATUS.UPCOMING.color);
}
});
}
/**
* Helper function to update time element text and color
*/
function updateTimeElement(element, text, color) {
// Only update if changed to avoid unnecessary reflows
if (element.textContent !== text) {
element.textContent = text;
}
if (element.style.color !== color) {
element.style.color = color;
}
}
]]>