From cc8be4269068a6dac17a2b163308152a0f6a3938 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 29 Jan 2013 19:15:12 -0500 Subject: [PATCH] allow people to delete *old* history rather than *new* history --- _locales/en/messages.json | 1 + javascript/clearhistory.js | 12 ++++++++++-- javascript/options.js | 3 +++ views/options.html | 5 +++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 82ff685..e85b3a6 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -6,6 +6,7 @@ "optionsTitle": {"message": "Options for Clear History [Advance Fork]"}, "optionsHeader": {"message": "Clear History [Advance Fork]"}, "optionsTimeFor": {"message": "Delete history for:"}, + "optionsTimeStart": {"message": "Clear entries newer than the selected time (otherwise, entries older than the selection will be cleared)"}, "optionsTime": { "message": "Last $num$ $units$", "placeholders": { diff --git a/javascript/clearhistory.js b/javascript/clearhistory.js index 3766f6b..b2d2714 100644 --- a/javascript/clearhistory.js +++ b/javascript/clearhistory.js @@ -72,10 +72,18 @@ function clearHistory() { chrome.history.deleteAll(didClearHistory); } else { // Create the range + var timeStart = localStorage['timeStart'] === CONSTANTS.YES; var now = (new Date).getTime(); + var startTime = (now - time * 60 * 60 * 1000); // time from hrs to ms + if (timeStart) { + var endTime = now; + } else { + var endTime = startTime; + startTime = 0; + } var range = { - startTime: (now - time * 60 * 60 * 1000), // time from hrs to ms - endTime: now + startTime: startTime, + endTime: endTime }; // Delete history in the range chrome.history.deleteRange(range, didClearHistory); diff --git a/javascript/options.js b/javascript/options.js index 62721cb..17139d5 100644 --- a/javascript/options.js +++ b/javascript/options.js @@ -30,6 +30,7 @@ function init() { $('#optionsHeader')[0].innerText = chrome.i18n.getMessage('optionsHeader'); $('#optionsPrompt')[0].innerText = chrome.i18n.getMessage('optionsPrompt'); $('#optionsTimeFor')[0].innerText = chrome.i18n.getMessage('optionsTimeFor'); + $('#optionsTimeStart')[0].innerText = chrome.i18n.getMessage('optionsTimeStart'); $('#optionsCookies')[0].innerText = chrome.i18n.getMessage('optionsCookies'); $('#optionsSaved > b')[0].innerText = chrome.i18n.getMessage('optionsSaved'); @@ -45,12 +46,14 @@ function init() { }); // Load or set localStorage data + var timeStart = localStorage['timeStart'] || CONSTANTS.YES; var time = ~~(localStorage['time']) || (localStorage['time'] = CONSTANTS.DEFAULT_TIME); var showPrompt = localStorage['prompt'] || (localStorage['prompt'] = CONSTANTS.YES); var clearCookies = localStorage['cookies'] || CONSTANTS.NO; + $('input[name=timeStart]')[0].checked = (timeStart === CONSTANTS.YES); $('input[name=time][value="' + time + '"]')[0].checked = true; $('input[name=prompt]')[0].checked = (showPrompt === CONSTANTS.YES); $('input[name=cookies]')[0].checked = (clearCookies === CONSTANTS.YES); diff --git a/views/options.html b/views/options.html index a555e8f..9b909eb 100644 --- a/views/options.html +++ b/views/options.html @@ -24,6 +24,11 @@
+

+
+ +
+
-- 2.39.5