Skip to content

Commit

Permalink
Merge pull request #58 from morris-jason/master
Browse files Browse the repository at this point in the history
Dedicated delete buttons for History and Rules - Issue #44.
  • Loading branch information
andrewilyas committed Oct 14, 2016
2 parents fd2554e + a33a7a4 commit 6866c7a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 11 deletions.
8 changes: 5 additions & 3 deletions extension/assets/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ <h2>Blacklisted Websites</h2>
<h4>Enter any valid regex</h4>
<table class="ui table" id="blacklist_tbl">
<tr><td>Websites</td><td>Type</td><td>Enabled</td></tr>
</table>
</table>
<button class="ui green button" id="add">Add</button>
<button class="ui blue button" id="save">Save</button>
<button class="ui red button" id="clear-rules">Clear Rules</button>

<h2>Falcon History</h2>
<div class="ui input">
Expand All @@ -22,11 +23,12 @@ <h2>Falcon History</h2>
<table class="ui table" id="history_tbl">
</table>
<button class="ui button" id="loadmore">Load more</button>

<button class="ui red button" id="clear-history">Clear History</button>

<h2>Danger Zone!</h2>
<button class="ui red button" id="clear">Clear All Data</button>

<script type="text/javascript" src="../js/lib/notie.min.js"></script>
<script type="text/javascript" src="../js/preferences.js"></script>
</body>
</html>
</html>
52 changes: 44 additions & 8 deletions extension/js/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
}
}


function getHistory(query="") {
var history_table = document.getElementById("history_tbl")
history_table.innerHTML = "<table class='ui table' id='history_tbl'></table>"
Expand All @@ -82,7 +81,6 @@
})
}


function* nextPages(allPages){
while(true)
yield allPages.splice(0, 20)
Expand Down Expand Up @@ -151,26 +149,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);
}


})();

0 comments on commit 6866c7a

Please sign in to comment.