//put the external xml feeds url here //var IndicesURL="http://qq.axl.co.uk/axl-dlls/publish?url=/templates/ir/thomasmiller/indices.xml"; var IndicesURL = "/tmi/XMLFeeds.nsf/GetIndices?openagent"; //put the external xml feeds url here //var CurrURL="http://qq.axl.co.uk/axl-dlls/publish?url=/templates/ir/thomasmiller/forex.xml"; var CurrURL = "/tmi/XMLFeeds.nsf/GetCurr?openagent"; var IndicesID = "IndicesFeeds"; var CurrID = "CurrFeeds"; var HTMLTable=''; var HTMLHeaderIndCols=''; var HTMLHeaderCurrCols=''; var xmlhttp; var t; //this is refresh the xmlfeeds table automatically function stopCount() { clearTimeout(t); } function loadXMLDoc(sType) { //called from the index page //alert("loadXMLDoc called stype=" + sType); xmlhttp=null; if (window.XMLHttpRequest) {// code for IE7, Firefox, Mozilla, etc. xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) {// code for IE5, IE6 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp!=null) { if (sType=="1") { xmlhttp.open("GET",IndicesURL,true); } else { xmlhttp.open("GET",CurrURL,true); } /* xmlhttp.onreadystatechange=onResponse(sType);*/ xmlhttp.onreadystatechange= function() { if (xmlhttp.readyState == 4 && xmlhttp.responseXML) { // alert (xmlhttp.responseXML ); onResponse(sType); } }; xmlhttp.send(null); } else { alert("Your browser does not support XMLHTTP."); } //This is to automatically refresh the xmlfeeds table every 1 min. if (sType=="1") { t=setTimeout("loadXMLDoc('1')",60000); } } function onResponse(sType) {//use this one when we have the real url to call see online example: http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_httprequest_js4 if (sType=="1") { sElemNM = "index"; sColHeading = HTMLHeaderIndCols; sID=IndicesID; sTN1 = "name"; sTN2 = "value"; sTN3 = "changeDirection" sTN4 = "change"; sTN5 = "changePercent"; } else { sElemNM = "forex"; sColHeading = HTMLHeaderCurrCols; sID=CurrID; sTN1 = "name"; sTN2 = "mid"; sTN3 = "changeDirection" sTN4 = "change"; sTN5 = "changePercent"; } x=xmlhttp.responseXML.documentElement.getElementsByTagName(sElemNM); var txt=""; for (i=0;i"; xx=x[i].getElementsByTagName(sTN1); { try { txt=txt + ""; } catch (er) { txt=txt + ""; } } xx=x[i].getElementsByTagName(sTN2); { try { txt=txt + ""; } catch (er) { txt=txt + ""; } } //changeDirection + change xxD=x[i].getElementsByTagName(sTN3); xx=x[i].getElementsByTagName(sTN4); { try { if (xxD[0].firstChild.nodeValue == "+") { sColor = "color:#008000"; } else { sColor = "color:#ff0000;"; } txt=txt + ""; } catch (er) { txt=txt + ""; } } xx=x[i].getElementsByTagName(sTN5); { try { txt=txt + ""; } catch (er) { txt=txt + ""; } } txt=txt + ""; } txt=HTMLTable + sColHeading + txt + "
INDEXLEVELCHANGE ON DAY% CHANGE
FXRATECHANGE ON DAY% CHANGE
" + xx[0].firstChild.nodeValue + " " + xx[0].firstChild.nodeValue + " " + xxD[0].firstChild.nodeValue; txt=txt + xx[0].firstChild.nodeValue + " " + xxD[0].firstChild.nodeValue + xx[0].firstChild.nodeValue + "%
"; document.getElementById(sID).innerHTML=txt; //So now call this function again to load curr xml feeds, if we have just done the indices if (sType=="1") { loadXMLDoc('2'); } }