1function countdownTimer(moduleId, eventDate, displaySeconds) { 2 const countdownElement = $("#" + moduleId); 3 const daysElement = countdownElement.find('.days'); 4 const daysElementLabel = daysElement.siblings(".label") 5 const hoursElement = countdownElement.find('.hours'); 6 const hoursElementLabel = hoursElement.siblings(".label") 7 const minutesElement = countdownElement.find('.minutes'); 8 const minutesElementLabel = minutesElement.siblings(".label") 9 const secondsElement = countdownElement.find('.seconds'); 10 const secondsElementLabel = secondsElement.siblings(".label") 11 12 const secondsDiv = countdownElement.find('.seconds-item'); 13 let interval; 14 15 function updateCountdown() { 16 const currentDate = new Date().toISOString().slice(0, 19); 17 const now = new Date(currentDate).getTime(); 18 const timeDifference = new Date(eventDate).getTime() - now; 19 20 const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); 21 const hours = Math.floor((timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 22 const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60)); 23 const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000); 24 25 if(timeDifference <= 0){ 26 clearInterval(interval); 27 return; 28 } 29 30 daysElement.text(days); 31 hoursElement.text(hours); 32 minutesElement.text(minutes); 33 secondsElement.text(seconds); 34 35 // lol. Fixing a pet peeve of Lachlan's. 36 secondsElementLabel.text(seconds === 1 ? "SECOND" : "SECONDS"); 37 minutesElementLabel.text(minutes === 1 ? "MINUTE" : "MINUTES"); 38 hoursElementLabel.text(hours === 1 ? "HOUR" : "HOURS"); 39 daysElementLabel.text(days === 1 ? "DAY" : "DAYS"); 40 41 42 if(seconds === 1){ 43 secondsElementLabel.text("SECOND"); 44 } 45 46 if (!displaySeconds) { 47 secondsDiv.hide(); 48 } 49 } 50 51 updateCountdown(); 52 interval = setInterval(updateCountdown, 1000); 53} 54 55$(document).ready(function () { 56 $(".count-down-module").each(function () { 57 const $module = $(this); 58 const moduleId = $module.data("target-div"); 59 const eventDate = $module.data("start-date"); 60 const eventEndDate = $module.data("end-date"); 61 const displaySeconds = $module.data("show-seconds"); 62 63 // Start the clock ticking. 64 countdownTimer(moduleId, eventDate, displaySeconds); 65 66 // Set the intervals for when to use HTMX to refresh the module. 67 const currentDate = new Date().toISOString().slice(0, 19); 68 const now = new Date(currentDate).getTime(); 69 70 const timeStartDifference = new Date(eventDate).getTime() - now; 71 const timeEndDifference = new Date(eventEndDate).getTime() - now; 72 73 // If the event is more than 2**31 milliseconds away, setTimeout can't handle it. 74 // Set the timeout to 25 days away if that's the case. 75 // setTimeout(()=>{htmx.trigger("#" + moduleId, "refreshContent")}, min(timeStartDifference, 2**33));l 76 let max_timeout = 2**31 - 1 77 78 setTimeout(()=>{htmx.trigger("#" + moduleId, "refreshContent")}, Math.min(timeStartDifference, max_timeout )); 79 setTimeout(()=>{htmx.trigger("#" + moduleId, "refreshContent")}, Math.min(timeEndDifference, max_timeout)); 80 81 }); 82});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.