${timeFormat(item?.start_at)} WIB
${item?.league?.name ?? "TBD"}
${item.name}
`;
}
});
// }
$('#result').append(successData);
moment.tz.setDefault('Asia/Bangkok');
var countdownInterval = setInterval(updateCountdown, 1000);
function updateCountdown() {
// Loop through each list item with a data-start-date attribute
$('.time_box').each(function() {
var startDateUnixTimestamp = $(this).data('start-date');
var startDate = moment.unix(startDateUnixTimestamp);
// Calculate the time remaining in milliseconds
var timeDifference = startDate.diff(moment(), 'seconds');
if (timeDifference > 0) {
var duration = moment.duration(timeDifference, 'seconds');
var hoursRemaining = duration.hours();
var minutesRemaining = duration.minutes();
var secondsRemaining = duration.seconds();
// Update the countdown text
$(this).text(
hoursRemaining +
'j ' +
minutesRemaining +
'm ' +
secondsRemaining +
'd'
);
} else {
clearInterval(countdownInterval);
// If the countdown has reached or passed the start date
$(this).text('Live').addClass('live_btn_active').text('Live');
}
});
}
// updateCountdown();
// Update the countdown every second
setInterval(updateCountdown, 1000);
});
$(document).on('click', '.main_match_wrapper', function() {
var dataListValue = $(this).data('list');
// redirect details page
window.location.href =
'https://nbrflx.co/live-badminton.php?id=' + dataListValue;
});
function dateFormat(date) {
return moment.unix(date).local().format("dddd, DD MMMM YYYY");
}
function timeFormat(date) {
const subtractDate = moment(date).subtract(2, 'hours');
return moment.unix(date).local().format("hh:mm");
}
// JavaScript to handle menu interactions
document.querySelectorAll('.scroll-menu .menu-item').forEach(item => {
item.addEventListener('click', function() {
document.querySelectorAll('.scroll-menu .menu-item').forEach(el => el.classList.remove('active'));
this.classList.add('active');
const sport = this.getAttribute('data-sport');
// Implement logic to filter fixtures based on selected sport
console.log(`Selected sport: ${sport}`);
});
});
// show suggestion list