$ = jQuery; let flag = true; if ( jQuery("form.woocommerce-checkout").length > 0 && !( jQuery("form.woocommerce-checkout").hasClass('wc-roundoff') ) ) { jQuery("form.woocommerce-checkout").addClass('wc-roundoff'); } dispaly_socialshare_links( jQuery ); jQuery(window).on('load', function(){ if ( wcOrderScript.donationToOrder.is_checkout && wcOrderScript.donationToOrder.is_roundOff == 'yes' ) { jQuery( '.wc-block-components-checkout-place-order-button' ).on('click', function (e) { if ( flag ) { e.stopPropagation(); add_popup_before_order(); } }); } }); jQuery(window).on('load', function(){ jQuery('.flip-clock').each(function() { var clockElement = jQuery(this); var clock; var startTimeStr = jQuery(this).data('start-time'); var endTimeStr = jQuery(this).data('end-time'); var endTimeArr = endTimeStr.split(':'); // Split the time string into hours and minutes var startTimeArr = startTimeStr.split(':'); // Split the start time string into hours and minutes var now = new Date(); // Set the start and end times to today with the provided hours and minutes var startTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseInt(startTimeArr[0]), parseInt(startTimeArr[1]), 0); var endTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseInt(endTimeArr[0]), parseInt(endTimeArr[1]), 0); // If the end time is before the current time, set it to tomorrow with the same hours and minutes if (endTime.getTime() < now.getTime()) { endTime.setDate(endTime.getDate() + 1); } var diff = endTime.getTime() / 1000 - now.getTime() / 1000; diff = Math.max(diff, 0); clockElement.addClass('non-clickable'); clock = jQuery(this).FlipClock(diff, { clockFace: 'HourlyCounter', countdown: true }); console.log('startTime'); console.log(startTime); console.log('endTime'); console.log(endTime); // Check the remaining time and start time every second var interval = setInterval(function() { now = new Date(); var remainingTime = clock.getTime().time; if (remainingTime <= 0) { clearInterval(interval); console.log('Reloading page'); location.reload(); // Reload the page } }, 1000); // To forcefully set the remaining time to the clock instance clock.setTime(diff); clock.start(); }); // Initialize Pomodoro clock instances jQuery('.pomodoro-clock-container').each(function () { var container = this; var timerLabel = jQuery(container).find('.timer-label'); var startTimeStr = jQuery(this).data('start-time'); var endTimeStr = jQuery(this).data('end-time'); var startTimeParts = startTimeStr.split(':'); var endTimeParts = endTimeStr.split(':'); var now = new Date(); var start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), startTimeParts[0], startTimeParts[1], 0); var end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), endTimeParts[0], endTimeParts[1], 0); if (end < start) { end.setDate(end.getDate() + 1); } var duration = (end - start) / 1000; var elapsedTime = (now - start) / 1000; var remainingTime = duration - elapsedTime; var storedRemainingTime = localStorage.getItem('remainingTime'); var lastSaved = localStorage.getItem('lastSaved'); if (storedRemainingTime && lastSaved) { var elapsedSinceLastSave = (now.getTime() - new Date(lastSaved).getTime()) / 1000; remainingTime = Math.max(0, storedRemainingTime - elapsedSinceLastSave); } var totalSecondsInDay = 24 * 60 * 60; remainingTime = remainingTime % totalSecondsInDay; var bar = new ProgressBar.Circle(container, { color: '#EFBBBE', trailColor: '#BF5252', trailWidth: 5, duration: remainingTime * 1000, easing: 'linear', strokeWidth: 5, from: { color: '#EFBBBE', width: 5 }, to: { color: '#EFBBBE', width: 5 }, step: function (state, circle) { var elapsed = (1.0 - circle.value()) * duration; var remaining = Math.max(duration - elapsed, 0); timerLabel.text(formatDuration(remaining)); circle.path.setAttribute('stroke', state.color); circle.path.setAttribute('stroke-width', state.width); } }); function updateProgressBar() { bar.set(remainingTime / duration); if (remainingTime <= 0) { clearInterval(progressInterval); } } var progressInterval = setInterval(updateProgressBar, 1100); var interval = setInterval(function () { now = new Date(); elapsedTime = (now - start) / 1000; remainingTime = Math.max(duration - elapsedTime, 0); remainingTime = remainingTime % totalSecondsInDay; timerLabel.text(formatDuration(remainingTime)); localStorage.setItem('remainingTime', remainingTime); localStorage.setItem('lastSaved', new Date().toISOString()); if (remainingTime <= 1) { clearInterval(interval); location.reload(); } }, 1000); jQuery(window).on('beforeunload', function () { now = new Date(); elapsedTime = (now - start) / 1000; remainingTime = Math.max(duration - elapsedTime, 0); remainingTime = remainingTime % totalSecondsInDay; localStorage.setItem('remainingTime', remainingTime); localStorage.setItem('lastSaved', new Date().toISOString()); }); }); jQuery('