mirror of
https://github.com/pi-hole/web.git
synced 2025-12-26 13:36:22 +00:00
Changes to formatting only (no functional changes)
Issues identified by codacy *Multiple spaces removed *piholeChanged defined before use *curly brackets after if conditions *lonely if converted to else if Signed-off-by: Rob Gill <rrobgill@protonmail.com>
This commit is contained in:
@@ -59,7 +59,7 @@ function updateTopClientsChart() {
|
||||
|
||||
// Clear tables before filling them with data
|
||||
$("#client-frequency td").parent().remove();
|
||||
var clienttable = $("#client-frequency").find("tbody:last");
|
||||
var clienttable = $("#client-frequency").find("tbody:last");
|
||||
var client, percentage, clientname, clientip;
|
||||
var sum = 0;
|
||||
for (client in data.top_sources) {
|
||||
@@ -113,7 +113,7 @@ function updateTopDomainsChart() {
|
||||
|
||||
// Clear tables before filling them with data
|
||||
$("#domain-frequency td").parent().remove();
|
||||
var domaintable = $("#domain-frequency").find("tbody:last");
|
||||
var domaintable = $("#domain-frequency").find("tbody:last");
|
||||
var domain, percentage;
|
||||
var sum = 0;
|
||||
for (domain in data.top_domains) {
|
||||
@@ -155,7 +155,7 @@ function updateTopAdsChart() {
|
||||
|
||||
// Clear tables before filling them with data
|
||||
$("#ad-frequency td").parent().remove();
|
||||
var adtable = $("#ad-frequency").find("tbody:last");
|
||||
var adtable = $("#ad-frequency").find("tbody:last");
|
||||
var ad, percentage;
|
||||
var sum = 0;
|
||||
for (ad in data.top_ads) {
|
||||
|
||||
@@ -15,24 +15,6 @@ function secondsTimeSpanToHMS(s) {
|
||||
return h+":"+(m < 10 ? "0"+m : m)+":"+(s < 10 ? "0"+s : s); //zero padding on minutes and seconds
|
||||
}
|
||||
|
||||
function countDown(){
|
||||
var ena = $("#enableLabel");
|
||||
var enaT = $("#enableTimer");
|
||||
var target = new Date(parseInt(enaT.html()));
|
||||
var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000);
|
||||
|
||||
if(seconds > 0){
|
||||
setTimeout(countDown,1000);
|
||||
ena.text("Enable (" + secondsTimeSpanToHMS(seconds) + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
ena.text("Enable");
|
||||
piholeChanged("enabled");
|
||||
localStorage.removeItem("countDownTarget");
|
||||
}
|
||||
}
|
||||
|
||||
function piholeChanged(action)
|
||||
{
|
||||
var status = $("#status");
|
||||
@@ -56,6 +38,24 @@ function piholeChanged(action)
|
||||
|
||||
}
|
||||
|
||||
function countDown(){
|
||||
var ena = $("#enableLabel");
|
||||
var enaT = $("#enableTimer");
|
||||
var target = new Date(parseInt(enaT.html()));
|
||||
var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000);
|
||||
|
||||
if(seconds > 0){
|
||||
setTimeout(countDown,1000);
|
||||
ena.text("Enable (" + secondsTimeSpanToHMS(seconds) + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
ena.text("Enable");
|
||||
piholeChanged("enabled");
|
||||
localStorage.removeItem("countDownTarget");
|
||||
}
|
||||
}
|
||||
|
||||
function piholeChange(action, duration)
|
||||
{
|
||||
var token = encodeURIComponent($("#token").html());
|
||||
|
||||
@@ -79,7 +79,7 @@ var customTooltips = function(tooltip) {
|
||||
var style = "background:" + colors.backgroundColor;
|
||||
style += "; border-color:" + colors.borderColor;
|
||||
style += "; border-width: 2px";
|
||||
var span = "<span class=\"chartjs-tooltip-key\" style=\"" + style + "\"></span>";
|
||||
var span = "<span class=\"chartjs-tooltip-key\" style=\"" + style + "\"></span>";
|
||||
var num = body[0].split(": ");
|
||||
if(num[1] > 0)
|
||||
{
|
||||
@@ -189,7 +189,7 @@ function updateQueryTypesOverTime() {
|
||||
// remove last data point since it not representative
|
||||
data.over_time[0].splice(-1,1);
|
||||
var timestamps = data.over_time[0];
|
||||
var plotdata = data.over_time[1];
|
||||
var plotdata = data.over_time[1];
|
||||
// Remove possibly already existing data
|
||||
queryTypeChart.data.labels = [];
|
||||
queryTypeChart.data.datasets[0].data = [];
|
||||
@@ -307,7 +307,9 @@ function updateForwardedOverTime() {
|
||||
var key, i, j;
|
||||
for (key in data.forward_destinations)
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(data.forward_destinations, key)) continue;
|
||||
if (!{}.hasOwnProperty.call(data.forward_destinations, key)) {
|
||||
continue;
|
||||
}
|
||||
if(key.indexOf("|") > -1)
|
||||
{
|
||||
var idx = key.indexOf("|");
|
||||
@@ -344,10 +346,14 @@ function updateForwardedOverTime() {
|
||||
// Add data for each dataset that is available
|
||||
for (j in timestamps)
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(timestamps, j)) continue;
|
||||
if (!{}.hasOwnProperty.call(timestamps, j)) {
|
||||
continue;
|
||||
}
|
||||
for (key in plotdata[j])
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(plotdata[j], key)) continue;
|
||||
if (!{}.hasOwnProperty.call(plotdata[j], key)) {
|
||||
continue;
|
||||
}
|
||||
forwardDestinationChart.data.datasets[key].data.push(1e-2*plotdata[j][key]);
|
||||
}
|
||||
|
||||
@@ -396,7 +402,9 @@ function updateClientsOverTime() {
|
||||
var key, i, j;
|
||||
for (key in data.clients)
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(data.clients, key)) continue;
|
||||
if (!{}.hasOwnProperty.call(data.clients, key)) {
|
||||
continue;
|
||||
}
|
||||
var clientname;
|
||||
if(data.clients[key].name.length > 0)
|
||||
{
|
||||
@@ -436,10 +444,14 @@ function updateClientsOverTime() {
|
||||
// Add data for each dataset that is available
|
||||
for (j in timestamps)
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(timestamps, j)) continue;
|
||||
if (!{}.hasOwnProperty.call(timestamps, j)) {
|
||||
continue;
|
||||
}
|
||||
for (key in plotdata[j])
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(plotdata[j], key)) continue;
|
||||
if (!{}.hasOwnProperty.call(plotdata[j], key)) {
|
||||
continue;
|
||||
}
|
||||
clientsChart.data.datasets[key].data.push(plotdata[j][key]);
|
||||
}
|
||||
|
||||
@@ -730,19 +742,16 @@ function updateSummaryData(runOnce) {
|
||||
|
||||
FTLoffline = true;
|
||||
}
|
||||
else
|
||||
else if(FTLoffline)
|
||||
{
|
||||
if(FTLoffline)
|
||||
{
|
||||
// FTL was previously offline
|
||||
FTLoffline = false;
|
||||
$("#temperature").text(" ");
|
||||
updateQueriesOverTime();
|
||||
updateForwardedOverTime();
|
||||
updateQueryTypesOverTime();
|
||||
updateTopClientsChart();
|
||||
updateTopLists();
|
||||
}
|
||||
// FTL was previously offline
|
||||
FTLoffline = false;
|
||||
$("#temperature").text(" ");
|
||||
updateQueriesOverTime();
|
||||
updateForwardedOverTime();
|
||||
updateQueryTypesOverTime();
|
||||
updateTopClientsChart();
|
||||
updateTopLists();
|
||||
}
|
||||
|
||||
["ads_blocked_today", "dns_queries_today", "ads_percentage_today", "unique_clients"].forEach(function(today) {
|
||||
|
||||
Reference in New Issue
Block a user