1/** 2 * Shortcode Countdown 3 * 4 * @package ThemeREX Addons 5 * @since v1.4.3 6 */ 7 8/* global jQuery, TRX_ADDONS_STORAGE */ 9 10// Countdown init 11jQuery(document).on( 'action.init_hidden_elements', function(e, container) { 12 13 "use strict"; 14 15 if (container === undefined) container = jQuery('body'); 16 17 container.find('.sc_countdown:not(.inited)').each(function () { 18 var $self = jQuery(this).addClass('inited'), 19 id = $self.attr('id'), 20 interval = 1, //$self.data('interval'), 21 countDate = false, 22 countTo = $self.data('count-to') > 0, 23 countRestart = $self.data('count-restart') > 0, 24 endDateStr = '' + $self.data('date'), 25 endDateParts = endDateStr.split('-'), 26 endTimeStr = '' + $self.data('time'), 27 endTimeParts = endTimeStr.split(':'); 28 29 if (endTimeParts.length < 3) endTimeParts[2] = '00'; 30 31 if ( countRestart ) { 32 var dt = new Date(); 33 countDate = new Date( dt.getTime() + ( endDateParts[0] * 3600 * 24 + endTimeParts[0] * 3600 + endTimeParts[1] * 60 + endTimeParts[2] * 1 ) * 1000 * ( countTo ? 1 : -1 ) ); 34 } else { 35 countDate = new Date(endDateParts[0], endDateParts[1]-1, endDateParts[2], endTimeParts[0], endTimeParts[1], endTimeParts[2]); 36 } 37 38 var countInit = { 39 tickInterval: interval, 40 onTick: trx_addons_sc_countdown, 41 alwaysExpire: true, 42 onExpiry: function() { 43 trx_addons_sc_countdown([0,0,0,0,0,0]); 44 } 45 }; 46 if ( countTo ) { 47 countInit.until = countDate; 48 } else { 49 countInit.since = countDate; 50 } 51 $self.find('.sc_countdown_placeholder').countdown( countInit ); 52 }); 53 54 // Countdown update 55 function trx_addons_sc_countdown(dt) { 56 var counter = jQuery(this).parent(); 57 for (var i=3; i < dt.length; i++) { 58 var v = (dt[i]<10 ? '0' : '') + dt[i]; 59 var item = counter.find('.sc_countdown_item').eq(i-3); 60 var digits = item.find('.sc_countdown_digits span').addClass('hide'); 61 for (var ch=v.length-1; ch >= 0; ch--) { 62 digits.eq(ch + (i==3 && v.length<3 ? 1 : 0)).removeClass('hide').text(v.substr(ch, 1)); 63 } 64 trx_addons_draw_arc_on_canvas(item, dt[i]); 65 } 66 } 67 68} );
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.