matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Now playing - XML Document
js code: var url = 'http://69.175.111.66:8301/admin.cgi?mode=viewxml';
function GetXmlFromUrl () {
Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', url);
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.open('GET', url, true, 'user', 'pass');
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.responseCode == 200) {
return xmlhttp.responseText;
}
}
}
xmlhttp.send();
}
function CreateXML() {
try {
var xml = new ActiveXObject("Microsoft.XMLDOM");
} catch(e) { try {
var xml = new ActiveXObject("MSXML2.DOMDocument");
} catch(e) { return; } }
xml.async = false;
return xml;
}
function OnEvent_ChatWndReceiveMessage(pChatWnd, sOrigin, sMessage, nType) {
if(sMessage.toLowerCase() == '!current') {
var sXml = GetXmlFromUrl();
var oXml = CreateXML();
if (oXml !== false) {
oXml.LoadXml(sXml);
pChatWnd.SendMessage('Current playing '+oXml.selectSingleNode('//SHOUTCASTSERVER/SONGTITLE').text());
}
}
}
|
|