Skip to content

Instantly share code, notes, and snippets.

@eversonl
Created May 5, 2009 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eversonl/107283 to your computer and use it in GitHub Desktop.
Save eversonl/107283 to your computer and use it in GitHub Desktop.
noun_type_feed = new CmdUtils.NounType( "feed",["bbc", "cnn"]);
CmdUtils.CreateCommand({
name: "poo",
takes: {channel: noun_type_feed},
preview: function(pblock, feed)
{
var searchTerm = "poo "+feed.text;
// Don't even display any text before fetching search results,
// since the results come back nearly instantaneously. In the
// future, we can display a throbber.
if(searchTerm.length < 7) {
pblock.innerHTML = "display an rss feed for:-<br>bbc<br>cnn "
return;
}
//news feed sources.
var sources = new Array();
sources['bbc'] = 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml';
sources['cnn'] = 'http://rss.cnn.com/rss/edition.rss';
//get the feed.
jQuery.ajax({
type: "GET",
url: ""+sources[feed.text],
data: "",
dataType: "xml",
error: function() {
displayMessage("Sorry Error with "+feed.text);
},
success: function(xml) {
parseRSS(pblock,xml);
}
})
}
})
function parseRSS(pblock, xml)
{
var $ = jQuery;
pblock.innerHTML = "";
$(xml).find("item").each(function()
{
pblock.innerHTML += "<br/><a href='"+$(this).find('link').text()+"'>"+$(this).find('title').text()+"</a>";
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment