1// loadScript: returns a promise that completes when the script loads 2window.loadScript = function (scriptPath) { 3 // check list - if already loaded we can ignore 4 if (loaded[scriptPath]) { 5 //console.log(scriptPath + " already loaded"); 6 // return 'empty' promise 7 return new this.Promise(function (resolve, reject) { 8 resolve(); 9 }); 10 } 11 12 return new Promise(function (resolve, reject) { 13 // create JS library script element 14 var script = document.createElement("script"); 15 16 if (scriptPath === "https://www.google.com/recaptcha/api.js") { 17 script.src = scriptPath + "?render=explicit"; 18 } 19 20 21 script.async = true; 22 script.defer = true; 23 24 25 script.src = scriptPath; 26 script.type = "text/javascript"; 27 28 // console.log(scriptPath + " created"); 29 30 // flag as loading/loaded 31 loaded[scriptPath] = true; 32 33 // if the script returns okay, return resolve 34 script.onload = function () { 35 // console.log(scriptPath + " loaded ok"); 36 resolve(scriptPath); 37 }; 38 39 // if it fails, return reject 40 script.onerror = function () { 41 // console.log(scriptPath + " load failed"); 42 reject(scriptPath); 43 } 44 45 // scripts will load at end of body 46 document["body"].appendChild(script); 47 }); 48} 49// store list of what scripts we've loaded 50loaded = [];
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.