1/** 2 * Returns an XMLHttp instance to use for asynchronous 3 * downloading. This method will never throw an exception, but will 4 * return NULL if the browser does not support XmlHttp for any reason. 5 * @return {XMLHttpRequest|Null} 6 */ 7function createXmlHttpRequest() { 8 try { 9 if (typeof ActiveXObject != 'undefined') { 10 return new ActiveXObject('Microsoft.XMLHTTP'); 11 } else if (window["XMLHttpRequest"]) { 12 return new XMLHttpRequest(); 13 } 14 } catch (e) { 15 changeStatus(e); 16 } 17 return null; 18} 19; 20 21 22 23 24 25 26 27 28 29 30/** 31 * This functions wraps XMLHttpRequest open/send function. 32 * It lets you specify a URL and will call the callback if 33 * it gets a status code of 200. 34 * @param {String} url The URL to retrieve 35 * @param {Function} callback The function to call once retrieved. 36 */ 37function downloadUrl(url, callback, asText, async) { 38 39if (async == null) { 40 async = true; //asynchronous true by default 41} 42 43 var status = -1; 44 var request = createXmlHttpRequest(); 45 if (!request) { 46 return false; 47 } 48 49 request.onreadystatechange = function () { 50 if (request.readyState == 4) { 51 try { 52 status = request.status; 53 } catch (e) { 54 //alert(e); - suppress 55 // Usually indicates request timed out in FF. 56 } 57 if (status == 200) { 58 if (asText == true) { 59 callback(request.responseText, request.status); 60 } else { 61 callback(request.responseXML, request.status); 62 } 63 request.onreadystatechange = function () { 64 }; 65 } 66 } 67 } 68 request.open('GET', url, async); //using asynchronous loading 69 try { 70 request.send(null); 71 } catch (e) { 72 //suppress errors 73 //changeStatus(e); 74 } 75} 76; 77 78function downloadScript(url) { 79 var script = document.createElement('script'); 80 script.src = url; 81 document.body.appendChild(script); 82}
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.