Ajax basierter RSS Reader

Juni 6th, 2006

Ein nett gemachter RSS Reader in Javascript, nur schade, dass der Code unkommentiert ist (aber bei so wenig Lines of Code versteht man den auch so ;-))

Ajax.RssReader = Class.create();
Ajax.RssReader.prototype = Object.extend(new Ajax.Request(), {

initialize : function( url, options ) {

options = options || {};

this.setOptions(options);

this.items = {};

var onSuccess = this.options.onSuccess || Prototype.emptyFunction;
var onFailure = this.options.onFailure || Prototype.emptyFunction;

this.options.onSuccess = (function(t) { if( this.onSuccess(t) ) { onSuccess(this); } else { this.onFailure(t); onFailure(this); } }).bind(this);
this.options.onFailure = (function(t) { this.onFailure(t); onFailure(this); }).bind(this);

this.request( url );

},

onSuccess : function( t ) {

try {
var node = t.responseXML;
var xmlChannel = node.getElementsByTagName(’channel’).item(0);
}
catch(e) {
return false;
}

this.channel = {
title: this._getElementValue(xmlChannel, ‘title’),
link: this._getElementValue(xmlChannel, ‘link’),
description: this._getElementValue(xmlChannel, ‘description’),
language: this._getElementValue(xmlChannel, ‘language’),
copyright: this._getElementValue(xmlChannel, ‘copyright’),
managingEditor: this._getElementValue(xmlChannel, ‘managingEditor’),
webMaster: this._getElementValue(xmlChannel, ‘webMaster’),
pubDate: this._getElementValue(xmlChannel, ‘pubDate’),
lastBuildDate: this._getElementValue(xmlChannel, ‘lastBuildDate’)
};

this.items = new Array();

var xmlItems = xmlChannel.getElementsByTagName(’item’);

for (var n=0; n

var xmlItem = xmlItems[n];

var item = {
title: this._getElementValue(xmlItem, 'title'),
link: this._getElementValue(xmlItem, 'link'),
description: this._getElementValue(xmlItem, 'description'),
author: this._getElementValue(xmlItem, 'author'),
category: this._getElementValue(xmlItem, 'category'),
comments: this._getElementValue(xmlItem, 'comments'),
guid: this._getElementValue(xmlItem, 'guid'),
pubDate: this._getElementValue(xmlItem, 'pubDate')
};

this.items.push( item );

}

return true;

},

onFailure : function( t ) {

},

_getElementValue : function( node, elementName ) {

try {
var value = node.getElementsByTagName(elementName).item(0).firstChild.data;
}
catch(e) {
var value = '';
}

return value;

}

});

Noch ist dieser in JS gecodeter Rss-Reader nicht stabil, bei aufgetretenen Problemen bittet der Autor um Hinweise an: r.schuil@gmail.com (nur englische Mails)

http://r.schuil.googlepages.com/ajax.rssreader



Ähnliche Beiträge "Ajax basierter RSS Reader":
  • BloxOr Open Source Web RSS Reader
  • FeedShow - Bloglines Konkurrent?
  • COMPUTERWOCHE Feedreader
  • Leave a Reply

    Warning: include(): URL file-access is disabled in the server configuration in /home/p2666/html/_rss/wp-content/themes/whiteasmilk/footer.php on line 20 Warning: include(http://www.shares-online.de/links/csvscript3.php): failed to open stream: no suitable wrapper could be found in /home/p2666/html/_rss/wp-content/themes/whiteasmilk/footer.php on line 20 Warning: include(): Failed opening 'http://www.shares-online.de/links/csvscript3.php' for inclusion (include_path='.:/usr/lib/php') in /home/p2666/html/_rss/wp-content/themes/whiteasmilk/footer.php on line 20