Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedicated delete buttons for History and Rules - Issue #44. #58

Merged
merged 1 commit into from Oct 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -60,7 +60,6 @@
}
}


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


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


})();