vendor: 8,627 bytes, lines 1-217
1/*! 2 * The Final Countdown for jQuery v2.0.4 (http://hilios.github.io/jQuery.countdown/) 3 * Copyright (c) 2014 Edson Hilios 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 * this software and associated documentation files (the "Software"), to deal in 7 * the Software without restriction, including without limitation the rights to 8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 * the Software, and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in all 13 * copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22(function(factory) { 23 "use strict"; 24 if (typeof define === "function" && define.amd) { 25 define([ "jquery" ], factory); 26 } else { 27 factory(jQuery); 28 } 29})(function($) { 30 "use strict"; 31 var PRECISION = 100; 32 var instances = [], matchers = []; 33 matchers.push(/^[0-9]*$/.source); 34 matchers.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source); 35 matchers.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source); 36 matchers = new RegExp(matchers.join("|")); 37 function parseDateString(dateString) { 38 if (dateString instanceof Date) { 39 return dateString; 40 } 41 if (String(dateString).match(matchers)) { 42 if (String(dateString).match(/^[0-9]*$/)) { 43 dateString = Number(dateString); 44 } 45 if (String(dateString).match(/\-/)) { 46 dateString = String(dateString).replace(/\-/g, "/"); 47 } 48 return new Date(dateString); 49 } else { 50 throw new Error("Couldn't cast `" + dateString + "` to a date object."); 51 } 52 } 53 var DIRECTIVE_KEY_MAP = { 54 Y: "years", 55 m: "months", 56 w: "weeks", 57 d: "days", 58 D: "totalDays", 59 H: "hours", 60 M: "minutes", 61 S: "seconds" 62 }; 63 function escapedRegExp(str) { 64 var sanitize = str.toString().replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); 65 return new RegExp(sanitize); 66 } 67 function strftime(offsetObject) { 68 return function(format) { 69 var directives = format.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi); 70 if (directives) { 71 for (var i = 0, len = directives.length; i < len; ++i) { 72 var directive = directives[i].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/), regexp = escapedRegExp(directive[0]), modifier = directive[1] || "", plural = directive[3] || "", value = null; 73 directive = directive[2]; 74 if (DIRECTIVE_KEY_MAP.hasOwnProperty(directive)) { 75 value = DIRECTIVE_KEY_MAP[directive]; 76 value = Number(offsetObject[value]); 77 } 78 if (value !== null) { 79 if (modifier === "!") { 80 value = pluralize(plural, value); 81 } 82 if (modifier === "") { 83 if (value < 10) { 84 value = "0" + value.toString(); 85 } 86 } 87 format = format.replace(regexp, value.toString()); 88 } 89 } 90 } 91 format = format.replace(/%%/, "%"); 92 return format; 93 }; 94 } 95 function pluralize(format, count) { 96 var plural = "s", singular = ""; 97 if (format) { 98 format = format.replace(/(:|;|\s)/gi, "").split(/\,/); 99 if (format.length === 1) { 100 plural = format[0]; 101 } else { 102 singular = format[0]; 103 plural = format[1]; 104 } 105 } 106 if (Math.abs(count) === 1) { 107 return singular; 108 } else { 109 return plural; 110 } 111 } 112 var Countdown = function(el, finalDate, callback) { 113 this.el = el; 114 this.$el = $(el); 115 this.interval = null; 116 this.offset = {}; 117 this.instanceNumber = instances.length; 118 instances.push(this); 119 this.$el.data("countdown-instance", this.instanceNumber); 120 if (callback) { 121 this.$el.on("update.countdown", callback); 122 this.$el.on("stoped.countdown", callback); 123 this.$el.on("finish.countdown", callback); 124 } 125 this.setFinalDate(finalDate); 126 this.start(); 127 }; 128 $.extend(Countdown.prototype, { 129 start: function() { 130 if (this.interval !== null) { 131 clearInterval(this.interval); 132 } 133 var self = this; 134 this.update(); 135 this.interval = setInterval(function() { 136 self.update.call(self); 137 }, PRECISION); 138 }, 139 stop: function() { 140 clearInterval(this.interval); 141 this.interval = null; 142 this.dispatchEvent("stoped"); 143 }, 144 toggle: function() { 145 if (this.interval) { 146 this.stop(); 147 } else { 148 this.start(); 149 } 150 }, 151 pause: function() { 152 this.stop(); 153 }, 154 resume: function() { 155 this.start(); 156 }, 157 remove: function() { 158 this.stop.call(this); 159 instances[this.instanceNumber] = null; 160 delete this.$el.data().countdownInstance; 161 }, 162 setFinalDate: function(value) { 163 this.finalDate = parseDateString(value); 164 }, 165 update: function() { 166 if (this.$el.closest("html").length === 0) { 167 this.remove(); 168 return; 169 } 170 this.totalSecsLeft = this.finalDate.getTime() - new Date().getTime(); 171 this.totalSecsLeft = Math.ceil(this.totalSecsLeft / 1e3); 172 this.totalSecsLeft = this.totalSecsLeft < 0 ? 0 : this.totalSecsLeft; 173 this.offset = { 174 seconds: this.totalSecsLeft % 60, 175 minutes: Math.floor(this.totalSecsLeft / 60) % 60, 176 hours: Math.floor(this.totalSecsLeft / 60 / 60) % 24, 177 days: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7, 178 totalDays: Math.floor(this.totalSecsLeft / 60 / 60 / 24), 179 weeks: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7), 180 months: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 30), 181 years: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 365) 182 }; 183 if (this.totalSecsLeft === 0) { 184 this.stop(); 185 this.dispatchEvent("finish"); 186 } else { 187 this.dispatchEvent("update"); 188 } 189 }, 190 dispatchEvent: function(eventName) { 191 var event = $.Event(eventName + ".countdown"); 192 event.finalDate = this.finalDate; 193 event.offset = $.extend({}, this.offset); 194 event.strftime = strftime(this.offset); 195 this.$el.trigger(event); 196 } 197 }); 198 $.fn.countdown = function() { 199 var argumentsArray = Array.prototype.slice.call(arguments, 0); 200 return this.each(function() { 201 var instanceNumber = $(this).data("countdown-instance"); 202 if (instanceNumber !== undefined) { 203 var instance = instances[instanceNumber], method = argumentsArray[0]; 204 if (Countdown.prototype.hasOwnProperty(method)) { 205 instance[method].apply(instance, argumentsArray.slice(1)); 206 } else if (String(method).match(/^[$A-Z_][0-9A-Z_$]*$/i) === null) { 207 instance.setFinalDate.call(instance, method); 208 instance.start(); 209 } else { 210 $.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi, method)); 211 } 212 } else { 213 new Countdown(this, argumentsArray[0], argumentsArray[1]); 214 } 215 }); 216 }; 217});
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.