1"use strict"; 2 3var events = { 4 'abort': 'abort', 5 'animationcancel': 'animationcancel', 6 'animationend': 'animationend', 7 'animationiteration': 'animationiteration', 8 'animationstart': 'animationstart', 9 'auxclick': 'auxclick', 10 'blur': 'blur', 11 'cancel': 'cancel', 12 'canplay': 'canplay', 13 'canplaythrough': 'canplaythrough', 14 'change': 'change', 15 'click': 'click', 16 'close': 'close', 17 'contextmenu': 'contextmenu', 18 'cuechange': 'cuechange', 19 'dblclick': 'dblclick', 20 'drag': 'drag', 21 'dragend': 'dragend', 22 'dragenter': 'dragenter', 23 'dragexit': 'dragexit', 24 'dragleave': 'dragleave', 25 'dragover': 'dragover', 26 'dragstart': 'dragstart', 27 'drop': 'drop', 28 'durationchange': 'durationchange', 29 'emptied': 'emptied', 30 'ended': 'ended', 31 'error': 'error', 32 'focus': 'focus', 33 'focusin': 'focusin', 34 'focusout': 'focusout', 35 'gotpointercapture': 'gotpointercapture', 36 'input': 'input', 37 'invalid': 'invalid', 38 'keydown': 'keydown', 39 'keypress': 'keypress', 40 'keyup': 'keyup', 41 'load': 'load', 42 'loadeddata': 'loadeddata', 43 'loadedmetadata': 'loadedmetadata', 44 'loadstart': 'loadstart', 45 'lostpointercapture': 'lostpointercapture', 46 'mousedown': 'mousedown', 47 'mouseenter': 'mouseenter', 48 'mouseleave': 'mouseleave', 49 'mousemove': 'mousemove', 50 'mouseout': 'mouseout', 51 'mouseover': 'mouseover', 52 'mouseup': 'mouseup', 53 'pause': 'pause', 54 'play': 'play', 55 'playing': 'playing', 56 'pointercancel': 'pointercancel', 57 'pointerdown': 'pointerdown', 58 'pointerenter': 'pointerenter', 59 'pointerleave': 'pointerleave', 60 'pointermove': 'pointermove', 61 'pointerout': 'pointerout', 62 'pointerover': 'pointerover', 63 'pointerup': 'pointerup', 64 'progress': 'progress', 65 'ratechange': 'ratechange', 66 'reset': 'reset', 67 'resize': 'resize', 68 'scroll': 'scroll', 69 'securitypolicyviolation': 'securitypolicyviolation', 70 'seeked': 'seeked', 71 'seeking': 'seeking', 72 'select': 'select', 73 'selectionchange': 'selectionchange', 74 'selectstart': 'selectstart', 75 'stalled': 'stalled', 76 'submit': 'submit', 77 'suspend': 'suspend', 78 'timeupdate': 'timeupdate', 79 'toggle': 'toggle', 80 'touchcancel': 'touchcancel', 81 'touchend': 'touchend', 82 'touchmove': 'touchmove', 83 'touchstart': 'touchstart', 84 'transitioncancel': 'transitioncancel', 85 'transitionend': 'transitionend', 86 'transitionrun': 'transitionrun', 87 'transitionstart': 'transitionstart', 88 'volumechange': 'volumechange', 89 'waiting': 'waiting', 90 'wheel': 'wheel' 91}; 92/** 93 * typedef {{string: events}} elementEvent 94 * @typedef {string} elementEvent 95 * @type {events.<string, *>} 96 */ 97 98/** 99 * @callback aelCallback 100 * @param {Event} event 101 */ 102 103/** 104 * @callback eachCallback 105 * @param HTMLElementTagNameMap[*] element 106 * @param {int} i 107 */ 108 109/** 110 * 111 * @callback elementAelCallback 112 * @param {Event} event 113 */ 114 115/** 116 * 117 */ 118 119/** 120 * 121 * @param {eachCallback} callback 122 * @returns {Object} 123 */ 124 125NodeList.prototype.each = function (callback) { 126 var i = 0, 127 length = this.length; 128 129 for (i; i < length; i++) { 130 var element = this[i]; 131 132 if (callback(element, i) === true) { 133 break; 134 } 135 } 136 137 return this; 138}; 139/** 140 * 141 * @param {string} selector 142 * @returns HTMLElementTagNameMap[*] 143 */ 144 145 146window.qs = function (selector) { 147 return document.querySelector(selector); 148}; 149/** 150 * 151 * @param {string} selector 152 * @returns {NodeListOf<HTMLElementTagNameMap[*]>} 153 */ 154 155 156window.qsa = function (selector) { 157 return document.querySelectorAll(selector); 158}; 159/** 160 * 161 * @param {GlobalEventHandlersEventMap.} event 162 * @param {aelCallback} callback 163 */ 164 165 166window.ael = function (event, callback) { 167 document.addEventListener(event, callback); 168}; 169/** 170 * 171 * @param {string} selector 172 * @returns HTMLElementTagNameMap[*] 173 */ 174 175 176Element.prototype.qs = function (selector) { 177 return this.querySelector(selector); 178}; 179/** 180 * 181 * @param {string} selector 182 * @returns {NodeListOf<HTMLElementTagNameMap[*]>} 183 */ 184 185 186Element.prototype.qsa = function (selector) { 187 return this.querySelectorAll(selector); 188}; 189/** 190 * 191 * @param {elementEvent} event 192 * @param {elementAelCallback} callback 193 * @returns HTMLElementTagNameMap[*] 194 */ 195 196 197Element.prototype.ael = function (event, callback) { 198 this.addEventListener(event, callback); 199 return this; 200};
201/** 202 * 203 * @callback nodeListAelCallback 204 * @param event 205 * @param HTMLElementTagNameMap[*] element 206 * @param {int} i 207 */ 208 209/** 210 * 211 * @param event 212 * @param {nodeListAelCallback} callback 213 * @returns NodeList 214 */ 215 216 217NodeList.prototype.ael = function (event, callback) { 218 this.each(function (element, i) { 219 element.ael(event, function (event) { 220 return callback(event, element, i); 221 }); 222 }); 223 return this; 224}; 225/** 226 * 227 * @param {string} name 228 * @param {string|null} value 229 * @returns {string|<HTMLElementTagNameMap[*]>|null} 230 */ 231 232 233Element.prototype.attr = function (name) { 234 var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; 235 if (value === undefined) return this.getAttribute(name) === undefined ? null : this.getAttribute(name); 236 237 if (value === null) { 238 this.removeAttribute(name); 239 return this; 240 } 241 242 this.setAttribute(name, value); 243 return this; 244}; 245/** 246 * 247 * @param {string} name 248 * @returns {boolean} 249 */ 250 251 252Element.prototype.hasAttr = function (name) { 253 return this.hasAttribute(name); 254}; 255/** 256 * 257 * @param {string} name 258 * @param {string|null} value 259 * @param {string} value2 260 * @returns {string|null} 261 */ 262 263 264Element.prototype.toggleAttr = function (name) { 265 var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 266 var value2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; 267 268 if (value2 === undefined) { 269 if (this.hasAttr(name)) { 270 this.attr(name, null); 271 return this; 272 } 273 274 if (value === null) { 275 this.attr(name, name); 276 return this; 277 } 278 279 this.attr(name, value); 280 return this; 281 } 282 283 if (!this.hasAttr(name)) { 284 this.attr(name, value); 285 return this; 286 } 287 288 if (this.attr(name) === value) { 289 this.attr(name, value2); 290 return this; 291 } 292 293 this.attr(name, value); 294 return this; 295}; 296/** 297 * 298 * @param {string} value 299 * @returns HTMLElementTagNameMap[*] 300 */ 301 302 303Element.prototype.addClass = function (value) { 304 this.classList.add(value); 305 return this; 306}; 307/** 308 * 309 * @param {string} value 310 * @returns HTMLElementTagNameMap[*] 311 */ 312 313 314Element.prototype.removeClass = function (value) { 315 this.classList.remove(value); 316 return this; 317}; 318/** 319 * 320 * @param {string} value 321 * @returns HTMLElementTagNameMap[*] 322 */ 323 324 325Element.prototype.hasClass = function (value) { 326 this.classList.contains(value); 327 return this; 328}; 329/** 330 * 331 * @param {string} value 332 * @param {string} value2 333 * @returns HTMLElementTagNameMap[*] 334 */ 335 336 337Element.prototype.toggleClass = function (value) { 338 var value2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; 339 340 if (value2 === undefined) { 341 if (this.classList.contains(value)) { 342 this.classList.remove(value); 343 return this; 344 } 345 346 this.classList.add(value); 347 return this; 348 } 349 350 if (this.classList.contains(value)) { 351 this.classList.remove(value); 352 this.classList.add(value2); 353 return this; 354 } 355 356 this.classList.remove(value2); 357 this.classList.add(value); 358 return this; 359};
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.