From 0d6e46292464a83536d3778a55c3a5b337bda684 Mon Sep 17 00:00:00 2001 From: Kerrick Long Date: Tue, 28 Jun 2011 10:52:14 -0500 Subject: [PATCH] Got fresh content working again. --- css/popup.css | 3 +++ fancy-settings/manifest.js | 2 +- js/common.js | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/css/popup.css b/css/popup.css index f5fc4d9..99d2fd8 100644 --- a/css/popup.css +++ b/css/popup.css @@ -45,6 +45,9 @@ a:hover { clear:both; overflow:auto; } +#posts li.stale { + display: none; +} li.hidden .votes, li.hidden .thumblink, li.hidden .link, li.hidden .domain, li.hidden .meta, li.hidden .actions *:not(.hide){ opacity: 0.25; } diff --git a/fancy-settings/manifest.js b/fancy-settings/manifest.js index 832f360..88ed4e7 100755 --- a/fancy-settings/manifest.js +++ b/fancy-settings/manifest.js @@ -90,7 +90,7 @@ this.manifest = { "group": "Fresh Content", "name": "freshCutoffDescription", "type": "description", - "text": "

This setting allows you to choose the oldest reddit posts you’d like to see. Anything posted before the value you’ve chosen will not be indicated in the browser button's total, and will not be shown in the popup." + "text": "

This setting allows you to choose the oldest reddit posts you’d like to see. Anything posted before the value you’ve chosen not be indicated in the browser button's total, but will not be shown in the popup." } ] }; diff --git a/js/common.js b/js/common.js index 52a64b1..2a46cfd 100644 --- a/js/common.js +++ b/js/common.js @@ -271,16 +271,17 @@ function Popup() { * @method */ Popup.prototype.createListHTML = function (url) { - var listHTML; + var listHTML, staleCounter; if (cache.get(url) === undefined) { throw 'Cannot create list HTML for a non-cached URL.'; } listHTML = '

    '; + staleCounter = 0; for(var i = 0; i < cache.get(url).api.length; i++) { - var data, voteDir, entry, hiddenText, saveText, thumbSrc; + var data, voteDir, entry, hiddenText, saveText, isFreshEnough, freshText, thumbSrc; data = cache.get(url).api[i].data; console.log(data); @@ -289,9 +290,12 @@ Popup.prototype.createListHTML = function (url) { if (data.likes === false) voteDir = -1; hiddenText = data.hidden === true ? 'hidden' : 'hide'; saveText = data.saved === true ? 'saved' : 'save'; + isFreshEnough = settings.freshCutoff === 91 ? 'true' : data.created_utc >= utils.epoch() - settings.freshCutoff * 24 * 60 * 60; + if (!isFreshEnough) staleCounter++; + freshText = isFreshEnough ? 'fresh' : 'stale'; thumbSrc = data.thumbnail.indexOf('/') === 0 ? 'http://www.reddit.com' + data.thumbnail : data.thumbnail; - listHTML += '
  1. '; + listHTML += '
  2. '; listHTML += '
    '; listHTML += ''; listHTML += '' + data.score + ''; @@ -320,6 +324,11 @@ Popup.prototype.createListHTML = function (url) { } listHTML += '
' + + if (staleCounter > 0) { + listHTML += '
Hiding ' + staleCounter.toString() + ' stale posts. Visit the options page to change your Fresh Content preferences.
'; + } + return listHTML; };