diff options
author | dave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2008-09-24 14:50:21 (GMT) |
---|---|---|
committer | dave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2008-09-24 14:50:21 (GMT) |
commit | c67e6610970d25e5485c93f6e85a91329f317e6e (patch) | |
tree | e80ca395b5a3812503f985728ce19de181630c71 | |
parent | 66362507f374e7cd05f78ce7a769a8edc1f18cd5 (diff) |
Added feedItemsPerPage support (part of bug 762)
git-svn-id: http://svn.mozilla.org/addons/trunk@18551 4eb1ac78-321c-0410-a911-ec516a8615a5
-rw-r--r-- | bandwagon/components/bandwagon-service.js | 24 | ||||
-rw-r--r-- | bandwagon/content/scripts/bandwagon.js | 1 | ||||
-rw-r--r-- | bandwagon/content/scripts/factory/feedFactory.js | 5 | ||||
-rw-r--r-- | bandwagon/content/scripts/model/feed.js | 1 | ||||
-rw-r--r-- | bandwagon/content/ui/feedsPaneController.js | 5 | ||||
-rw-r--r-- | bandwagon/defaults/preferences/bandwagon.js | 2 |
6 files changed, 36 insertions, 2 deletions
diff --git a/bandwagon/components/bandwagon-service.js b/bandwagon/components/bandwagon-service.js index 253c107..69c4005 100644 --- a/bandwagon/components/bandwagon-service.js +++ b/bandwagon/components/bandwagon-service.js @@ -452,6 +452,27 @@ BandwagonService.prototype = { } }, + getFeedItemsPerPage: function(feed) + { + // returns the global feed items per page, if enabled. otherwise, this feed's feed items per page. + + var feedItemsPerPage; + + if (Bandwagon.Preferences.getPreference("feeditemsperpage.enabled")) + { + feedItemsPerPage = Bandwagon.Preferences.getPreference("feeditemsperpage"); + } + else + { + feedItemsPerPage = feed.feedItemsPerPage; + } + + if (feedItemsPerPage<1) + feedItemsPerPage = 1; + + return feedItemsPerPage; + }, + _feedUpdateObserver: function(feed) { // called when a feed is updated @@ -524,7 +545,8 @@ BandwagonService.prototype = { + "updateInterval INTEGER NOT NULL, " + "showNotifications INTEGER NOT NULL, " + "autoPublish INTEGER NOT NULL, " - + "active INTEGER NOT NULL DEFAULT 1)" + + "active INTEGER NOT NULL DEFAULT 1, " + + "feedItemsPerPage INTEGER NOT NULL)" ); this._storageConnection.executeSimpleSQL( "CREATE TABLE IF NOT EXISTS feedItems " diff --git a/bandwagon/content/scripts/bandwagon.js b/bandwagon/content/scripts/bandwagon.js index 5da90cc..4fbeb91 100644 --- a/bandwagon/content/scripts/bandwagon.js +++ b/bandwagon/content/scripts/bandwagon.js @@ -44,6 +44,7 @@ Bandwagon.EMID = "sharing@addons.mozilla.org"; Bandwagon.SQLITE_FILENAME = "bandwagon.sqlite"; Bandwagon.FEED_UPDATE_TIMER_DELAY = 60 * 60; // interval between checking if feeds need updating (in seconds) (this will always be 30 seconds in debug mode) Bandwagon.DEFAULT_FEED_UPDATE_INTERVAL = 24 * 60 * 60; // default individual feed update interval (in seconds) +Bandwagon.DEFAULT_FEED_ITEMS_PER_PAGE = 10; Bandwagon.DEFAULT_FEED1_URL = "https://services.addons.mozilla.org/en-US/firefox/api/1.1/list/featured/all/10/"; Bandwagon.DEFAULT_FEED1_NAME = "Featured Add-ons"; Bandwagon.FIRSTRUN_LANDING_PAGE = "http://www.google.com/search?hl=en&q=bandwagon+first+run+landing+page&btnG=Google+Search&aq=f&oq="; // TODO diff --git a/bandwagon/content/scripts/factory/feedFactory.js b/bandwagon/content/scripts/factory/feedFactory.js index e700bff..802fd1a 100644 --- a/bandwagon/content/scripts/factory/feedFactory.js +++ b/bandwagon/content/scripts/factory/feedFactory.js @@ -112,7 +112,7 @@ Bandwagon.Factory.FeedFactory.prototype.commitFeed = function(feed) if (!this.connection) return; - var statement = this.connection.createStatement("REPLACE INTO feeds VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)"); + var statement = this.connection.createStatement("REPLACE INTO feeds VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)"); try { @@ -126,6 +126,7 @@ Bandwagon.Factory.FeedFactory.prototype.commitFeed = function(feed) statement.bindInt32Parameter(7, (feed.showNotifications?1:0)); statement.bindInt32Parameter(8, (feed.autoPublish?1:0)); statement.bindInt32Parameter(9, (feed.active?1:0)); + statement.bindInt32Parameter(10, feed.feedItemsPerPage); statement.execute(); } @@ -199,6 +200,8 @@ Bandwagon.Factory.FeedFactory.prototype._openFeedFromRS = function(resultset) feed.updateInterval = resultset.getInt32(6); feed.showNotifications = (resultset.getInt32(7)==1?true:false); feed.autoPublish = (resultset.getInt32(8)==1?true:false); + feed.active = (resultset.getInt32(9)==1?true:false); + feed.feedItemsPerPage = resultset.getInt32(10); return feed; } diff --git a/bandwagon/content/scripts/model/feed.js b/bandwagon/content/scripts/model/feed.js index cc33a66..265dbfa 100644 --- a/bandwagon/content/scripts/model/feed.js +++ b/bandwagon/content/scripts/model/feed.js @@ -50,6 +50,7 @@ Bandwagon.Model.Feed = function() this.showNotifications = true; this.autoPublish = false; this.active = true; + this.feedItemsPerPage = this.Bandwagon.DEFAULT_FEED_ITEMS_PER_PAGE; this.preview = false; this.editable = false; diff --git a/bandwagon/content/ui/feedsPaneController.js b/bandwagon/content/ui/feedsPaneController.js index 5c8ca74..8682d9c 100644 --- a/bandwagon/content/ui/feedsPaneController.js +++ b/bandwagon/content/ui/feedsPaneController.js @@ -583,8 +583,13 @@ Bandwagon.Controller.FeedsPane._repopulateFeedItemsList = function(feed) // repopulate with feed items + var feedItemsPerPage = bandwagonService.getFeedItemsPerPage(feed); + for (var id in feed.feedItems) { + if (feedItemsPerPage-- == 0) + break; + var feedItem = feed.feedItems[id]; if (feedItem == null) diff --git a/bandwagon/defaults/preferences/bandwagon.js b/bandwagon/defaults/preferences/bandwagon.js index 6e0984a..ee61041 100644 --- a/bandwagon/defaults/preferences/bandwagon.js +++ b/bandwagon/defaults/preferences/bandwagon.js @@ -6,3 +6,5 @@ pref("extensions.bandwagon.updateall.enabled", true); pref("extensions.bandwagon.updateall.interval", 2); pref("extensions.bandwagon.updateall.units", 1); pref("extensions.bandwagon.updateall.datelastcheck", 0); +pref("extensions.bandwagon.feeditemsperpage.enabled", true); +pref("extensions.bandwagon.feeditemsperpage", 10); |