1//<script language="JavaScript" src="xmlhttprequest.js"></script> 2 //<script language="JavaScript"> 3/*--------------------------------------------------------------------------- 4/ © Copyright 2001 Pentamation Enterprises, Inc., All Rights Reserved. 5/ This program is PROPRIETARY and CONFIDENTIAL information of Pentamation 6/ Enterprises, Inc., and may not be disclosed or used except as expressly 7/ authorized in a license agreement controlling such use and disclosure. 8/ Unauthorized use of this program will result in legal proceedings, civil 9/ damages, and possible criminal prosecution. 10/---------------------------------------------------------------------------- 11/ System Name: WebSMS 12/---------------------------------------------------------------------------- 13/ Page Name: ValidCommon.js 14/---------------------------------------------------------------------------- 15/ Page Description: Contains client side common functions used for validation 16/---------------------------------------------------------------------------- 17/ REV # DATE BY COMMENTS 18/ 1.0.000 02/09/2000 TMH Initial write. 19/--------------------------------------------------------------------------*/ 20 21// Method: BuildRequestDOM 22// Description: This method takes an object, and for each property of the 23// object, creates a node in an XMLDOM object. 24// Parameters: pobjParams. An object whose properties are parameters to an ASP page. 25// Return Value: XMLDOM Object 26 27// document.prototype.loadXML2 = function(str) { 28// var aDOMParser = new DOMParser(); 29// var DOMDocumnt = aDOMParser.parseFromString(str,"text/xml"); 30// return DOMDocumnt; 31//} 32 33function BuildRequestDOM(pobjParams) 34{ 35 var domParams; 36 var objParam; 37 var strXML; 38 var intCtr; 39 var strEncodedValue; 40 41 strXML = "<DATA>"; 42 for (objParam in pobjParams) { 43 44 strEncodedValue = pobjParams[objParam]; 45 strEncodedValue = strEncodedValue.replace(/&/g, "&"); 46 strEncodedValue = strEncodedValue.replace(/</g, "<"); 47 strEncodedValue = strEncodedValue.replace(/>/g, ">"); 48 strEncodedValue = strEncodedValue.replace(/"/g, """); 49 strEncodedValue = strEncodedValue.replace(/'/g, "'"); 50 strXML += "<" + objParam.toUpperCase() + ">" + 51 strEncodedValue + "</" + 52 objParam.toUpperCase() + ">"; 53 } // End-For: each key 54 strXML += "</DATA>"; 55 if (document.implementation && document.implementation.createDocument && !(window.opera)){ 56 domParams = document.implementation.createDocument("","doc",null); 57 var aDOMParser = new DOMParser(); 58 var DOMDocumnt = aDOMParser.parseFromString(strXML,"text/xml"); 59 domParams.load(DOMDocumnt); 60 } 61 else if (window.ActiveXObject) { 62 domParams = new ActiveXObject("Microsoft.XMLDOM"); 63 domParams.async = false; 64 domParams.loadXML(strXML); 65 } 66 return domParams 67} 68 69// Method: BuildXMLErrorDoc 70// Description: This method takes a string and builds an XML document from it. 71// Parameters: pstrError. Text to be displayed as the error message. 72// Return Value: XMLDOM Object 73function BuildXMLErrorDoc(pstrError) 74{ 75 var domReturn; 76 // Create an XMLDOM object 77 78 if (document.implementation && document.implementation.createDocument) 79 { var domParams= document.implementation.createDocument("","doc",null); 80 domReturn.load("<error>" + pstrError + "</error>"); 81 } 82 else if (window.ActiveXObject) { 83 domReturn = new ActiveXObject("Microsoft.XMLDOM"); 84 domReturn.async = false; 85 // Create an entry for the error string 86 domReturn.loadXML("<error>" + pstrError + "</error>"); 87 } 88 89 // return the object 90 return domReturn; 91} 92 93// Method: RequestValidation 94// Description: This method opens a connection to the server and sends an XML 95// document object as parameters to the given page. It expects an 96// XML DOM Object returned. 97// Parameters: pobjParams. An object containing the parameters for the page 98// pstrURL. The URL of the validation page to be opened. This method 99// will add the 'http://{server}/{Package}/content' to the URL given. 100// Return Value: XMLDOM Object 101function RequestValidation(pobjParams,pstrURL,pValue) 102{ 103 var domParams; 104 var domReturnValue; 105 var objRequest; 106 var strCommand; 107 var strBase; 108 var regContent = /.*\/content/i; 109 var winOut; 110 domReturnValue = ""; 111 // Retrieve the current URL 112 strCommand = location.href; 113 // Strip off anything after /content 114 strCommand = strCommand.match(regContent); 115 strBase = strCommand; 116
117 // If the remaning string is not 'null' 118 if (!(strCommand == "null")) { 119 // Determine if URL was passed in 120 if (pstrURL == null) { 121 // Use standard URL 122 strCommand += "/common/FieldValidation.asp"; 123 } else { 124 // Use passed in URL 125 strCommand = pstrURL; //AJP test 126 } 127 // Build Parameters XML DOM object 128 domParams = BuildRequestDOM(pobjParams); 129 130 // Check if an error occured parsing the parameters object 131 if (1==1) { 132 //AJPif (domParams.parseError.errorCode == 0) { < fix this 133 // Create an XML Request object, Open a connection to server, and send parameters 134 135 136 if (document.implementation && document.implementation.createDocument){ 137 objRequest = new XMLHttpRequest(); 138 if (objRequest) { 139 objRequest.open("POST",strCommand,false); 140 if (!(window.opera)){ 141 objRequest.setRequestHeader('Content-Type', 'text/xml'); 142 } 143 objRequest.send("<DATA><DENY>" + pValue + "</DENY></DATA>"); 144 if (objRequest.responseText == "") 145 { 146 domReturnValue = "NOTHING"; 147 } 148 else 149 { 150 domReturnValue = objRequest.responseText; 151 } 152 } 153 }else if (window.ActiveXObject) { 154 objRequest = new ActiveXObject("Microsoft.XMLHTTP"); 155 objRequest.open("POST",strCommand,false); 156 objRequest.send(domParams); 157 } 158 159 // If the server says everything is OK 160 if (domReturnValue != "") 161 { 162 return domReturnValue; 163 } 164 else 165 { 166 if (objRequest.status == 200) { 167 // Get the returned XML from the Request object 168 domReturnValue = objRequest.responseText; 169 // If there was an error parsing the XML 170 } else { // Server said there was a problem 171 winOut = window.open(); 172 winOut.document.write(objRequest.responseText); 173 winOut.document.close(); 174 domReturnValue = BuildXMLErrorDoc("An error occured on the server: " + location.host + " Status: " + objRequest.status + " Description: " + objRequest.statusText); 175 } // End-If: Server said everything was OK 176 } 177 } else { // An error occured parsing the parameters object 178 //AJP domReturnValue = BuildXMLErrorDoc("Error building PARAM list. Error: " + domParams.parseError.errorCode + " Reason: " + domParams.parseError.reason); 179 } // End-If: Error occured parsing the paramters object 180 } else { // Remaining string was 'null' 181 domReturnValue = BuildXMLErrorDoc("Cannot build URL for validation page."); 182 } // End-If: Remaining string was not 'null' 183 return domReturnValue; 184} 185 186// Method: CheckXMLDOMforError 187// Description: This method take an XMLDOM object and determines if an ERROR node exists. 188// If so, it displays the error text to the user. This method returns true 189// if an ERROR node exists, and false otherwise. 190// Parameters: pdomDocument. The XMLDOM to be checked 191// Return Value: true/false. 192function CheckXMLDOMforError(pdomDocument) 193{ 194 var nlError; 195 var blnReturnValue = false; 196 var lngErrNumber = null; 197 var strErrSource = null; 198 var strErrorHTML = ""; 199 if (document.implementation && document.implementation.createDocument) 200 { 201 nlError = pdomDocument.getElementsByTagName("error"); 202 } 203 else if (window.ActiveXObject) { 204 nlError = pdomDocument.selectSingleNode("error"); 205 } 206 207 if (!(nlError == null)) { 208 blnReturnValue = true; 209 if (document.implementation && document.implementation.createDocument) 210 { 211 lngErrNumber = nlError.getElementsByTagName("NUMBER")[0].firstChild.nodeValue; 212 strErrSource = nlError.getElementsByTagName("SOURCE")[0].firstChild.nodeValue; 213 } 214 else if (window.ActiveXObject) { 215 lngErrNumber = nlError.getAttribute("NUMBER"); 216 strErrSource = nlError.getAttribute("SOURCE"); 217 } 218 219 strErrorHTML = "<TABLE>" + 220 "<TR>" + 221 "<TD colspan=\"2\">An error has occurred in this application</TD>" + 222 "</TR>"; 223 if (lngErrNumber != null) { 224 strErrorHTML += "<TR>" + 225 "<TD valign=\"top\"><LABEL>Number:</LABEL></TD>" + 226 "<TD>" + lngErrNumber + "</TD>" + 227 "</TR>"; 228 } 229 if (strErrSource != null) { 230 strErrSource = strErrSource.replace(/->/g, "<BR>→"); 231 strErrorHTML += "<TR>" + 232 "<TD valign=\"top\"><LABEL>Source:</LABEL></TD>
232" + 233 "<TD>" + strErrSource + "</TD>" + 234 "</TR>"; 235 } 236 strErrorHTML += "<TR>" + 237 "<TD valign=\"top\"><LABEL>Description:</LABEL></TD>" + 238 "<TD>" + nlError.text + "</TD>" + 239 "</TR>" + 240 "<TR>" + 241 "<TD colspan=\"2\">The error was not caused by anything that you did. " + 242 "Please copy the information on this screen and give it to your " + 243 "system administrator.</TD>" + 244 "</TR>" + 245 "</TABLE>"; 246 SPIConfirm(strErrorHTML); 247 } 248 return blnReturnValue; 249} 250 251// Method: FieldMayBeNull 252// Description: This method takes an XML Node and assumes it is from the schema section 253// of an ADO Generated XML document. It determines if the nullable or 254// maybenull attributes are set. It returns true if they are set to true, and 255// false if they don't exist or are set to false. 256// Parameters: pstrError. Text to be displayed as the error message. 257// Return Value: XMLDOM Object 258function FieldMayBeNull(pobjDataTypeNode) 259{ 260 var strFldIsNullable; 261 var strFldMayBeNull; 262 var blnRetVal = true; 263 if (document.implementation && document.implementation.createDocument) 264 { 265 strFldIsNullable = pobjDataTypeNode.getElementsByTagName("rs:nullable")[0].firstChild.nodeValue; 266 strFldMayBeNull = pobjDataTypeNode.getElementsByTagName("rs:maybenull")[0].firstChild.nodeValue; 267 } 268 else if (window.ActiveXObject) { 269 strFldIsNullable = pobjDataTypeNode.getAttribute("rs:nullable"); 270 strFldMayBeNull = pobjDataTypeNode.firstChild.getAttribute("rs:maybenull"); 271 } 272 273 if ((strFldIsNullable == "false" || strFldIsNullable == null) && 274 (strFldMayBeNull == "false" || strFldMayBeNull == null)) { 275 blnRetVal = false; 276 } 277 return blnRetVal; 278} 279 280//</script>
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.