1(function (window, document) { 2 'use strict'; 3 4 if (window.EcoproUploaderApiLoader) { 5 return; 6 } 7 8 var uploaderAsset = '/_res/plani_api/uploader.js'; 9 var state = { 10 loading: false, 11 failed: false, 12 callbacks: [] 13 }; 14 15 function api() { 16 return window.jQuery && window.jQuery.api && window.jQuery.api.uploader; 17 } 18 19 function notify(callbacks, error) { 20 var index; 21 22 for (index = 0; index < callbacks.length; index++) { 23 try { 24 callbacks[index](error); 25 } catch (ignored) { 26 } 27 } 28 } 29 30 function ensure(callback) { 31 var script; 32 var parent; 33 var callbacks; 34 var finished = false; 35 36 if (typeof callback !== 'function') { 37 return; 38 } 39 40 if (typeof api() === 'function') { 41 callback(null); 42 return; 43 } 44 45 if (state.failed) { 46 callback(new Error('uploader asset failed to load')); 47 return; 48 } 49 50 if (state.loading) { 51 state.callbacks.push(callback); 52 return; 53 } 54 55 state.loading = true; 56 state.callbacks.push(callback); 57 script = document.createElement('script'); 58 script.type = 'text/javascript'; 59 script.async = false; 60 script.src = uploaderAsset; 61 script.onload = script.onreadystatechange = function () { 62 if (script.readyState && script.readyState !== 'loaded' && script.readyState !== 'complete') { 63 return; 64 } 65 finish(typeof api() === 'function' ? null : new Error('uploader API was not registered')); 66 }; 67 script.onerror = function () { 68 finish(new Error('uploader asset failed to load')); 69 }; 70 parent = document.head || document.getElementsByTagName('head')[0] || document.documentElement; 71 parent.appendChild(script); 72 73 function finish(error) { 74 if (finished) { 75 return; 76 } 77 78 finished = true; 79 state.loading = false; 80 if (error) { 81 state.failed = true; 82 } 83 callbacks = state.callbacks; 84 state.callbacks = []; 85 notify(callbacks, error); 86 } 87 } 88 89 window.EcoproUploaderApiLoader = { 90 ensure: ensure 91 }; 92}(window, document));
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.