Add new design

This commit is contained in:
Kevin Röbert 2017-08-31 21:19:32 +02:00
parent 0a13f134b0
commit a75daa0d28
5 changed files with 236 additions and 0 deletions

7
bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

6
bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

5
popper.min.js vendored Normal file

File diff suppressed because one or more lines are too long

83
popup_new.html Normal file
View File

@ -0,0 +1,83 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="switchButtons.css">
</head>
<body>
<div class="container-fluid" style="background: url('img-noise-361x370.png');background-size: auto;">
<div class="row">
<nav class="col-sm-1 navbar navbar-dark bg-dark">
<span class="navbar-brand">
<img src="icon38.png" width="30" height="30" class="d-inline-block align-top" alt="">
ClearURLs
</span>
</nav>
</div>
<br>
<div class="row">
<div class="col-sm-1">
<h5>Configs</h5>
<label class="switch">
<input type="checkbox" id="globalStatus">
<span class="slider round"></span>
<label>Filters</label>
</label>
<br>
<label class="switch">
<input type="checkbox" id="tabcounter">
<span class="slider round"></span>
<label>Toolbar counter</label>
</label>
</div>
</div>
<br>
<div class="row">
<div class="col-sm-1">
<h5>Statistics</h5>
<div class="progress">
<div class="progress-bar bg-danger" role="progressbar" style="width: 0%" id="progress_blocked"></div>
<div class="progress-bar bg-info" role="progressbar" style="width: 100%" id="progress_non_blocked"></div>
</div>
<br>
<h6>Total elements</h6>
<p class="text-info text-right" id="statistics_total_elements"></p>
<h6>Total blocked elements</h6>
<p class="text-danger text-right" id="statistics_value"></p>
<h6>Percentage of total traffic</h6>
<p class="text-right" id="statistics_value_global_percentage"></p>
<p class="text-center">
<button type="button" id="reset_counter_btn" class="btn btn-outline-danger" title="Reset the global statistics">Reset counter</button>
</p>
</div>
</div>
<footer>
<div class="row">
<div class="col-sm-1 bg-dark text-center">
<small class="text-muted">Version 1.1.2.0</small>
</div>
</div>
</footer>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="jquery-3.2.1.min.js"></script>
<script src="popper.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="popup_new.js"></script>
</body>
</html>

135
popup_new.js Normal file
View File

@ -0,0 +1,135 @@
/**
* Initialize the UI.
*
*/
function init()
{
setGlobalStatus();
changeStatistics();
setTabcounter();
}
/**
* Get the globalCounter value from the browser storage
* @param {(data){} Return value form browser.storage.local.get
*/
function changeStatistics(){
var element = $("#statistics_value");
var elGlobalPercentage = $("#statistics_value_global_percentage");
var elProgressbar_blocked = $('#progress_blocked');
var elProgressbar_non_blocked = $('#progress_non_blocked');
var elTotal = $('#statistics_total_elements');
var globalPercentage = 0;
var globalCounter;
var globalURLCounter;
browser.storage.local.get('globalCounter', function(data){
if(data.globalCounter){
globalCounter = data.globalCounter;
}
else {
globalCounter = 0;
}
element.text(globalCounter.toLocaleString());
});
browser.storage.local.get('globalURLCounter', function(data){
if(data.globalURLCounter){
globalURLCounter = data.globalURLCounter;
}
else {
globalURLCounter = 0;
}
globalPercentage = ((globalCounter/globalURLCounter)*100).toFixed(3);
if(isNaN(Number(globalPercentage))) globalPercentage = 0;
elGlobalPercentage.text(globalPercentage+"%");
elProgressbar_blocked.css('width', globalPercentage+'%');
elProgressbar_non_blocked.css('width', (100-globalPercentage)+'%');
elTotal.text(globalURLCounter);
});
};
/**
* Change the value of the globalStatus.
* Call by onChange()
*
*/
function changeGlobalStatus() {
var element = $('#globalStatus').is(':checked');
browser.storage.local.set({'globalStatus': element});
};
/**
* Set the values for the global status switch
*/
function setGlobalStatus() {
var element = $('#globalStatus');
browser.storage.local.get('globalStatus', function(data) {
if(data.globalStatus) {
element.prop('checked', true);
}
else if(data.globalStatus === null || typeof(data.globalStatus) == "undefined"){
element.prop('checked', true);
browser.storage.local.set({'globalStatus': true});
}
else {
element.prop('checked', false);
}
});
};
/**
* Change the value of the badgedStatus.
* Call by onChange()
*
*/
function changeTabcounter() {
var element = $('#tabcounter').is(':checked');
browser.storage.local.set({'badgedStatus': element});
};
/**
* Set the values for the tabcounter switch
*/
function setTabcounter() {
var element = $('#tabcounter');
browser.storage.local.get('badgedStatus', function(data) {
if(data.badgedStatus)
{
element.prop('checked', true);
}
else if(data.badgedStatus === null || typeof(data.badgedStatus) == "undefined"){
element.prop('checked', true);
browser.storage.local.set({'badgedStatus': true});
}
else {
element.prop('checked', false);
}
});
}
/**
* Reset the global statistic
*
*/
function resetGlobalCounter(){
browser.storage.local.set({"globalCounter": 0});
browser.storage.local.set({"globalURLCounter": 0});
};
$(document).ready(function(){
init();
$("#globalStatus").on("change", changeGlobalStatus);
$('#reset_counter_btn').on("click", resetGlobalCounter);
$('#tabcounter').on('change', changeTabcounter);
browser.storage.onChanged.addListener(changeStatistics);
});