mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-15 21:55:36 +07:00
New Addon version 1.2
+ Badges counts only per url (for this feature we need the new "tabs" permission) + New Interface. Special thanks to @grahamperrin and @Thorin-Oakenpants. (#21) + Files in folder ordered - Remove siteBlockedAlert.html page. We're show now nothing. + Revised texts for Rules-Status + Add File for version number
This commit is contained in:
64
core_js/log.js
Normal file
64
core_js/log.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Get the log and display the data as table.
|
||||
*/
|
||||
var log = [];
|
||||
|
||||
/**
|
||||
* Reset the global log
|
||||
*/
|
||||
function resetGlobalLog(){
|
||||
browser.storage.local.remove("log");
|
||||
browser.storage.local.set({"resetLog": true});
|
||||
location.reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the log and display to the user
|
||||
*/
|
||||
function getLog()
|
||||
{
|
||||
browser.storage.local.get('log', function(data) {
|
||||
if(data.log)
|
||||
{
|
||||
log = JSON.parse(data.log);
|
||||
}
|
||||
else{
|
||||
//Create foundation for log variable
|
||||
log = {"log": []};
|
||||
}
|
||||
|
||||
var length = Object.keys(log.log).length;
|
||||
var row;
|
||||
if(length != 0)
|
||||
{
|
||||
for(var i=0; i<length;i++)
|
||||
{
|
||||
row = "<tr>"
|
||||
+ "<td>"+log.log[i].before+"</td>"
|
||||
+ "<td>"+log.log[i].after+"</td>"
|
||||
+ "<td>"+log.log[i].rule+"</td>"
|
||||
+ "<td>"+toDate(log.log[i].timestamp)+"</td>";
|
||||
$('#tbody').append(row);
|
||||
}
|
||||
}
|
||||
$('#logTable').DataTable({
|
||||
"pageLength": 5
|
||||
} ).order([3, 'desc']).draw();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert timestamp to date
|
||||
*/
|
||||
function toDate(time)
|
||||
{
|
||||
return new Date(time).toLocaleString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load only when document is ready
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
getLog();
|
||||
$('#reset_log_btn').on("click", resetGlobalLog);
|
||||
});
|
||||
Reference in New Issue
Block a user