From bf7654c6d9e7eb469d83ee306703e8548ddf67cf Mon Sep 17 00:00:00 2001 From: Kerrick Long Date: Thu, 23 Jun 2011 15:20:57 -0500 Subject: [PATCH] Made freshCutoff have a max of 91 days old instead of 90. If the user selects 91 days old, it means show all posts. --- background.js | 4 ++-- fancy-settings/manifest.js | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/background.js b/background.js index 04cc9e7..6877426 100644 --- a/background.js +++ b/background.js @@ -1,7 +1,7 @@ var db = openDatabase('mhdb', '1.0', 'Mostly Harmless Database', 5 * 1024 * 1024); var settings = new Store("settings", { "cacheTime": 1, - "freshCutoff": 90 + "freshCutoff": 91 }).toObject(); var commentsMatchPattern = /https?:\/\/www\.reddit\.com(\/r\/(.+?))?\/comments\/(.+?)\/.*/; init(); @@ -104,7 +104,7 @@ function cacheData(response,pageUrl,tabId,isCommentsPage) { var insertUrl = isCommentsPage ? 'http://www.reddit.com' + pageUrl.split('#')[0] : pageUrl.split('#')[0]; for(var i = 0; i < response.data.children.length; i++) { var data = response.data.children[i].data; - var isFreshEnough = data.created_utc >= epoch() - settings.freshCutoff * 24 * 60 * 60; + var isFreshEnough = settings.freshCutoff === 91 ? true : data.created_utc >= epoch() - settings.freshCutoff * 24 * 60 * 60; if(isFreshEnough) { wasCached = true; freshPosts.push(data); diff --git a/fancy-settings/manifest.js b/fancy-settings/manifest.js index 231359e..0acd249 100755 --- a/fancy-settings/manifest.js +++ b/fancy-settings/manifest.js @@ -69,18 +69,20 @@ this.manifest = { "name": "freshCutoff", "type": "slider", "label": "", - "max": 90, + "max": 91, "min": 1, "step": 1, "display": true, "displayModifier": function(value) { if(value === 1) - return value.toString() + " day"; + return "Show posts less than " + value.toString() + " day old"; if(value <= 2 * 7) - return value.toString() + " days"; + return "Show posts less than " + value.toString() + " days old"; if(value > 2 * 7 && value < 7 * 7) - return Math.floor(value / 7).toString() + " weeks"; - return Math.ceil(value / 30).toString() + " months"; + return "Show posts less than " + Math.floor(value / 7).toString() + " weeks old"; + if(value >= 7 * 7 && value < 91) + return "Show posts less than " + Math.ceil(value / 30).toString() + " months old"; + return "Show posts from all time"; } }, {