1/* eslint-disable no-undef */ 2 3UNOUNO = window.UNOUNO || {}; 4UNOUNO.params = UNOUNO.params || {}; 5UNOUNO.utils = UNOUNO.utils || {}; 6 7UNOUNO.utils.Queue = function () { 8 this.__queue = []; 9 10 // eslint-disable-next-line @typescript-eslint/no-empty-function 11 this.__noop = function () {}; 12 13 this.push = function () { 14 if (this.__queue == null) { 15 throw new Error('QUEUE_ILLEGAL_STATE'); 16 } 17 18 // eslint-disable-next-line prefer-rest-params 19 const args = Array.prototype.slice.call(arguments); 20 const fn = args.shift(); 21 let options = {}; 22 23 if (typeof args[0] === 'object') { 24 options = args.shift(); 25 } 26 27 if (typeof fn === 'function') { 28 this.__queue.push({ 29 fn: fn, 30 options: options, 31 args: args || [], 32 }); 33 } 34 }; 35 36 this.getQueue = function () { 37 return this.__queue; 38 }; 39 40 this.run = function () { 41 if (!(this.__queue instanceof Array)) { 42 return; 43 } 44 45 // eslint-disable-next-line prefer-rest-params 46 const args = Array.prototype.slice.call(arguments); 47 let done = this.__noop; 48 let options = { 49 flushOnEnd: true, 50 sorted: false, 51 }; 52 53 if (typeof args[0] === 'function') { 54 done = args.shift(); 55 } 56 57 if (typeof args[0] === 'object') { 58 options = args.shift(); 59 } 60 61 if (typeof options.bail !== 'boolean') { 62 options.bail = !1; 63 } 64 65 if (typeof options.prerequisitesMet !== 'function') { 66 options.prerequisitesMet = function () { 67 return true; 68 }; 69 } 70 71 if (typeof options.sorted !== 'boolean') { 72 options.sorted = !1; 73 } 74 75 if (!options.sorted) { 76 this.__queue.sort(function (e1, e2) { 77 const p1 = (e1.options || {}).priority || 1; 78 const p2 = (e2.options || {}).priority || 1; 79 80 return p2 - p1; 81 }); 82 } 83 84 const element = this.__queue.shift(); 85 86 if (element) { 87 const callback = function (error) { 88 if (options.bail && error) { 89 return done(error); 90 } 91 92 this.run(done, { 93 sorted: true, 94 }); 95 }.bind(this); 96 97 const timeout = setTimeout(function () { 98 callback(new Error('QUEUE_ELEMENT_TIMEOUT')); 99 }, element.options.timeout || 0); 100 101 element.args.push(function (error) { 102 clearTimeout(timeout); 103 callback(error); 104 }); 105 106 try { 107 element.fn.apply(element.fn, element.args); 108 } catch (e) { 109 callback(e); 110 } 111 112 return; 113 } 114 115 if (options.flushOnEnd) { 116 this.__queue = null; 117 } 118 119 done(); 120 }; 121 122 return this; 123}; 124 125UNOUNO.resource = UNOUNO.resource || {}; 126UNOUNO.resource.loadIFrame = function () { 127 const args = Array.prototype.slice.call(arguments); 128 const attributes = args.shift(); 129 let options = {}; 130 let callback = function () {}; 131 132 if (typeof args[0] === 'object') { 133 options = args.shift(); 134 } 135 136 if (typeof args[0] === 'function') { 137 callback = args.shift(); 138 } 139 140 const iframe = document.createElement('iframe'); 141 142 for (const name in attributes) { 143 iframe.setAttribute(name, attributes[name]); 144 } 145 146 document.body.appendChild(iframe); 147 148 iframe.addEventListener('load', function () { 149 iframeReady(); 150 }); 151 152 const iframeTimeout = window.setTimeout(function () { 153 iframe.removeEventListener('load', iframeReady); 154 document.body.removeChild(iframe); 155 callback(new Error('IFRAME_TIMEOUT')); 156 }, options.timeout || 2500); 157 158 var iframeReady = function () { 159 clearTimeout(iframeTimeout); 160 iframe.removeEventListener('load', iframeReady); 161 callback(); 162 }; 163}; 164 165UNOUNO.resource.loadResource = function () { 166 const args = Array.prototype.slice.call(arguments); 167 let element = args.shift(); 168 var attr = args.shift(); 169 let options = {}; 170 let callback = function () {}; 171 172 if (typeof args[0] === 'object') { 173 options = args.shift(); 174 } 175 176 if (typeof args[0] === 'function') { 177 callback = args.shift(); 178 } 179 180 if ('attributes' in options) { 181 const attrs = options.attributes; 182 183 for (var attr in attrs) { 184 element[attr] = attrs[attr]; 185 } 186 } 187 188 let async = options.async; 189 let defer = options.defer; 190 let execute = options.execute; 191 192 if (typeof async !== 'boolean') { 193 async = !0; 194 } 195 196 if (typeof defer !== 'boolean') { 197 defer = !0; 198 } 199 200 if (typeof execute !== 'boolean') { 201 execute = !0; 202 } 203 204 var domReady = function (done) { 205 if (document.head) { 206 return done(); 207 } 208 209 setTimeout(function () { 210 domReady(done); 211 }); 212 }; 213 214 const request = 'XMLHttpRequest'; 215 216 const insertElement = function (element) {
217 if (document.getElementById(element.id)) { 218 if (!(!async && !defer && typeof window[request] === 'function')) { 219 callback.apply(callback, args); 220 } 221 return; 222 } 223 const nodeName = element.nodeName; 224 const destination = document.head; 225 226 const elementsOfSameTag = destination.getElementsByTagName(nodeName); 227 const firstElementOfSameTag = (function () { 228 let result = undefined; 229 230 for (let i = 0; i < elementsOfSameTag.length; i++) { 231 if (elementsOfSameTag[i].type === element.type || elementsOfSameTag[i].rel === element.rel) { 232 result = elementsOfSameTag[i]; 233 234 break; 235 } 236 } 237 238 return result; 239 })(); 240 241 if (firstElementOfSameTag) { 242 destination.insertBefore(element, firstElementOfSameTag); 243 } else { 244 destination.appendChild(element); 245 } 246 }; 247 248 if (!async && !defer && typeof window[request] === 'function') { 249 const location = element[attr]; 250 element.removeAttribute(attr); 251 252 const xhr = new window[request](); 253 xhr.open('GET', location, false); 254 xhr.onload = function () { 255 if (xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 400) { 256 let method = 'text'; 257 258 if (element.nodeName === 'LINK') { 259 element = document.createElement('style'); 260 element.type = 'text/css'; 261 262 method = 'innerHTML'; 263 } else if (element.nodeName === 'SCRIPT' && execute === true) { 264 eval(xhr.responseText); 265 266 return callback.apply(callback, args); 267 } 268 269 element[method] = xhr.responseText; 270 element.setAttribute('data-src', location.substring(window.location.origin.length)); 271 272 domReady(function () { 273 insertElement(element); 274 275 callback.apply(callback, args); 276 }); 277 } 278 }; 279 280 return xhr.send(); 281 } 282 283 let ready = !1; 284 285 element.onload = element.onreadystatechange = function () { 286 if (!ready && (!this.readyState || this.readyState == 'complete')) { 287 ready = !0; 288 289 callback.apply(callback, args); 290 } 291 }; 292 293 domReady(function () { 294 insertElement(element); 295 }); 296}; 297 298UNOUNO.resource.loadCSS = function () { 299 const args = Array.prototype.slice.call(arguments); 300 const href = args.shift(); 301 let options = {}; 302 let callback = function () {}; 303 304 if (typeof args[0] === 'object') { 305 options = args.shift(); 306 } 307 308 if (typeof args[0] === 'function') { 309 callback = args.shift(); 310 } 311 312 let async = options.async; 313 314 if (typeof async !== 'boolean') { 315 async = !0; 316 } 317 318 const stylesheet = document.createElement('link'); 319 320 stylesheet.href = href; 321 stylesheet.type = 'text/css'; 322 stylesheet.media = 'all'; 323 stylesheet.rel = 'stylesheet'; 324 325 UNOUNO.resource.loadResource(stylesheet, 'href', options, function () { 326 callback.apply(callback, args); 327 }); 328}; 329 330UNOUNO.resource.loadJS = function () { 331 const args = Array.prototype.slice.call(arguments); 332 const src = args.shift(); 333 let options = {}; 334 let callback = function () {}; 335 336 if (typeof args[0] === 'object') { 337 options = args.shift(); 338 } 339 340 if (typeof args[0] === 'function') { 341 callback = args.shift(); 342 } 343 344 let async = options.async; 345 let defer = options.defer; 346 347 if (typeof defer !== 'boolean') { 348 defer = !0; 349 } 350 351 if (typeof async !== 'boolean') { 352 async = !0; 353 } 354 355 const script = document.createElement('script'); 356 script.type = 'text/javascript'; 357 script.src = src; 358 359 if (async) { 360 script.async = !0; 361 } 362 363 if (defer) { 364 script.defer = !0; 365 } 366 367 UNOUNO.resource.loadResource(script, 'src', options, function () { 368 callback.apply(callback, args); 369 }); 370}; 371 372UNOUNO.tracking = UNOUNO.tracking || {}; 373 374UNOUNO.onload = UNOUNO.onload || {}; 375UNOUNO.onload.queue = new UNOUNO.utils.Queue();
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.