mirror of
https://github.com/wassname/Mostly-Harmless.git
synced 2026-07-18 12:10:30 +08:00
Made freshCutoff have a max of 91 days old instead of 90.
If the user selects 91 days old, it means show all posts.
This commit is contained in:
+2
-2
@@ -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);
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user