1$(function () { 2 jQuery.fn.dwTimer = function (options) { 3 var options = $.extend( 4 { 5 timerLoop: false, 6 startDate: false, 7 endDate: false 8 }, 9 options 10 ); 11 12 //vars 13 var timeoutID; 14 15 //j vars 16 var $this = this; 17 var $dayContainer = $this.find(".timerDayValue"); 18 var $hourContainer = $this.find(".timerHourValue"); 19 var $minuteContainer = $this.find(".timerMinuteValue"); 20 var $secondContainer = $this.find(".timerSecondValue"); 21 22 //functions 23 var calculateValues = function () { 24 //set vars 25 curDate = new Date(); 26 27 //calculate 28 var remainingDate = new Date(endDate.getTime() - curDate.getTime()); 29 var remainingSecond = Math.floor((remainingDate / 1000) % 60); 30 var remainingMinute = Math.floor((remainingDate / 1000 / 60) % 60); 31 var remainingHour = Math.floor((remainingDate / (1000 * 60 * 60)) % 24); 32 var remainingDay = Math.floor(remainingDate / (1000 * 60 * 60 * 24)); 33 34 //write DOM 35 $dayContainer.text(remainingDay); 36 $hourContainer.text(remainingHour); 37 $minuteContainer.text(remainingMinute); 38 $secondContainer.text(remainingSecond); 39 }; 40 41 // set end time value 42 if (options["timerLoop"] > 0 && options["startDate"] > 0) { 43 //loop mode 44 45 var endDate = new Date(options["startDate"] * 1000); // timestamp msec (php time() * 1000) 46 var curDate = new Date(); 47 48 //set end date form option 49 endDate.setDate(endDate.getDate() + parseInt(options["timerLoop"])); // set tmp endDate 50 51 //loop mode 52 while (endDate.getTime() <= curDate.getTime()) { 53 endDate.setDate(endDate.getDate() + parseInt(options["timerLoop"])); 54 } 55 } else if (options["endDate"] != "") { 56 var endDate = new Date(options["endDate"] * 1000); // timestamp msec (php time() * 1000) 57 var curDate = new Date(); 58 } 59 60 timeoutID = setInterval(function () { 61 calculateValues(); 62 }, 1000); 63 64 //start timer 65 calculateValues(); 66 }; 67});
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.