1/* SAGE Website Custom Routines */ 2/* Copyright 2019 Quick Technologies Inc. All rights reserved. */ 3 4function GetRequestFromService(URL) 5{ 6 var retString; 7 8 $.ajax({ 9 type: "GET", 10 url: URL, 11 data: "", 12 async:false, 13 success: function(data, textStatus, jqXHR) 14 { 15 retString=data; 16 }, 17 error: function(jqXHR, textStatus, errorThrown) 18 { 19 alert('There was a problem connecting to the service.'); 20 retString=""; 21 } 22 }); 23 return retString; 24} 25 26function GetFromServiceAsyncWithCallback(URL, Params, Callback, ErrorCallback) 27{ 28 $.ajax({ 29 type: "GET", 30 url: URL, 31 data: Params, 32 async:true, // don't wait 33 success: function(data, textStatus, jqXHR) 34 { 35 Callback(data); 36 }, 37 error: function(jqXHR, textStatus, errorThrown) 38 { 39 ErrorCallback(textStatus); 40 } 41 }); 42} 43 44function PostToServiceAsync(URL, Params) 45{ 46 var ok; 47 48 $.ajax({ 49 type: "POST", 50 url: URL, 51 data: Params, 52 async:true 53 }); 54 return(true); 55} 56 57function PostToServiceAsyncCallback(URL, Params, Callback) 58{ 59 var ok; 60 61 $.ajax({ 62 type: "POST", 63 url: URL, 64 data: Params, 65 async:true, 66 success: function(data, textStatus, jqXHR) 67 { 68 Callback(data); 69 }, 70 error: function(jqXHR, textStatus, errorThrown) 71 { 72 alert('There was a problem connecting to the service.'); 73 } 74 }); 75} 76 77function PostToService(URL, Params) 78{ 79 var ok; 80 var ResponseRec; 81 82 $.ajax({ 83 type: "POST", 84 url: URL, 85 data: Params, 86 async:false, // wait for it to finish 87 success: function(response) { 88 ResponseRec=response.split("\t"); 89 ok=ResponseRec[0]=='1'; 90 if (!ok) { 91 alert(ResponseRec[1]); 92 } 93 } 94 }); 95 return(ok); 96} 97 98function PostToServiceWithResponse(URL, Params) 99{ 100 // This includes the full response back 101 var r; 102 103 $.ajax({ 104 type: "POST", 105 url: URL, 106 data: Params, 107 async:false, // wait for it to finish 108 success: function(response) { 109 r=response; 110 }, 111 error: function(jqXHR, textStatus, errorThrown) 112 { 113 alert('There was a problem connecting to the service.'); 114 r=""; 115 } 116 }); 117 return(r); 118} 119 120function SubmitFormViaAjax(e,formElement,callbackfunction) 121{ 122 var formObj = $(formElement); 123 var formURL = formObj.attr("action"); 124 125 if(window.FormData !== undefined) // for HTML5 browsers 126 { 127 var formData = new FormData(formElement); 128 // FormData object returns multipart form data always. If the form is urlencoded, then we need to convert it here 129 if (formElement.enctype=='application/x-www-form-urlencoded') { 130 formData=formObj.serialize(); 131 } 132 133 $.ajax({
134 url: formURL, 135 type: 'POST', 136 data: formData, 137 mimeType:formElement.enctype, 138 contentType: false, 139 cache: false, 140 processData:false, 141 async:true, 142 success: function(data, textStatus, jqXHR) 143 { 144 callbackfunction(data); 145 }, 146 error: function(jqXHR, textStatus, errorThrown) 147 { 148 alert('There was a problem connecting to the service.'); 149 } 150 }); 151 e.preventDefault(); 152 } 153 else //for older browsers 154 { 155 //generate a random id 156 var iframeId = 'unique' + (new Date().getTime()); 157 158 //create an empty iframe 159 var iframe = $('<iframe src="javascript:false;" name="'+iframeId+'" />'); 160 161 //hide it 162 iframe.hide(); 163 164 //set form target to iframe 165 formObj.attr('target',iframeId); 166 167 //Add iframe to body 168 iframe.appendTo('body'); 169 iframe.load(function(e) 170 { 171 var doc = getDoc(iframe[0]); 172 var docRoot = doc.body ? doc.body : doc.documentElement; 173 var data = docRoot.innerHTML; 174 //data is returned from server. 175 ok=true; 176 ResponseData=data; 177 }); 178 179 } 180 181} 182 183
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.