mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Standalone open curly brackets for if and for statements
For code consistency all opening curly brackets for if and for statements now stand alone on their own lines Signed-off-by: Rob Gill <rrobgill@protonmail.com>
This commit is contained in:
+41
-21
@@ -15,14 +15,15 @@ function padNumber(num) {
|
||||
|
||||
// Helper function needed for converting the Objects to Arrays
|
||||
|
||||
function objectToArray(p){
|
||||
function objectToArray(p) {
|
||||
var keys = Object.keys(p);
|
||||
keys.sort(function(a, b) {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
var arr = [], idx = [];
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
for (var i = 0; i < keys.length; i++)
|
||||
{
|
||||
arr.push(p[keys[i]]);
|
||||
idx.push(keys[i]);
|
||||
}
|
||||
@@ -34,14 +35,16 @@ var lastTooltipTime = 0;
|
||||
var customTooltips = function(tooltip) {
|
||||
// Tooltip Element
|
||||
var tooltipEl = document.getElementById("chartjs-tooltip");
|
||||
if (!tooltipEl) {
|
||||
if (!tooltipEl)
|
||||
{
|
||||
tooltipEl = document.createElement("div");
|
||||
tooltipEl.id = "chartjs-tooltip";
|
||||
document.body.appendChild(tooltipEl);
|
||||
$(tooltipEl).html("<table></table>");
|
||||
}
|
||||
// Hide if no tooltip
|
||||
if (tooltip.opacity === 0) {
|
||||
if (tooltip.opacity === 0)
|
||||
{
|
||||
tooltipEl.style.opacity = 0;
|
||||
return;
|
||||
}
|
||||
@@ -49,14 +52,16 @@ var customTooltips = function(tooltip) {
|
||||
// Limit rendering to once every 50ms. This gives the DOM time to react,
|
||||
// and avoids "lag" caused by not giving the DOM time to reapply CSS.
|
||||
var now = Date.now();
|
||||
if(now - lastTooltipTime < 50) {
|
||||
if(now - lastTooltipTime < 50)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastTooltipTime = now;
|
||||
|
||||
// Set caret Position
|
||||
tooltipEl.classList.remove("above", "below", "no-transform");
|
||||
if (tooltip.yAlign) {
|
||||
if (tooltip.yAlign)
|
||||
{
|
||||
tooltipEl.classList.add(tooltip.yAlign);
|
||||
} else {
|
||||
tooltipEl.classList.add("above");
|
||||
@@ -65,7 +70,8 @@ var customTooltips = function(tooltip) {
|
||||
return bodyItem.lines;
|
||||
}
|
||||
// Set Text
|
||||
if (tooltip.body) {
|
||||
if (tooltip.body)
|
||||
{
|
||||
var titleLines = tooltip.title || [];
|
||||
var bodyLines = tooltip.body.map(getBody);
|
||||
var innerHtml = "<table><thead>";
|
||||
@@ -139,8 +145,10 @@ function updateQueriesOverTime() {
|
||||
timeLineChart.data.datasets[1].data = [];
|
||||
|
||||
// Add data for each hour that is available
|
||||
for (var hour in data.ads_over_time[0]) {
|
||||
if ({}.hasOwnProperty.call(data.ads_over_time[0], hour)) {
|
||||
for (var hour in data.ads_over_time[0])
|
||||
{
|
||||
if ({}.hasOwnProperty.call(data.ads_over_time[0], hour))
|
||||
{
|
||||
var d,h;
|
||||
h = parseInt(data.domains_over_time[0][hour]);
|
||||
if(parseInt(data.ads_over_time[0][0]) < 1200)
|
||||
@@ -201,8 +209,10 @@ function updateQueryTypesOverTime() {
|
||||
queryTypeChart.data.datasets[1].backgroundColor = colors[1];
|
||||
|
||||
// Add data for each hour that is available
|
||||
for (var j in timestamps) {
|
||||
if ({}.hasOwnProperty.call(timestamps, j)) {
|
||||
for (var j in timestamps)
|
||||
{
|
||||
if ({}.hasOwnProperty.call(timestamps, j))
|
||||
{
|
||||
var d,h;
|
||||
h = parseInt(timestamps[j]);
|
||||
// New style: Get Unix timestamps
|
||||
@@ -307,7 +317,8 @@ function updateForwardedOverTime() {
|
||||
var key, i, j;
|
||||
for (key in data.forward_destinations)
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(data.forward_destinations, key)) {
|
||||
if (!{}.hasOwnProperty.call(data.forward_destinations, key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(key.indexOf("|") > -1)
|
||||
@@ -346,12 +357,14 @@ function updateForwardedOverTime() {
|
||||
// Add data for each dataset that is available
|
||||
for (j in timestamps)
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(timestamps, j)) {
|
||||
if (!{}.hasOwnProperty.call(timestamps, j))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (key in plotdata[j])
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(plotdata[j], key)) {
|
||||
if (!{}.hasOwnProperty.call(plotdata[j], key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
forwardDestinationChart.data.datasets[key].data.push(1e-2*plotdata[j][key]);
|
||||
@@ -402,7 +415,8 @@ function updateClientsOverTime() {
|
||||
var key, i, j;
|
||||
for (key in data.clients)
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(data.clients, key)) {
|
||||
if (!{}.hasOwnProperty.call(data.clients, key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var clientname;
|
||||
@@ -444,12 +458,14 @@ function updateClientsOverTime() {
|
||||
// Add data for each dataset that is available
|
||||
for (j in timestamps)
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(timestamps, j)) {
|
||||
if (!{}.hasOwnProperty.call(timestamps, j))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (key in plotdata[j])
|
||||
{
|
||||
if (!{}.hasOwnProperty.call(plotdata[j], key)) {
|
||||
if (!{}.hasOwnProperty.call(plotdata[j], key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
clientsChart.data.datasets[key].data.push(plotdata[j][key]);
|
||||
@@ -597,7 +613,8 @@ function updateTopClientsChart() {
|
||||
// Clear tables before filling them with data
|
||||
$("#client-frequency-blocked td").parent().remove();
|
||||
var clientblockedtable = $("#client-frequency-blocked").find("tbody:last");
|
||||
for (client in data.top_sources_blocked) {
|
||||
for (client in data.top_sources_blocked)
|
||||
{
|
||||
|
||||
if ({}.hasOwnProperty.call(data.top_sources_blocked, client)){
|
||||
// Sanitize client
|
||||
@@ -660,7 +677,8 @@ function updateTopLists() {
|
||||
var domaintable = $("#domain-frequency").find("tbody:last");
|
||||
var adtable = $("#ad-frequency").find("tbody:last");
|
||||
var url, domain, percentage;
|
||||
for (domain in data.top_queries) {
|
||||
for (domain in data.top_queries)
|
||||
{
|
||||
if ({}.hasOwnProperty.call(data.top_queries,domain)){
|
||||
// Sanitize domain
|
||||
if(escapeHtml(domain) !== domain)
|
||||
@@ -683,7 +701,8 @@ function updateTopLists() {
|
||||
$("#domain-frequency").parent().remove();
|
||||
}
|
||||
|
||||
for (domain in data.top_ads) {
|
||||
for (domain in data.top_ads)
|
||||
{
|
||||
if ({}.hasOwnProperty.call(data.top_ads,domain)){
|
||||
// Sanitize domain
|
||||
if(escapeHtml(domain) !== domain)
|
||||
@@ -716,7 +735,8 @@ function updateTopLists() {
|
||||
var FTLoffline = false;
|
||||
function updateSummaryData(runOnce) {
|
||||
var setTimer = function(timeInSeconds) {
|
||||
if (!runOnce) {
|
||||
if (!runOnce)
|
||||
{
|
||||
setTimeout(updateSummaryData, timeInSeconds * 1000);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user