Created
May 5, 2009 23:31
-
-
Save eversonl/107283 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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