1(function ($) { 2 'use strict'; 3 var Countdown = function ($countdown, endTime, $) { 4 var timeInterval, 5 elements = { 6 $daysSpan: $countdown.find('.countdown-days'), 7 $hoursSpan: $countdown.find('.countdown-hours'), 8 $minutesSpan: $countdown.find('.countdown-minutes'), 9 $secondsSpan: $countdown.find('.countdown-seconds') 10 }; 11 12 var updateClock = function () { 13 var timeRemaining = Countdown.getTimeRemaining(endTime); 14 15 $.each(timeRemaining.parts, function (timePart) { 16 var $element = elements['$' + timePart + 'Span'], 17 partValue = this.toString(); 18 19 if (1 === partValue.length) { 20 partValue = 0 + partValue; 21 } 22 23 if ($element.length) { 24 $element.text(partValue); 25 } 26 }); 27 28 if (timeRemaining.total <= 0) { 29 clearInterval(timeInterval); 30 } 31 }; 32 33 var initializeClock = function () { 34 updateClock(); 35 36 timeInterval = setInterval(updateClock, 1000); 37 }; 38 39 initializeClock(); 40 }; 41 Countdown.getTimeRemaining = function (endTime) { 42 var timeRemaining = endTime - new Date(), 43 seconds = Math.floor((timeRemaining / 1000) % 60), 44 minutes = Math.floor((timeRemaining / 1000 / 60) % 60), 45 hours = Math.floor((timeRemaining / (1000 * 60 * 60)) % 24), 46 days = Math.floor(timeRemaining / (1000 * 60 * 60 * 24)); 47 48 if (days < 0 || hours < 0 || minutes < 0) { 49 seconds = minutes = hours = days = 0; 50 } 51 52 return { 53 total: timeRemaining, 54 parts: { 55 days: days, 56 hours: hours, 57 minutes: minutes, 58 seconds: seconds 59 } 60 }; 61 }; 62 var $element = $('[data-countdown="true"]'); 63 $element.each(function (index, el) { 64 var date = new Date($(this).data('date') * 1000); 65 new Countdown($(this), date, $); 66 }); 67 68})(jQuery);
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.