Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. FeedWindow = function() {
  8. this.feedUrl = new Ext.form.ComboBox({
  9. id: 'feed-url',
  10. fieldLabel: 'Enter the URL of the feed to add',
  11. emptyText: 'http://example.com/blog/feed',
  12. width: 450,
  13. validationEvent: false,
  14. validateOnBlur: false,
  15. msgTarget: 'under',
  16. triggerAction: 'all',
  17. displayField: 'url',
  18. mode: 'local',
  19. listeners:{
  20. valid: this.syncShadow,
  21. invalid: this.syncShadow,
  22. scope: this
  23. },
  24. tpl: new Ext.XTemplate(
  25. '<tpl for="."><div class="x-combo-list-item">',
  26. '<em>{url}</em><strong>{text}</strong>',
  27. '<div class="x-clear"></div>',
  28. '</div></tpl>'),
  29. store: new Ext.data.ArrayStore({
  30. fields: ['url', 'text'],
  31. data : this.defaultFeeds
  32. })
  33. });
  34. this.form = new Ext.FormPanel({
  35. labelAlign:'top',
  36. items:this.feedUrl,
  37. border: false,
  38. bodyStyle:'background:transparent;padding:10px;'
  39. });
  40. FeedWindow.superclass.constructor.call(this, {
  41. title: 'Add Feed',
  42. iconCls: 'feed-icon',
  43. id: 'add-feed-win',
  44. autoHeight: true,
  45. width: 500,
  46. resizable: false,
  47. plain:true,
  48. modal: true,
  49. y: 100,
  50. autoScroll: true,
  51. closeAction: 'hide',
  52. buttons:[{
  53. text: 'Add Feed!',
  54. handler: this.onFeedAdd,
  55. scope: this
  56. },{
  57. text: 'Cancel',
  58. handler: this.hide.createDelegate(this, [])
  59. }],
  60. items: this.form
  61. });
  62. this.addEvents({add:true});
  63. }
  64. Ext.extend(FeedWindow, Ext.Window, {
  65. defaultFeeds : [
  66. ['http://www.divergingpath.com/rss.cfm?mode=full', 'Aaron Conran\'s Blog'],
  67. ['http://feeds.yuiblog.com/YahooUserInterfaceBlog', 'Yahoo! UI Blog'],
  68. ['http://feeds.feedburner.com/jquery/', 'jQuery Blog'],
  69. ['http://sports.yahoo.com/nba/rss.xml', 'NBA News'],
  70. ['http://feeds.dzone.com/dzone/frontpage', 'DZone.com']
  71. ],
  72. show : function(){
  73. if(this.rendered){
  74. this.feedUrl.setValue('');
  75. }
  76. FeedWindow.superclass.show.apply(this, arguments);
  77. },
  78. onFeedAdd: function() {
  79. this.el.mask('Validating Feed...', 'x-mask-loading');
  80. var url = this.feedUrl.getValue();
  81. Ext.Ajax.request({
  82. url: 'feed-proxy.php',
  83. params: {feed: url},
  84. success: this.validateFeed,
  85. failure: this.markInvalid,
  86. scope: this,
  87. feedUrl: url
  88. });
  89. },
  90. markInvalid : function(){
  91. this.feedUrl.markInvalid('The URL specified is not a valid RSS2 feed.');
  92. this.el.unmask();
  93. },
  94. validateFeed : function(response, options){
  95. var dq = Ext.DomQuery;
  96. var url = options.feedUrl;
  97. try{
  98. var xml = response.responseXML;
  99. var channel = xml.getElementsByTagName('channel')[0];
  100. if(channel){
  101. var text = dq.selectValue('title', channel, url);
  102. var description = dq.selectValue('description', channel, 'No description available.');
  103. this.el.unmask();
  104. this.hide();
  105. return this.fireEvent('validfeed', {
  106. url: url,
  107. text: text,
  108. description: description
  109. });
  110. }
  111. }catch(e){
  112. }
  113. this.markInvalid();
  114. }
  115. });