Hi,
I'm trying to retrieve the Skype online status for a user and use that in decision making within a DNN module.
I have created a TEST HTML page using the same version of jQuery that is installed with DNN 6.1.3 and have it working as expected.
My problem though is implementing this within my DNN module - I get jQuery errors - parseerror.
Is there anything I need to do in order to enable DNN to make cross-domain queries with jQuery.getJSON?
The code may not be the neatest or best, but at least it works in the test page.
Any help would be greatly appreciated.
This is my test HTML page that works correctly:
<html>
<head>
<title>Test Page</title>
<script type="text/javascript" src="jquery/jquery.js" ></script>
<script type="text/javascript">
// check the current status of the user from Skype
function checkSkypeStatus()
{
var skypeName = document.getElementById("txtSkypeName").value;
var skypeUrl = "http://mystatus.skype.com/" + skypeName + ".xml";
// use YQL with JSON to perform cross-domain request and return XML data
$.getJSON("http://query.yahooapis.com/v1/public/..."
+ encodeURIComponent(skypeUrl) + "%22&format=xml'&callback=?",
function(data){
// data.results);
if (data.results != null)
{
// data.results);
var skypeName = document.getElementById("txtSkypeName").value;
var xmlOrg = data.results.toString(); // get the original XML response
var xmlNew = xmlOrg.replace(/xml:/g, ""); // strip xml: namespace from presense nodes
var xml = $.parseXML(xmlNew); // parse the XML into an XmlDocument
var $xmlDoc = $( xml );
// from XML: ' + $xmlDoc.find('presence[lang="NUM"]').text());
//var status = $xmlDoc.find('presence:first').text();
var status = $xmlDoc.find('presence[lang="NUM"]').text(); // read the status code from the XML
//¦0 – unknown
//¦1 – offline
//¦2 – online
//¦3 – away
//¦4 – not available
//¦5 – do not disturb
//¦6 – invisible
//¦7 – skype me
if (status == "1")
{
//document.getElementById("status").innerText = skypeName + " is currently offline";
$("#status").text( skypeName + " is currently offline");
$("#SkypeStatus").replaceWith("<img id='SkypeStatus' src='' alt='skypeName + is currently offline' />");
}
else if(status == "2")
{
$("#status").text( skypeName + " is currently online");
}
}
else
$("#status").text( skypeName + " status is unknown");
}); // end of callback function to process the response from skype
} // function checkSkypeStatus()
</script>
</head>
<body>
<h1>This is my test page</h1>
<input type="text" id="txtSkypeName" name="txtSkypeName" value="alon.hirsch" /><br />
<button value="Click me!" onclick="checkSkypeStatus()">Click ME!</button>
<p id="status" >Checking online status ...</p>
<div id="SkypeStatus">
</div>
</body>
</html>
Thanx,
Alon