1var viewing_room = { 2 3 init: function() { 4 window.galleries.viewing_room.countdown_clock(); 5 }, 6 7 countdown_clock: function() { 8 9 $('.countdown_clock').each(function() { 10 11 var $this = $(this); 12 13 // Set the date we're counting down to 14 var start_date = $(this).attr('data-target-time'); 15 var countDownDate = new Date(start_date.replace(/-/g,"/")).getTime(); 16 17 // Clock is active 18 if (!$this.closest('.countdown_clock').hasClass('active')) { 19 $this.closest('.countdown_clock').addClass('active'); 20 } 21 22 // Set clock on first load 23 $this.html(window.galleries.viewing_room.update_clock_html(countDownDate)); 24 25 if (window.location.hash && window.location.hash == '#pausecountdown') { 26 27 } else { 28 // Update the countdown every 1 second 29 setInterval(function() { 30 $this.html(window.galleries.viewing_room.update_clock_html(countDownDate)); 31 }, 1000); 32 } 33 34 }); 35 36 }, 37 38 update_clock_html: function(countDownDate) { 39 40 var clock_format = 'full'; 41 42 // Get today's date and time 43 //var now = new Date().getTime(); 44 // Get in UTC 45 var d =new Date(); 46 var timezone_offset = d.getTimezoneOffset(); 47 // Reverse timezone offset for the calculation below 48 var timezone_offset = timezone_offset - (timezone_offset * 2) 49 // Get current time adjusted to UTC 50 var now = d.getTime() - (timezone_offset * 1000 * 60); 51 52 // Find the distance between now and the count down date 53 var distance = countDownDate - now; 54 55 var _html_ = ''; 56 57 58 if (distance <= 0) { 59 _html_ = '' 60 $('.countdown_container').each(function() { 61 $(this).find('.countdown_text').text(''); 62 if ($(this).hasClass('countdown_reload_on_completion')) { 63 // window.location.reload(); 64 } else { 65 if ($(this).hasClass('show_message_on_zero')) { 66 $(this).find('.countdown').remove(); 67 $(this).find('.countdown_label_on_zero').removeClass('hidden'); 68 $('body').addClass('countdown-clock-status-zero'); 69 } else { 70 $(this).remove(); 71 } 72 } 73 }); 74 } else { 75 76 if (clock_format == 'days') { 77 // Time calculations for days, hours, minutes and seconds 78 var days = Math.ceil(distance / (1000 * 60 * 60 * 24)); 79 _html_ += (days != 0 ? '<span class="numeral">'+ days+ '</span>' : ''); 80 _html_ += (days != 0 ? ' <span class="countdown_text">'+ (days > 1 ? 'days' : 'day') + '</span>' : ''); 81 82 } else if (clock_format == 'full') { 83 // Time calculations for days, hours, minutes and seconds 84 var days = Math.floor(distance / (1000 * 60 * 60 * 24)); 85 var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 86 var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); 87 var seconds = Math.floor((distance % (1000 * 60)) / 1000); 88 _html_ += ('<span class="segment' + (days == 0 ? ' segment-expired' : '') + '"><span class="numeral">'+ days+ '</span><span class="period">Days</span></span><span class="segment-divide' + (days == 0 ? ' segment-divide-expired' : '') + '">:</span>' || ''); 89 _html_ += ('<span class="segment' + (days == 0 && hours == 0 ? ' segment-expired' : '') + '"><span class="numeral">'+ hours+ '</span><span class="period">Hours</span></span><span class="segment-divide' + (days == 0 && hours == 0 ? ' segment-divide-expired' : '') + '">:</span>' || '');
90 _html_ += ('<span class="segment' + (days == 0 && hours == 0 && minutes == 0 ? ' segment-expired' : '') + '"><span class="numeral">'+ minutes+ '</span><span class="period">Mins</span></span><span class="segment-divide' + (days == 0 && hours == 0 && minutes == 0 ? ' segment-divide-expired' : '') + '">:</span>' || ''); 91 _html_ += '<span class="segment' + (days == 0 && hours == 0 && minutes == 0 && seconds == 0 ? ' segment-expired' : '') + '"><span class="numeral">'+ seconds+ '</span><span class="period">Secs</span></span>'; 92 } 93 94 } 95 96 return _html_; 97 98 } 99 100} 101 102window.galleries = window.galleries || {}; 103window.galleries.viewing_room = viewing_room; 104export default viewing_room;
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.