3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">FeedWindow = function() {
\r
9 this.feedUrl = new Ext.form.ComboBox({
\r
11 fieldLabel: 'Enter the URL of the feed to add',
\r
12 emptyText: 'http://example.com/blog/feed',
\r
14 validationEvent: false,
\r
15 validateOnBlur: false,
\r
17 triggerAction: 'all',
\r
18 displayField: 'url',
\r
22 valid: this.syncShadow,
\r
23 invalid: this.syncShadow,
\r
26 tpl: new Ext.XTemplate(
\r
27 '<tpl for="."><div class="x-combo-list-item">',
\r
28 '<em>{url}</em><strong>{text}</strong>',
\r
29 '<div class="x-clear"></div>',
\r
31 store: new Ext.data.ArrayStore({
\r
32 fields: ['url', 'text'],
\r
33 data : this.defaultFeeds
\r
37 this.form = new Ext.FormPanel({
\r
41 bodyStyle:'background:transparent;padding:10px;'
\r
44 FeedWindow.superclass.constructor.call(this, {
\r
46 iconCls: 'feed-icon',
\r
55 closeAction: 'hide',
\r
59 handler: this.onAdd,
\r
63 handler: this.hide.createDelegate(this, [])
\r
69 this.addEvents({add:true});
\r
72 Ext.extend(FeedWindow, Ext.Window, {
\r
74 ['http://www.divergingpath.com/rss.cfm?mode=full', 'Aaron Conran\'s Blog'],
\r
75 ['http://feeds.yuiblog.com/YahooUserInterfaceBlog', 'Yahoo! UI Blog'],
\r
76 ['http://feeds.feedburner.com/jquery/', 'jQuery Blog'],
\r
77 ['http://sports.yahoo.com/nba/rss.xml', 'NBA News'],
\r
78 ['http://feeds.dzone.com/dzone/frontpage', 'DZone.com']
\r
83 this.feedUrl.setValue('');
\r
85 FeedWindow.superclass.show.apply(this, arguments);
\r
89 this.el.mask('Validating Feed...', 'x-mask-loading');
\r
90 var url = this.feedUrl.getValue();
\r
92 url: 'feed-proxy.php',
\r
93 params: {feed: url},
\r
94 success: this.validateFeed,
\r
95 failure: this.markInvalid,
\r
101 markInvalid : function(){
\r
102 this.feedUrl.markInvalid('The URL specified is not a valid RSS2 feed.');
\r
106 validateFeed : function(response, options){
\r
107 var dq = Ext.DomQuery;
\r
108 var url = options.feedUrl;
\r
111 var xml = response.responseXML;
\r
112 var channel = xml.getElementsByTagName('channel')[0];
\r
114 var text = dq.selectValue('title', channel, url);
\r
115 var description = dq.selectValue('description', channel, 'No description available.');
\r
119 return this.fireEvent('validfeed', {
\r
122 description: description
\r
127 this.markInvalid();
\r