Ajax Framework Code by Richard Schwartz10/18/2005 12:14:32 AM
function initXMLHttpRequest() { // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { // branch for IE/Windows ActiveX version req = new ActiveXObject("Microsoft.XMLHTTP"); } return(req); } function makeCustomHandlerForObject(reqString, targetObjectString, returnProperty) { out = "var xmlOutput = processReadyStateChange(window[\"" + reqString + "\"],\"" + returnProperty + "\");"; out = out + "if ( ! (typeof(xmlOutput) == \"string\" && xmlOutput == \"\") ) {"+ targetObjectString + "= xmlOutput; window[\"" + reqString + "\"] = null;}"; return out; } function makeCustomHandlerForFunction(reqString, targetObjectString, returnProperty) { out = "var xmlOutput = processReadyStateChange(window[\"" + reqString + "\"],\"" + returnProperty + "\");" out = out + "if ( ! (typeof(xmlOutput) == \"string\" && xmlOutput == \"\") ) {" + targetObjectString.substr(0, targetObjectString.length - 1) + ",xmlOutput); window[\"" + reqString + "\"] = null;}"; return out; } function loadXMLDoc(url, reqIndex, target, property) { req = window[ reqIndex ]; if (target.substr(target.length - 1, 1) == ")") { req.onreadystatechange = new Function( makeCustomHandlerForFunction(reqIndex, target, property) ); } else { req.onreadystatechange = new Function( makeCustomHandlerForObject(reqIndex, target, property) ); } req.open("GET", url, true; if (window.XMLHttpRequest) { req.send(null; } else { req.send(); } } function processReadyStateChange(req, property) { // only if req shows "complete" if (req.readyState == 4) { // only if "OK" if (req.status == 200) { return req[ property ]; } else { alert("There was a problem retrieving the RSS feed\n" + req.statusText) } } return ""; } var reqNum = 0; function getXMLText(source, target) { var reqIndex = "req" + (++reqNum); window[ reqIndex ] = initXMLHttpRequest(); loadXMLDoc(source, reqIndex, target, "responseText")} function getXMLDoc(source, target) { var reqIndex = "req" + (++reqNum); window[ reqIndex ] = initXMLHttpRequest(); loadXMLDoc(source, reqIndex, target, "responseXML")} function getFirstElement(node, elementName) { child = node.firstChild; while ( child != null ) { if (child.nodeType == 1) { if ( child.nodeName == elementName) { return child; } } child = child.nextSibling; } return null; } function getLastElement(node, elementName) { child = node.lastChild; while ( child != null ) { if (child.nodeType == 1) { if ( child.nodeName == elementName) { return child; } } child = child.previousSibling; } return null; } function getNthElement(node, elementName, n) { foundCount = 0; child = node.firstChild; while (child != null { if (child.nodeType == 1) { if (child.nodeName == elementName) { foundCount = foundCount + 1; if (foundCount == n) { return child; } } } child = child.nextSibling } return null; } function getElementText(node) { if (node == null { return(""); } child = node.firstChild; foundCDATA = false; foundPlainText = false; while (child != null { if (child.nodeType == 4) { // CDATA node result = child.nodeValue; foundCDATA = true; } else { if (child.nodeType == 3) { // Text node result = child.nodeValue; foundPlainText = true; } } if (foundCDATA == true { return result } child = child.nextSibling } if (foundPlainText == false { return("") } return result; }

the hitchhiker's guide to anti-spam for Lotus Domino
- 











