diff options
Diffstat (limited to 'bandwagon/content/scripts/model/feed.js')
-rw-r--r-- | bandwagon/content/scripts/model/feed.js | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/bandwagon/content/scripts/model/feed.js b/bandwagon/content/scripts/model/feed.js deleted file mode 100644 index 412ee4a..0000000 --- a/bandwagon/content/scripts/model/feed.js +++ /dev/null @@ -1,189 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is bandwagon. - * - * The Initial Developer of the Original Code is - * David McNamara. - * Portions created by the Initial Developer are Copyright (C) 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -Bandwagon.Model.Feed = function() -{ - this.Bandwagon = Bandwagon; - - this.id = -1; // internal bandwagon id - - this.url = ""; - this.name = ""; - this.description = ""; - this.password = null; - this.dateAdded = new Date(); - this.dateLastCheck = null; - this.updateInterval = this.Bandwagon.DEFAULT_FEED_UPDATE_INTERVAL; // in seconds - this.showNotifications = true; - this.autoPublish = false; - this.active = true; - this.feedItemsPerPage = this.Bandwagon.DEFAULT_FEED_ITEMS_PER_PAGE; - - this.preview = false; - this.editable = false; - this.status = this.STATUS_NEW; - - this.feedItems = {}; -} - -Bandwagon.Model.Feed.prototype.STATUS_NEW = 0; -Bandwagon.Model.Feed.prototype.STATUS_LOADING = 1; -Bandwagon.Model.Feed.prototype.STATUS_LOADERROR = 2; -Bandwagon.Model.Feed.prototype.STATUS_LOADED = 3; - -Bandwagon.Model.Feed.prototype.getUnreadFeedItems = function() -{ - var unreadFeedItems = []; - - for (var id in this.feedItems) - { - if (!this.feedItems[id].read) - { - unreadFeedItems.push(this.feedItems[id]); - } - } - - return unreadFeedItems; -} - -Bandwagon.Model.Feed.prototype.setAllRead = function() -{ - for (var id in this.feedItems) - { - this.feedItems[id].read = true; - } -} - -Bandwagon.Model.Feed.prototype.getUnnotifiedFeedItems = function() -{ - var unnotifiedFeedItems = []; - - for (var id in this.feedItems) - { - if (!this.feedItems[id].notified) - { - unnotifiedFeedItems.push(this.feedItems[id]); - } - } - - return unnotifiedFeedItems; -} - -Bandwagon.Model.Feed.prototype.setAllNotified = function() -{ - for (var id in this.feedItems) - { - this.feedItems[id].notified = true; - } -} - -Bandwagon.Model.Feed.prototype.getSortedFeedItems = function() -{ - var sortedFeedItems = []; - - for (var id in this.feedItems) - { - sortedFeedItems.push(this.feedItems[id]); - } - - sortedFeedItems.sort(function(a, b) - { - // sorting is unread, then dateadded - - if (a.read == false && b.read == true ) return -1; - if (a.read == true && b.read == false ) return 1; - - return (a.dateAdded.getTime() < b.dateAdded.getTime()?1:-1); - }); - - return sortedFeedItems; -} - -Bandwagon.Model.Feed.prototype.hasFeedItem = function() -{ - for (var id in this.feedItems) - { - if (this.feedItems[id] && this.feedItems[id].guid) - { - return true; - } - } - - return false; -} - -Bandwagon.Model.Feed.prototype.toString = function() -{ - return this.name + " (" + this.url + ")"; -} - -Bandwagon.Model.Feed.prototype.equals = function(other) -{ - if (other == null) - return false; - - return (this.url == other.url); -} - -Bandwagon.Model.Feed.prototype.unserialize = function(xaddons) -{ - for each (var xaddon in xaddons.addon) - { - var feedItem = new this.Bandwagon.Model.FeedItem(); - feedItem.Bandwagon = this.Bandwagon; - - feedItem.unserialize(xaddon); - - if (feedItem.guid && feedItem.guid != "" && feedItem.name && feedItem.name != "") - { - if (this.feedItems[feedItem.guid]) - { - // "merge" with existing item - this.feedItems[feedItem.guid].unserialize(xaddon); - } - else - { - this.feedItems[feedItem.guid] = feedItem; - } - } - } - - /* TODO feed is missing info for the following: - * - * - site url - */ - -} |