PDA

View Full Version : gAjax RSS Feeds Displayer v2.0



pixelfuture
06-24-2013, 06:21 PM
1) gAjax RSS Feeds Displayer v2.0

2) http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm

3) I'm trying to create a feature that would allow a user to load multiple rss feeds using a set of check boxes. I can get it so that when a checkbox is clicked it loads up the selected rss feed, but I can't figure out how to clear it when it's unchcked. Any thoughts or help on this?


function validate1(){
var yahoo = document.getElementById('yahoo');
if (yahoo.checked){
example3.addFeed("Yahoo", "http://dir.yahoo.com/rss/dir/getrss.php?arts");
example3.init()
} else {
//clear rss feed

}
}

function validate2(){
var msnbc = document.getElementById('msnbc');
if (msnbc.checked){
example3.addFeed("MSNBC", "http://feeds.nbcnews.com/feeds/topstories");
example3.init();
} else {
//clear rss feed

}

jscheuer1
06-24-2013, 09:37 PM
You can use this function (using a text only editor like NotePad, add it to the end of the gfeedfetcher.js file):


function removefeed(feed, removelabel){
var labels = feed.feedlabels, i = -1, keptfeeds = {};
while (++i < labels.length){
if(labels[i] !== removelabel){
keptfeeds[labels[i]] = feed.feedurls[i];
}
}
feed.feedcontainer.innerHTML = '';
feed.feeds = {};
feed.feedlabels = [];
feed.feedurls = [];
for(var f in keptfeeds){
feed.addFeed(f, keptfeeds[f]);
}
feed.feedlabels.length && feed.init();
}


For example:


function validate1(){
var yahoo = document.getElementById('yahoo');
if (yahoo.checked){
example3.addFeed("Yahoo", "http://dir.yahoo.com/rss/dir/getrss.php?arts");
example3.init()
} else {
removefeed(example3, 'Yahoo'); //clear rss feed

}
}


Just be aware that, if example3 has no other feeds, it will be empty after removing it's only feed.