From a33a7a4ed363669f956d740f218bce1b99ad92f8 Mon Sep 17 00:00:00 2001 From: Jason Morris Date: Sun, 2 Oct 2016 22:37:25 -0500 Subject: [PATCH] Issue #44 - functionality complete. Waiting for PR approval. --- extension/assets/preferences.html | 8 +++-- extension/js/preferences.js | 52 ++++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/extension/assets/preferences.html b/extension/assets/preferences.html index bf75baa..2e8727e 100644 --- a/extension/assets/preferences.html +++ b/extension/assets/preferences.html @@ -11,9 +11,10 @@

Blacklisted Websites

Enter any valid regex

-
WebsitesTypeEnabled
+ +

Falcon History

@@ -22,11 +23,12 @@

Falcon History

- + +

Danger Zone!

- \ No newline at end of file + diff --git a/extension/js/preferences.js b/extension/js/preferences.js index 09d58fc..ba02167 100644 --- a/extension/js/preferences.js +++ b/extension/js/preferences.js @@ -60,7 +60,6 @@ } } - function getHistory(query="") { var history_table = document.getElementById("history_tbl") history_table.innerHTML = "
" @@ -77,7 +76,6 @@ }) } - function* nextPages(allPages){ while(true) yield allPages.splice(0, 20) @@ -146,26 +144,64 @@ function clearAllData() { chrome.storage.local.clear(); - notie.alert(1, 'Deleted. Restarting Falcon...', 2) + notie.alert(1, 'Deleted All Data. Restarting Falcon...', 2) + setTimeout(function() { + chrome.runtime.reload() + }, 2000); + } + + function clearRules() { + chrome.storage.local.get(['blacklist'], function(items) { + var blacklist = items['blacklist']; + blacklist['SITE'] = ['chrome-ui://newtab'] + chrome.storage.local.set({'blacklist':blacklist}); + }); + notie.alert(1, 'Deleted Rules. Restarting Falcon...', 2) + setTimeout(function() { + chrome.runtime.reload() + }, 2000); + } + + function clearHistory() { + chrome.storage.local.get(function(results) { + var timestaps = results['index']['index']; + for(key in timestaps){ + chrome.storage.local.remove(timestaps[key]); + } + chrome.storage.local.set({'index':{'index':[]}}); + }); + notie.alert(1, 'Deleted History. Restarting Falcon...', 2) setTimeout(function() { chrome.runtime.reload() }, 2000); } getHistory() + document.getElementById("save").onclick = save; document.getElementById("add").onclick = add; document.getElementById("loadmore").onclick = loadMore; - document.getElementById("clear").onclick = function() { - notie.confirm('Are you sure you want to do that?', 'Yes', 'Cancel', function() { - clearAllData() - }) + document.getElementById("clear").onclick = function () { + notie.confirm('Are you sure you want to do that?', 'Yes', 'Cancel', function() { + clearAllData(); + }); + } + + document.getElementById("clear-rules").onclick = function () { + notie.confirm('Are you sure you want to do that?', 'Yes', 'Cancel', function() { + clearRules(); + }); + } + + document.getElementById("clear-history").onclick = function () { + notie.confirm('Are you sure you want to do that?', 'Yes', 'Cancel', function() { + clearHistory(); + }); } document.getElementById("search_history").onkeyup = function () { getHistory(document.getElementById("search_history").value); } - })();