The following code fetches data from a XML feed and just displays it on the gadget. Everything works fine except for one thing - the looping never takes off, the data that is fetched for the first time stays forever and there is no update.
Can someone help me understand why would this code not go and re-fetch the data from XML soruce every 25 seconds
registerNamespace(
"Anand.Hariharan.V");Anand.Hariharan.V.PopulationClock =
function(p_elSource, p_args, p_namespace) {Anand.Hariharan.V.PopulationClock.initializeBase(
this, arguments); var m_this = this; var m_el = p_elSource; var m_module = p_args.module; var m_onDashboard = p_args.onDashboard; var m_feedUrl = "http://www.------.com/rss/feed.xml f=" var m_numItems = p_args.numItems p_args.numItems : 5; var m_feed = p_args.feed; var m_moduleEl; var m_isLoaded; var m_headlinesEl; this.initialize = function(p_objScope){
Anand.Hariharan.V.PopulationClock.getBaseMethod(
this, "initialize", "Web.Bindings.Base").call(this, p_objScope);GetFeed();
};
Anand.Hariharan.V.PopulationClock.registerBaseMethod(
this, "initialize"); this.dispose = function(p_blnUnload) {m_this =
null;m_el =
null;m_module =
null;m_onDashboard =
null;m_feedUrl =
null;m_moduleEl =
null;m_isLoaded =
null;m_headlinesEl =
null;Anand.Hariharan.V.PopulationClock.getBaseMethod(
this, "dispose", "Web.Bindings.Base").call(this, p_blnUnload);};
Anand.Hariharan.V.PopulationClock.registerBaseMethod(
this, "dispose"); function callbackfn(){
m_feedUrl = url+Math.random().toString();
setTimeout(GetFeed,25000);
}
function GetFeed(){
var XML_Pointer = Web.Network.createRequest(Web.Network.Type.XML,
m_feedUrl,
{proxy:
"rss", numItems:m_numItems},OnFeedReceived);
XML_Pointer.execute();
callbackfn();
}
function OnFeedReceived(response){
m_feed = Start.Parser.ParseRssResponse(response);
if (m_feed)RenderFeed();
else if (!m_isLoaded)m_el.innerHTML =
"Error";}
function RenderFeed(){
if (m_feed && m_feed.channels && m_feed.channels.length > 0){
RenderChannel(m_feed.channels[0]);
}
}
function RenderChannel(channel){
if (!m_isLoaded){
if (m_el.innerText == "Loading...")m_el.innerText =
"";m_isLoaded =
true;}
else{
ClearFeed();
}
if (channel.items.length > 0){
RenderHeadlines(channel);
}
}
function RenderHeadlines(channel){
if (!m_headlinesEl){
m_headlinesEl = document.createElement(
"ul");m_headlinesEl.className =
"rssList";m_el.appendChild(m_headlinesEl);
}
for (var i = 0; i < m_numItems; i++){
var li = document.createElement("li");li.className =
"rssItem";m_headlinesEl.appendChild(li);
var aEl = document.createElement("a");li.appendChild(aEl);
aEl.href = channel.items[i].link;
aEl.target =
"top";aEl.innerHTML = channel.items[i].title;
}
}
};
Anand.Hariharan.V.PopulationClock.registerClass(
"Anand.Hariharan.V.PopulationClock", "Web.Bindings.Base");