1/* 2 * T- Countdown v2.4.0 3 * http://plugins.twinpictures.de/plugins/t-minus-countdown/ 4 * 5 * Copyright 2018, Twinpictures 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal 9 * in the Software without restriction, including without limitation the rights 10 * to use, copy, modify, merge, publish, distribute, sublicense, blend, trade, 11 * bake, hack, scramble, difiburlate, digest and/or sell copies of the Software, 12 * and to permit persons to whom the Software is furnished to do so, subject to 13 * the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in 16 * all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 * THE SOFTWARE. 25 */ 26 27(function($){
28 $.fn.tminusCountDown = function (options) { 29 if ($(this)[0] == undefined) 30 return; 31 32 config = {}; 33 $.extend(config, options); 34 tminusTargetTime = this.setTminustminusTargetTime(config); 35 $.data($(this)[0], 'tminusTargetTime', tminusTargetTime); 36 37 var nowobj = $.parseJSON( tminusnow ); 38 nowTime = new Date(nowobj.now); 39 40 //ofset from browser time 41 browserTime = new Date(); 42 timeOffset = Math.floor((nowTime.valueOf()-browserTime.valueOf())/1000); 43 $.data($(this)[0], 'timeOffset', timeOffset); 44 45 style = config.style; 46 $.data($(this)[0], 'style', config.style); 47 48 $.data($(this)[0], 'status', 'play'); 49 $.data($(this)[0], 'id', config.id); 50 51 if ( config.event_id ) { 52 $.data($(this)[0], 'event_id', config.event_id); 53 $.ajax({ 54 url: tCountAjax.ajaxurl, 55 type : "post", 56 dataType : "json", 57 data: { 58 action : 'tminusevents', 59 event_id : config.event_id, 60 countdownNonce : tCountAjax.countdownNonce 61 }, 62 success: $.proxy(function( jsonobj ) { 63 $.data($(this)[0], 'eventObj', jsonobj); 64 }, this) 65 }); 66 } 67 68 if( config.launchtarget ) { 69 $.data($(this)[0], 'launchtarget', config.launchtarget); 70 } 71 if (config.onComplete){ 72 $.data($(this)[0], 'callback', config.onComplete); 73 } 74 if (config.hangtime){ 75 $.data($(this)[0], 'hangtime', config.hangtime); 76 } 77 if (config.omitWeeks){ 78 $.data($(this)[0], 'omitWeeks', config.omitWeeks); 79 } 80 $('#' + $(this).attr('id') + ' .' + style + '-digit').html('<div class="tc_top"></div><div class="tc_bottom"></div>'); 81 82 //caculate the initial difference in seconds between now and launch 83 diffSecs = Math.floor((tminusTargetTime.valueOf()-nowTime.valueOf())/1000); 84 //console.log(diffSecs); 85 $(this).doTminusCountDown($(this).attr('id'), diffSecs, 500); 86 87 return this; 88 }; 89 90 $.fn.stopTminusCountDown = function () { 91 $.data(this[0], 'status', 'stop'); 92 }; 93 94 $.fn.startTminusCountDown = function () { 95 $.data(this[0], 'status', 'play'); 96 this.doTminusCountDown($(this).attr('id'),$.data(this[0], 'diffSecs'), 500); 97 }; 98 99 $.fn.setTminustminusTargetTime = function (options) { 100 var tminusTargetTime = new Date(); 101 if (options.targetDate){ 102 tminusTargetTime = new Date(options.targetDate.month + '/' + options.targetDate.day + '/' + options.targetDate.year + ' ' + options.targetDate.hour + ':' + options.targetDate.min + ':' + options.targetDate.sec + (options.targetDate.utc ? ' UTC' : '')); 103 } 104 else if (options.targetOffset){ 105 tminusTargetTime.setFullYear(options.targetOffset.year + tminusTargetTime.getFullYear()); 106 tminusTargetTime.setMonth(options.targetOffset.month + tminusTargetTime.getMonth()); 107 tminusTargetTime.setDate(options.targetOffset.day + tminusTargetTime.getDate()); 108 tminusTargetTime.setHours(options.targetOffset.hour + tminusTargetTime.getHours()); 109 tminusTargetTime.setMinutes(options.targetOffset.min + tminusTargetTime.getMinutes()); 110 tminusTargetTime.setSeconds(options.targetOffset.sec + tminusTargetTime.getSeconds()); 111 } 112 113 return tminusTargetTime; 114 }; 115 116 $.fn.doTminusCountDown = function (id, diffSecs, duration) { 117 $this = $('#' + id); 118 119 if (diffSecs <= 0){ 120 if( $.data($this[0], 'launchtarget') != 'countup' ){ 121 diffSecs = 0; 122 $.data($this[0], 'status', 'stop'); 123 } 124 } 125 secs = Math.abs(diffSecs % 60); 126 mins = Math.floor(Math.abs(diffSecs/60)%60); 127 hours = Math.floor(Math.abs(diffSecs/60/60)%24); 128 if ($.data($this[0], 'omitWeeks') == 'true'){ 129 days = Math.floor(Math.abs(diffSecs/60/60/24)); 130 weeks = 0; 131 } 132 else{ 133 days = Math.floor(Math.abs(diffSecs/60/60/24)%7); 134 weeks = Math.floor(Math.abs(diffSecs/60/60/24/7)); 135 } 136 style = $.data($this[0], 'style'); 137 138 $this.dashTminusChangeTo(id, style + '-seconds_dash', secs, duration ? duration : 500); 139 $this.dashTminusChangeTo(id, style + '-minutes_dash', mins, duration ? duration : 1000); 140 $this.dashTminusChangeTo(id, style + '-hours_dash', hours, duration ? duration : 1000); 141 $this.dashTminusChangeTo(id, style + '-days_dash', days, duration ? duration : 1000); 142 $this.dashTminusChangeTo(id, style + '-days_trip_dash', days, duration ? duration : 1000); 143 $this.dashTminusChangeTo(id, style + '-weeks_dash', weeks, duration ? duration : 1000); 144 $this.dashTminusChangeTo(id, style + '-weeks_trip_dash', weeks, duration ? duration : 1000); 145 146 //why exactly are we doing this? 147 $.data($this[0], 'diffSecs', diffSecs); 148 149 //console.log('update diffSecs to: ', diffSecs); 150 //events 151 if( $.data($this[0], 'event_id') ){ 152 $this.checkEvent(id, diffSecs); 153 } 154 155 if (diffSecs > 0 || $.data($this[0], 'launchtarget') == 'countup'){ 156 if($.data($this[0], 'status') == 'play'){ 157 158 //recaculate diffSecs 159 160 //this is the current browser time, not so good, as we also need an offset 161 nowTime = new Date(); 162 timeOffset = $.data($this[0], 'timeOffset'); 163 nowTime.setSeconds(nowTime.getSeconds() + timeOffset); 164 //console.log('hey dude: ', tminusTargetTime.valueOf(), $.data($this[0], 'tminusTargetTime').valueOf() ); 165 166 diffSecs = Math.floor(($.data($this[0], 'tminusTargetTime').valueOf()-nowTime.valueOf())/1000); 167 168 t = setTimeout( function() { 169 $this.doTminusCountDown(id, diffSecs); 170 } , 1000); 171 } 172 } 173 //cb = $.data($this[0], 'callback') 174 else if ($.data($this[0], 'callback')){ 175 if($.data($this[0], 'hangtime')){ 176 //phone's ringing dude. 177 } 178 $.data($this[0], 'callback')(); 179 } 180 181 }; 182 183 $.fn.dashTminusChangeTo = function(id, dash, n, duration) { 184
185 $this = $('#' + id); 186 style = $.data($this[0], 'style'); 187 188 //console.log('.' + dash + ' .' + style + '-digit'); 189 for (var i=($this.find('.' + dash + ' .' + style + '-digit').length-1); i>=0; i--){ 190 var d = n%10; 191 n = (n - d) / 10; 192 $this.digitTminusChangeTo('#' + $this.attr('id') + ' .' + dash + ' .' + style + '-digit:eq('+i+')', d, duration); 193 } 194 }; 195 196 $.fn.digitTminusChangeTo = function (digit, n, duration) { 197 198 if (!duration){ 199 duration = 500; 200 } 201 202 //check for number translation object 203 /* for example ***** 204 var numTransObj = { 205 0: 'a', 206 1: 'b', 207 2: 'c', 208 3: 'd', 209 4: 'e', 210 5: 'f', 211 6: 'g', 212 7: 'h', 213 8: 'i', 214 9: 'j' 215 }; 216 *******************/ 217 if(typeof numTransObj != "undefined"){ 218 n = numTransObj[n]; 219 } 220 221 if ($(digit + ' div.tc_top').html() != n + ''){ 222 $(digit + ' div.tc_top').css({'display': 'none'}); 223 $(digit + ' div.tc_top').html((n ? n : '0')).stop(true, true, true).slideDown(duration); 224 225 $(digit + ' div.tc_bottom').stop(true, true, true).animate({'height': ''}, duration, function() { 226 $(digit + ' div.tc_bottom').html($(digit + ' div.tc_top').html()); 227 $(digit + ' div.tc_bottom').css({'display': 'block', 'height': ''}); 228 $(digit + ' div.tc_top').hide().slideUp(10); 229 }); 230 } 231 }; 232 233 $.fn.checkEvent = function () { 234 if ( ! $.data( this[0], 'eventObj' ) ) { 235 return; 236 } 237 238 var eventObj = $.data( this[0], 'eventObj' ).tevent; 239 for (var key in eventObj) { 240 if (eventObj[key].hasOwnProperty('tevents_event_time') && eventObj[key]['tevents_event_time'] == $.data( this[0], 'diffSecs' ) ) { 241 //content (even if it's blank) 242 if (eventObj[key].hasOwnProperty('tevents_target_elem') && eventObj[key]['tevents_event_target'] == 'other') { 243 target_elem = eventObj[key]['tevents_target_elem']; 244 } 245 else{ 246 target_elem = '#' + $.data( this[0], 'id' ) + '-' + eventObj[key]['tevents_event_target']; 247 } 248 $(target_elem).html( eventObj[key]['tevents_event_content'] ); 249 250 //function 251 if ( eventObj[key]['tevents_event_function'] ) { 252 var fn = window[ eventObj[key]['tevents_event_function'] ]; 253 if(typeof fn === 'function') { 254 fn(); 255 } 256 } 257 } 258 } 259 } 260 261})(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.