|
XML Populate the Gadget's UI
Listing 2. One you set up the gadget's manifest, your next step is to gather the data required for your gadget and populate its user interface. function refreshGadget()
{
//debugger;
req = null;
req = new ActiveXObject("Microsoft.XMLHTTP");
req.open("GET",
"http://weather.yahooapis.com/forecastrss?p=
" + location, false);
req.send();
if (req.status == 200)
{
GetWeather(req.responseXML.documentElement);
location.href = location.href;
req = null;
}
else
{
city.innerText = "Not Available";
}
}
function GetWeather(xmlNode)
{
var city1 = xmlNode.getElementsByTagName(
"yweather:location").item(0).attributes.item(0).value
var state1 = xmlNode.getElementsByTagName(
"yweather:location").item(0).attributes.item(1).value
city.innerText = city1 + ", " + state1;
currentTemp.innerText = xmlNode.getElementsByTagName(
"yweather:condition").item(0).attributes.item(2).value;
wDate.innerText = xmlNode.getElementsByTagName(
"yweather:condition").item(0).attributes.item(3).value;
}
|