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