mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
committed by
dependabot-preview[bot]
parent
256887b78e
commit
ae13014565
+5
-2
@@ -23,13 +23,14 @@
|
||||
"xo": "^0.29.0"
|
||||
},
|
||||
"prettier": {
|
||||
"arrowParens": "avoid",
|
||||
"bracketSpacing": true,
|
||||
"endOfLine": "auto",
|
||||
"printWidth": 100,
|
||||
"singleQuote": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"space": 2,
|
||||
"envs": [
|
||||
"browser",
|
||||
"jquery"
|
||||
@@ -40,6 +41,7 @@
|
||||
},
|
||||
"esnext": false,
|
||||
"prettier": true,
|
||||
"space": 2,
|
||||
"ignores": [
|
||||
"**/vendor/**"
|
||||
],
|
||||
@@ -56,11 +58,12 @@
|
||||
"unicorn/filename-case": "off",
|
||||
"unicorn/no-for-loop": "off",
|
||||
"unicorn/no-zero-fractions": "off",
|
||||
"unicorn/prevent-abbreviations": "off",
|
||||
"unicorn/prefer-includes": "off",
|
||||
"unicorn/prefer-node-append": "off",
|
||||
"unicorn/prefer-number-properties": "off",
|
||||
"unicorn/prefer-query-selector": "off",
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
"unicorn/prevent-abbreviations": "off",
|
||||
"unicorn/string-content": "off"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,24 +18,20 @@ function escapeHtml(text) {
|
||||
"'": "'"
|
||||
};
|
||||
|
||||
return text.replace(/[&<>"']/g, function(m) {
|
||||
return text.replace(/[&<>"']/g, function (m) {
|
||||
return map[m];
|
||||
});
|
||||
}
|
||||
|
||||
function updateTopLists() {
|
||||
$.getJSON("api.php?topItems=audit", function(data) {
|
||||
$.getJSON("api.php?topItems=audit", function (data) {
|
||||
if ("FTLnotrunning" in data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear tables before filling them with data
|
||||
$("#domain-frequency td")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#ad-frequency td")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#domain-frequency td").parent().remove();
|
||||
$("#ad-frequency td").parent().remove();
|
||||
var domaintable = $("#domain-frequency").find("tbody:last");
|
||||
var adtable = $("#ad-frequency").find("tbody:last");
|
||||
var url, domain;
|
||||
@@ -105,10 +101,10 @@ function add(domain, list) {
|
||||
url: "scripts/pi-hole/php/add.php",
|
||||
method: "post",
|
||||
data: { domain: domain, list: list, token: token },
|
||||
success: function() {
|
||||
success: function () {
|
||||
updateTopLists();
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
console.log(exception);
|
||||
}
|
||||
});
|
||||
@@ -130,14 +126,12 @@ function auditUrl(url) {
|
||||
add(url, "audit");
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
// Pull in data via AJAX
|
||||
updateTopLists();
|
||||
|
||||
$("#domain-frequency tbody").on("click", "button", function() {
|
||||
var url = $(this)
|
||||
.parents("tr")[0]
|
||||
.textContent.split(" ")[0];
|
||||
$("#domain-frequency tbody").on("click", "button", function () {
|
||||
var url = $(this).parents("tr")[0].textContent.split(" ")[0];
|
||||
if ($(this).context.textContent === " Blacklist") {
|
||||
blacklistUrl(url);
|
||||
} else {
|
||||
@@ -145,10 +139,8 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$("#ad-frequency tbody").on("click", "button", function() {
|
||||
var url = $(this)
|
||||
.parents("tr")[0]
|
||||
.textContent.split(" ")[0];
|
||||
$("#ad-frequency tbody").on("click", "button", function () {
|
||||
var url = $(this).parents("tr")[0].textContent.split(" ")[0];
|
||||
if ($(this).context.textContent === " Whitelist") {
|
||||
whitelistUrl(url);
|
||||
} else {
|
||||
|
||||
@@ -36,7 +36,7 @@ function showAlert(type, message) {
|
||||
alertElement.delay(8000).fadeOut(2000);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$("#btnAdd").on("click", addCustomDNS);
|
||||
|
||||
table = $("#customDNSTable").DataTable({
|
||||
@@ -45,7 +45,7 @@ $(document).ready(function() {
|
||||
columnDefs: [
|
||||
{
|
||||
targets: 2,
|
||||
render: function(data, type, row) {
|
||||
render: function (data, type, row) {
|
||||
return (
|
||||
'<button class="btn btn-danger btn-xs deleteCustomDNS" type="button" data-domain=\'' +
|
||||
row[0] +
|
||||
@@ -58,7 +58,7 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
],
|
||||
drawCallback: function() {
|
||||
drawCallback: function () {
|
||||
$(".deleteCustomDNS").on("click", deleteCustomDNS);
|
||||
}
|
||||
});
|
||||
@@ -80,13 +80,13 @@ function addCustomDNS() {
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { action: "add", ip: ip, domain: domain },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
showAlert("success");
|
||||
table.ajax.reload();
|
||||
} else showAlert("error", response.message);
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
showAlert("error", "Error while adding this custom DNS entry");
|
||||
}
|
||||
});
|
||||
@@ -102,13 +102,13 @@ function deleteCustomDNS() {
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { action: "delete", domain: domain, ip: ip },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
showAlert("success");
|
||||
table.ajax.reload();
|
||||
} else showAlert("error", response.message);
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
showAlert("error", "Error while deleting this custom DNS entry");
|
||||
console.log(exception);
|
||||
}
|
||||
|
||||
@@ -8,22 +8,16 @@
|
||||
/* global Chart:false, moment:false */
|
||||
|
||||
var start__ = moment().subtract(6, "days");
|
||||
var from =
|
||||
moment(start__)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
var from = moment(start__).utc().valueOf() / 1000;
|
||||
var end__ = moment();
|
||||
var until =
|
||||
moment(end__)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
var until = moment(end__).utc().valueOf() / 1000;
|
||||
var interval = 0;
|
||||
|
||||
var timeoutWarning = $("#timeoutWarning");
|
||||
|
||||
var dateformat = "MMMM Do YYYY, HH:mm";
|
||||
|
||||
$(function() {
|
||||
$(function () {
|
||||
$("#querytime").daterangepicker(
|
||||
{
|
||||
timePicker: true,
|
||||
@@ -34,23 +28,15 @@ $(function() {
|
||||
ranges: {
|
||||
Today: [moment().startOf("day"), moment()],
|
||||
Yesterday: [
|
||||
moment()
|
||||
.subtract(1, "days")
|
||||
.startOf("day"),
|
||||
moment()
|
||||
.subtract(1, "days")
|
||||
.endOf("day")
|
||||
moment().subtract(1, "days").startOf("day"),
|
||||
moment().subtract(1, "days").endOf("day")
|
||||
],
|
||||
"Last 7 Days": [moment().subtract(6, "days"), moment()],
|
||||
"Last 30 Days": [moment().subtract(29, "days"), moment()],
|
||||
"This Month": [moment().startOf("month"), moment()],
|
||||
"Last Month": [
|
||||
moment()
|
||||
.subtract(1, "month")
|
||||
.startOf("month"),
|
||||
moment()
|
||||
.subtract(1, "month")
|
||||
.endOf("month")
|
||||
moment().subtract(1, "month").startOf("month"),
|
||||
moment().subtract(1, "month").endOf("month")
|
||||
],
|
||||
"This Year": [moment().startOf("year"), moment()],
|
||||
"All Time": [moment(0), moment()]
|
||||
@@ -59,15 +45,9 @@ $(function() {
|
||||
showDropdowns: true,
|
||||
autoUpdateInput: false
|
||||
},
|
||||
function(startt, endt) {
|
||||
from =
|
||||
moment(startt)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
until =
|
||||
moment(endt)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
function (startt, endt) {
|
||||
from = moment(startt).utc().valueOf() / 1000;
|
||||
until = moment(endt).utc().valueOf() / 1000;
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -80,7 +60,7 @@ function padNumber(num) {
|
||||
|
||||
function objectToArray(p) {
|
||||
var keys = Object.keys(p);
|
||||
keys.sort(function(a, b) {
|
||||
keys.sort(function (a, b) {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
@@ -128,7 +108,7 @@ function updateQueriesOverTime() {
|
||||
|
||||
$.getJSON(
|
||||
"api_db.php?getGraphData&from=" + from + "&until=" + until + "&interval=" + interval,
|
||||
function(data) {
|
||||
function (data) {
|
||||
// convert received objects to arrays
|
||||
data.domains_over_time = objectToArray(data.domains_over_time);
|
||||
data.ads_over_time = objectToArray(data.ads_over_time);
|
||||
@@ -188,7 +168,7 @@ function updateQueriesOverTime() {
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
var ctx = document.getElementById("queryOverTimeChart").getContext("2d");
|
||||
timeLineChart = new Chart(ctx, {
|
||||
type: "bar",
|
||||
@@ -224,7 +204,7 @@ $(document).ready(function() {
|
||||
enabled: true,
|
||||
mode: "x-axis",
|
||||
callbacks: {
|
||||
title: function(tooltipItem) {
|
||||
title: function (tooltipItem) {
|
||||
var label = tooltipItem[0].xLabel;
|
||||
var time = new Date(label);
|
||||
var from_date =
|
||||
@@ -254,7 +234,7 @@ $(document).ready(function() {
|
||||
padNumber(time.getSeconds());
|
||||
return "Queries from " + from_date + " to " + until_date;
|
||||
},
|
||||
label: function(tooltipItems, data) {
|
||||
label: function (tooltipItems, data) {
|
||||
if (tooltipItems.datasetIndex === 1) {
|
||||
var percentage = 0.0;
|
||||
var total = parseInt(data.datasets[0].data[tooltipItems.index]);
|
||||
@@ -313,13 +293,13 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
|
||||
$("#querytime").on("apply.daterangepicker", function(ev, picker) {
|
||||
$("#querytime").on("apply.daterangepicker", function (ev, picker) {
|
||||
$(this).val(picker.startDate.format(dateformat) + " to " + picker.endDate.format(dateformat));
|
||||
$("#queries-over-time").show();
|
||||
updateQueriesOverTime();
|
||||
});
|
||||
|
||||
$("#queryOverTimeChart").click(function(evt) {
|
||||
$("#queryOverTimeChart").click(function (evt) {
|
||||
var activePoints = timeLineChart.getElementAtEvent(evt);
|
||||
if (activePoints.length > 0) {
|
||||
//get the internal index in the chart
|
||||
|
||||
@@ -8,22 +8,16 @@
|
||||
/* global moment:false */
|
||||
|
||||
var start__ = moment().subtract(6, "days");
|
||||
var from =
|
||||
moment(start__)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
var from = moment(start__).utc().valueOf() / 1000;
|
||||
var end__ = moment();
|
||||
var until =
|
||||
moment(end__)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
var until = moment(end__).utc().valueOf() / 1000;
|
||||
|
||||
var timeoutWarning = $("#timeoutWarning");
|
||||
var listsStillLoading = 0;
|
||||
|
||||
var dateformat = "MMMM Do YYYY, HH:mm";
|
||||
|
||||
$(function() {
|
||||
$(function () {
|
||||
$("#querytime").daterangepicker(
|
||||
{
|
||||
timePicker: true,
|
||||
@@ -34,23 +28,15 @@ $(function() {
|
||||
ranges: {
|
||||
Today: [moment().startOf("day"), moment()],
|
||||
Yesterday: [
|
||||
moment()
|
||||
.subtract(1, "days")
|
||||
.startOf("day"),
|
||||
moment()
|
||||
.subtract(1, "days")
|
||||
.endOf("day")
|
||||
moment().subtract(1, "days").startOf("day"),
|
||||
moment().subtract(1, "days").endOf("day")
|
||||
],
|
||||
"Last 7 Days": [moment().subtract(6, "days"), moment()],
|
||||
"Last 30 Days": [moment().subtract(29, "days"), moment()],
|
||||
"This Month": [moment().startOf("month"), moment()],
|
||||
"Last Month": [
|
||||
moment()
|
||||
.subtract(1, "month")
|
||||
.startOf("month"),
|
||||
moment()
|
||||
.subtract(1, "month")
|
||||
.endOf("month")
|
||||
moment().subtract(1, "month").startOf("month"),
|
||||
moment().subtract(1, "month").endOf("month")
|
||||
],
|
||||
"This Year": [moment().startOf("year"), moment()],
|
||||
"All Time": [moment(0), moment()]
|
||||
@@ -59,15 +45,9 @@ $(function() {
|
||||
showDropdowns: true,
|
||||
autoUpdateInput: false
|
||||
},
|
||||
function(startt, endt) {
|
||||
from =
|
||||
moment(startt)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
until =
|
||||
moment(endt)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
function (startt, endt) {
|
||||
from = moment(startt).utc().valueOf() / 1000;
|
||||
until = moment(endt).utc().valueOf() / 1000;
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -82,18 +62,16 @@ function escapeHtml(text) {
|
||||
"'": "'"
|
||||
};
|
||||
|
||||
return text.replace(/[&<>"']/g, function(m) {
|
||||
return text.replace(/[&<>"']/g, function (m) {
|
||||
return map[m];
|
||||
});
|
||||
}
|
||||
|
||||
function updateTopClientsChart() {
|
||||
$("#client-frequency .overlay").show();
|
||||
$.getJSON("api_db.php?topClients&from=" + from + "&until=" + until, function(data) {
|
||||
$.getJSON("api_db.php?topClients&from=" + from + "&until=" + until, function (data) {
|
||||
// Clear tables before filling them with data
|
||||
$("#client-frequency td")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#client-frequency td").parent().remove();
|
||||
var clienttable = $("#client-frequency").find("tbody:last");
|
||||
var client, percentage, clientname;
|
||||
var sum = 0;
|
||||
@@ -145,11 +123,9 @@ function updateTopClientsChart() {
|
||||
|
||||
function updateTopDomainsChart() {
|
||||
$("#domain-frequency .overlay").show();
|
||||
$.getJSON("api_db.php?topDomains&from=" + from + "&until=" + until, function(data) {
|
||||
$.getJSON("api_db.php?topDomains&from=" + from + "&until=" + until, function (data) {
|
||||
// Clear tables before filling them with data
|
||||
$("#domain-frequency td")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#domain-frequency td").parent().remove();
|
||||
var domaintable = $("#domain-frequency").find("tbody:last");
|
||||
var domain, percentage;
|
||||
var sum = 0;
|
||||
@@ -194,11 +170,9 @@ function updateTopDomainsChart() {
|
||||
|
||||
function updateTopAdsChart() {
|
||||
$("#ad-frequency .overlay").show();
|
||||
$.getJSON("api_db.php?topAds&from=" + from + "&until=" + until, function(data) {
|
||||
$.getJSON("api_db.php?topAds&from=" + from + "&until=" + until, function (data) {
|
||||
// Clear tables before filling them with data
|
||||
$("#ad-frequency td")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#ad-frequency td").parent().remove();
|
||||
var adtable = $("#ad-frequency").find("tbody:last");
|
||||
var ad, percentage;
|
||||
var sum = 0;
|
||||
@@ -241,7 +215,7 @@ function updateTopAdsChart() {
|
||||
});
|
||||
}
|
||||
|
||||
$("#querytime").on("apply.daterangepicker", function(ev, picker) {
|
||||
$("#querytime").on("apply.daterangepicker", function (ev, picker) {
|
||||
$(this).val(picker.startDate.format(dateformat) + " to " + picker.endDate.format(dateformat));
|
||||
timeoutWarning.show();
|
||||
listsStillLoading = 3;
|
||||
|
||||
@@ -8,15 +8,9 @@
|
||||
/* global moment:false */
|
||||
|
||||
var start__ = moment().subtract(6, "days");
|
||||
var from =
|
||||
moment(start__)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
var from = moment(start__).utc().valueOf() / 1000;
|
||||
var end__ = moment();
|
||||
var until =
|
||||
moment(end__)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
var until = moment(end__).utc().valueOf() / 1000;
|
||||
var instantquery = false;
|
||||
var daterange;
|
||||
|
||||
@@ -29,7 +23,7 @@ var GETDict = {};
|
||||
window.location.search
|
||||
.substr(1)
|
||||
.split("&")
|
||||
.forEach(function(item) {
|
||||
.forEach(function (item) {
|
||||
GETDict[item.split("=")[0]] = item.split("=")[1];
|
||||
});
|
||||
|
||||
@@ -41,7 +35,7 @@ if ("from" in GETDict && "until" in GETDict) {
|
||||
instantquery = true;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$(function () {
|
||||
daterange = $("#querytime").daterangepicker(
|
||||
{
|
||||
timePicker: true,
|
||||
@@ -52,23 +46,15 @@ $(function() {
|
||||
ranges: {
|
||||
Today: [moment().startOf("day"), moment()],
|
||||
Yesterday: [
|
||||
moment()
|
||||
.subtract(1, "days")
|
||||
.startOf("day"),
|
||||
moment()
|
||||
.subtract(1, "days")
|
||||
.endOf("day")
|
||||
moment().subtract(1, "days").startOf("day"),
|
||||
moment().subtract(1, "days").endOf("day")
|
||||
],
|
||||
"Last 7 Days": [moment().subtract(6, "days"), moment()],
|
||||
"Last 30 Days": [moment().subtract(29, "days"), moment()],
|
||||
"This Month": [moment().startOf("month"), moment()],
|
||||
"Last Month": [
|
||||
moment()
|
||||
.subtract(1, "month")
|
||||
.startOf("month"),
|
||||
moment()
|
||||
.subtract(1, "month")
|
||||
.endOf("month")
|
||||
moment().subtract(1, "month").startOf("month"),
|
||||
moment().subtract(1, "month").endOf("month")
|
||||
],
|
||||
"This Year": [moment().startOf("year"), moment()],
|
||||
"All Time": [moment(0), moment()]
|
||||
@@ -77,15 +63,9 @@ $(function() {
|
||||
showDropdowns: true,
|
||||
autoUpdateInput: false
|
||||
},
|
||||
function(startt, endt) {
|
||||
from =
|
||||
moment(startt)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
until =
|
||||
moment(endt)
|
||||
.utc()
|
||||
.valueOf() / 1000;
|
||||
function (startt, endt) {
|
||||
from = moment(startt).utc().valueOf() / 1000;
|
||||
until = moment(endt).utc().valueOf() / 1000;
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -115,36 +95,36 @@ function add(domain, list) {
|
||||
url: "scripts/pi-hole/php/add.php",
|
||||
method: "post",
|
||||
data: { domain: domain, list: list, token: token },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
if (
|
||||
response.indexOf("not a valid argument") >= 0 ||
|
||||
response.indexOf("is not a valid domain") >= 0
|
||||
) {
|
||||
alFailure.show();
|
||||
err.html(response);
|
||||
alFailure.delay(4000).fadeOut(2000, function() {
|
||||
alFailure.delay(4000).fadeOut(2000, function () {
|
||||
alFailure.hide();
|
||||
});
|
||||
} else {
|
||||
alSuccess.show();
|
||||
alSuccess.delay(1000).fadeOut(2000, function() {
|
||||
alSuccess.delay(1000).fadeOut(2000, function () {
|
||||
alSuccess.hide();
|
||||
});
|
||||
}
|
||||
|
||||
alInfo.delay(1000).fadeOut(2000, function() {
|
||||
alInfo.delay(1000).fadeOut(2000, function () {
|
||||
alInfo.hide();
|
||||
alList.html("");
|
||||
alDomain.html("");
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
alFailure.show();
|
||||
err.html("");
|
||||
alFailure.delay(1000).fadeOut(2000, function() {
|
||||
alFailure.delay(1000).fadeOut(2000, function () {
|
||||
alFailure.hide();
|
||||
});
|
||||
alInfo.delay(1000).fadeOut(2000, function() {
|
||||
alInfo.delay(1000).fadeOut(2000, function () {
|
||||
alInfo.hide();
|
||||
alList.html("");
|
||||
alDomain.html("");
|
||||
@@ -210,7 +190,7 @@ function getQueryTypes() {
|
||||
return queryType.join(",");
|
||||
}
|
||||
|
||||
var reloadCallback = function() {
|
||||
var reloadCallback = function () {
|
||||
timeoutWarning.hide();
|
||||
statistics = [0, 0, 0, 0];
|
||||
var data = tableApi.rows().data();
|
||||
@@ -234,11 +214,7 @@ var reloadCallback = function() {
|
||||
percent = (100.0 * (statistics[2] + statistics[3])) / statistics[0];
|
||||
}
|
||||
|
||||
$("h3#ads_percentage_today").text(
|
||||
parseFloat(percent)
|
||||
.toFixed(1)
|
||||
.toLocaleString() + " %"
|
||||
);
|
||||
$("h3#ads_percentage_today").text(parseFloat(percent).toFixed(1).toLocaleString() + " %");
|
||||
};
|
||||
|
||||
function refreshTableData() {
|
||||
@@ -254,7 +230,7 @@ function refreshTableData() {
|
||||
tableApi.ajax.url(APIstring).load(reloadCallback);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
var APIstring;
|
||||
|
||||
if (instantquery) {
|
||||
@@ -271,7 +247,7 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
tableApi = $("#all-queries").DataTable({
|
||||
rowCallback: function(row, data) {
|
||||
rowCallback: function (row, data) {
|
||||
var fieldtext, buttontext, color;
|
||||
switch (data[4]) {
|
||||
case 1:
|
||||
@@ -355,9 +331,9 @@ $(document).ready(function() {
|
||||
ajax: {
|
||||
url: APIstring,
|
||||
error: handleAjaxError,
|
||||
dataSrc: function(data) {
|
||||
dataSrc: function (data) {
|
||||
var dataIndex = 0;
|
||||
return data.data.map(function(x) {
|
||||
return data.data.map(function (x) {
|
||||
x[0] = x[0] * 1e6 + dataIndex++;
|
||||
return x;
|
||||
});
|
||||
@@ -370,7 +346,7 @@ $(document).ready(function() {
|
||||
columns: [
|
||||
{
|
||||
width: "15%",
|
||||
render: function(data, type) {
|
||||
render: function (data, type) {
|
||||
if (type === "display") {
|
||||
return moment
|
||||
.unix(Math.floor(data / 1e6))
|
||||
@@ -399,7 +375,7 @@ $(document).ready(function() {
|
||||
],
|
||||
initComplete: reloadCallback
|
||||
});
|
||||
$("#all-queries tbody").on("click", "button", function() {
|
||||
$("#all-queries tbody").on("click", "button", function () {
|
||||
var data = tableApi.row($(this).parents("tr")).data();
|
||||
if (data[4] === 1 || data[4] === 4 || data[5] === 5) {
|
||||
add(data[2], "white");
|
||||
@@ -413,7 +389,7 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$("#querytime").on("apply.daterangepicker", function(ev, picker) {
|
||||
$("#querytime").on("apply.daterangepicker", function (ev, picker) {
|
||||
$(this).val(picker.startDate.format(dateformat) + " to " + picker.endDate.format(dateformat));
|
||||
refreshTableData();
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ function httpGet(ta, theUrl) {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
xmlhttp.onreadystatechange = function () {
|
||||
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
|
||||
ta.show();
|
||||
ta.empty();
|
||||
@@ -54,7 +54,7 @@ function eventsource() {
|
||||
|
||||
source.addEventListener(
|
||||
"message",
|
||||
function(e) {
|
||||
function (e) {
|
||||
ta.append(e.data);
|
||||
},
|
||||
false
|
||||
@@ -63,14 +63,14 @@ function eventsource() {
|
||||
// Will be called when script has finished
|
||||
source.addEventListener(
|
||||
"error",
|
||||
function() {
|
||||
function () {
|
||||
source.close();
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
$("#debugBtn").on("click", function() {
|
||||
$("#debugBtn").on("click", function () {
|
||||
$("#debugBtn").attr("disabled", true);
|
||||
$("#upload").attr("disabled", true);
|
||||
eventsource();
|
||||
|
||||
@@ -65,7 +65,7 @@ function piholeChange(action, duration) {
|
||||
case "enable":
|
||||
btnStatus = $("#flip-status-enable");
|
||||
btnStatus.html("<i class='fa fa-spinner'> </i>");
|
||||
$.getJSON("api.php?enable&token=" + token, function(data) {
|
||||
$.getJSON("api.php?enable&token=" + token, function (data) {
|
||||
if (data.status === "enabled") {
|
||||
btnStatus.html("");
|
||||
piholeChanged("enabled");
|
||||
@@ -76,7 +76,7 @@ function piholeChange(action, duration) {
|
||||
case "disable":
|
||||
btnStatus = $("#flip-status-disable");
|
||||
btnStatus.html("<i class='fa fa-spinner'> </i>");
|
||||
$.getJSON("api.php?disable=" + duration + "&token=" + token, function(data) {
|
||||
$.getJSON("api.php?disable=" + duration + "&token=" + token, function (data) {
|
||||
if (data.status === "disabled") {
|
||||
btnStatus.html("");
|
||||
piholeChanged("disabled");
|
||||
@@ -93,7 +93,7 @@ function piholeChange(action, duration) {
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
var enaT = $("#enableTimer");
|
||||
var target = new Date(parseInt(enaT.html()));
|
||||
var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000);
|
||||
@@ -103,28 +103,28 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
// Handle Enable/Disable
|
||||
$("#pihole-enable").on("click", function(e) {
|
||||
$("#pihole-enable").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
localStorage.removeItem("countDownTarget");
|
||||
piholeChange("enable", "");
|
||||
});
|
||||
$("#pihole-disable-permanently").on("click", function(e) {
|
||||
$("#pihole-disable-permanently").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
piholeChange("disable", "0");
|
||||
});
|
||||
$("#pihole-disable-10s").on("click", function(e) {
|
||||
$("#pihole-disable-10s").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
piholeChange("disable", "10");
|
||||
});
|
||||
$("#pihole-disable-30s").on("click", function(e) {
|
||||
$("#pihole-disable-30s").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
piholeChange("disable", "30");
|
||||
});
|
||||
$("#pihole-disable-5m").on("click", function(e) {
|
||||
$("#pihole-disable-5m").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
piholeChange("disable", "300");
|
||||
});
|
||||
$("#pihole-disable-custom").on("click", function(e) {
|
||||
$("#pihole-disable-custom").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var custVal = $("#customTimeout").val();
|
||||
custVal = $("#btnMins").hasClass("active") ? custVal * 60 : custVal;
|
||||
@@ -145,7 +145,7 @@ if (sessionvalidity > 0) {
|
||||
// setSeconds will correctly handle wrap-around cases
|
||||
updateSessionTimer();
|
||||
|
||||
setInterval(function() {
|
||||
setInterval(function () {
|
||||
var current = new Date();
|
||||
var totalseconds = (start - current) / 1000;
|
||||
var minutes = Math.floor(totalseconds / 60);
|
||||
@@ -169,7 +169,7 @@ if (sessionvalidity > 0) {
|
||||
}
|
||||
|
||||
// Handle Strg + Enter button on Login page
|
||||
$(document).keypress(function(e) {
|
||||
$(document).keypress(function (e) {
|
||||
if ((e.keyCode === 10 || e.keyCode === 13) && e.ctrlKey && $("#loginpw").is(":focus")) {
|
||||
$("#loginform").attr("action", "settings.php");
|
||||
$("#loginform").submit();
|
||||
@@ -191,7 +191,7 @@ function testCookies() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$(function () {
|
||||
if (!testCookies() && $("#cookieInfo").length) {
|
||||
$("#cookieInfo").show();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ function eventsource() {
|
||||
|
||||
source.addEventListener(
|
||||
"message",
|
||||
function(e) {
|
||||
function (e) {
|
||||
if (e.data.indexOf("Pi-hole blocking is") !== -1) {
|
||||
alSuccess.show();
|
||||
}
|
||||
@@ -46,8 +46,8 @@ function eventsource() {
|
||||
// Will be called when script has finished
|
||||
source.addEventListener(
|
||||
"error",
|
||||
function() {
|
||||
alInfo.delay(1000).fadeOut(2000, function() {
|
||||
function () {
|
||||
alInfo.delay(1000).fadeOut(2000, function () {
|
||||
alInfo.hide();
|
||||
});
|
||||
source.close();
|
||||
@@ -57,14 +57,14 @@ function eventsource() {
|
||||
);
|
||||
}
|
||||
|
||||
$("#gravityBtn").on("click", function() {
|
||||
$("#gravityBtn").on("click", function () {
|
||||
$("#gravityBtn").attr("disabled", true);
|
||||
eventsource();
|
||||
});
|
||||
|
||||
// Handle hiding of alerts
|
||||
$(function() {
|
||||
$("[data-hide]").on("click", function() {
|
||||
$(function () {
|
||||
$("[data-hide]").on("click", function () {
|
||||
$(this)
|
||||
.closest("." + $(this).attr("data-hide"))
|
||||
.hide();
|
||||
|
||||
@@ -15,7 +15,7 @@ function get_groups() {
|
||||
$.post(
|
||||
"scripts/pi-hole/php/groups.php",
|
||||
{ action: "get_groups", token: token },
|
||||
function(data) {
|
||||
function (data) {
|
||||
groups = data.data;
|
||||
initTable();
|
||||
},
|
||||
@@ -23,7 +23,7 @@ function get_groups() {
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$("#btnAdd").on("click", addAdlist);
|
||||
|
||||
get_groups();
|
||||
@@ -52,10 +52,10 @@ function initTable() {
|
||||
{ data: "groups", searchable: false },
|
||||
{ data: null, width: "80px", orderable: false }
|
||||
],
|
||||
drawCallback: function() {
|
||||
drawCallback: function () {
|
||||
$('button[id^="deleteAdlist_"]').on("click", deleteAdlist);
|
||||
},
|
||||
rowCallback: function(row, data) {
|
||||
rowCallback: function (row, data) {
|
||||
$(row).attr("data-id", data.id);
|
||||
var tooltip =
|
||||
"Added: " +
|
||||
@@ -124,7 +124,7 @@ function initTable() {
|
||||
includeSelectAllOption: true,
|
||||
buttonContainer: '<div id="container_' + data.id + '" class="btn-group"/>',
|
||||
maxHeight: 200,
|
||||
onDropdownShown: function() {
|
||||
onDropdownShown: function () {
|
||||
var el = $("#container_" + data.id);
|
||||
var top = el[0].getBoundingClientRect().top;
|
||||
var bottom = $(window).height() - top - el.height();
|
||||
@@ -142,7 +142,7 @@ function initTable() {
|
||||
el.css("top", offset.top + "px");
|
||||
el.css("left", offset.left + "px");
|
||||
},
|
||||
onDropdownHide: function() {
|
||||
onDropdownHide: function () {
|
||||
var el = $("#container_" + data.id);
|
||||
var home = $("#selectHome_" + data.id);
|
||||
home.append(el);
|
||||
@@ -168,11 +168,11 @@ function initTable() {
|
||||
[10, 25, 50, 100, "All"]
|
||||
],
|
||||
stateSave: true,
|
||||
stateSaveCallback: function(settings, data) {
|
||||
stateSaveCallback: function (settings, data) {
|
||||
// Store current state in client's local storage area
|
||||
localStorage.setItem("groups-adlists-table", JSON.stringify(data));
|
||||
},
|
||||
stateLoadCallback: function() {
|
||||
stateLoadCallback: function () {
|
||||
// Receive previous state from client's local storage area
|
||||
var data = localStorage.getItem("groups-adlists-table");
|
||||
// Return if not available
|
||||
@@ -192,7 +192,7 @@ function initTable() {
|
||||
}
|
||||
});
|
||||
|
||||
table.on("order.dt", function() {
|
||||
table.on("order.dt", function () {
|
||||
var order = table.order();
|
||||
if (order[0][0] !== 0 || order[0][1] !== "asc") {
|
||||
$("#resetButton").show();
|
||||
@@ -200,7 +200,7 @@ function initTable() {
|
||||
$("#resetButton").hide();
|
||||
}
|
||||
});
|
||||
$("#resetButton").on("click", function() {
|
||||
$("#resetButton").on("click", function () {
|
||||
table.order([[0, "asc"]]).draw();
|
||||
$("#resetButton").hide();
|
||||
});
|
||||
@@ -228,7 +228,7 @@ function addAdlist() {
|
||||
comment: comment,
|
||||
token: token
|
||||
},
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully added adlist", address);
|
||||
@@ -239,7 +239,7 @@ function addAdlist() {
|
||||
utils.showAlert("error", "", "Error while adding new adlist: ", response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert("error", "", "Error while adding new adlist: ", jqXHR.responseText);
|
||||
console.log(exception);
|
||||
@@ -297,7 +297,7 @@ function editAdlist() {
|
||||
groups: groups,
|
||||
token: token
|
||||
},
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert(
|
||||
@@ -315,7 +315,7 @@ function editAdlist() {
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert(
|
||||
"error",
|
||||
@@ -340,19 +340,16 @@ function deleteAdlist() {
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { action: "delete_adlist", id: id, token: token },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "far fa-trash-alt", "Successfully deleted adlist ", address);
|
||||
table
|
||||
.row(tr)
|
||||
.remove()
|
||||
.draw(false);
|
||||
table.row(tr).remove().draw(false);
|
||||
} else {
|
||||
utils.showAlert("error", "", "Error while deleting adlist with ID " + id, response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert("error", "", "Error while deleting adlist with ID " + id, jqXHR.responseText);
|
||||
console.log(exception);
|
||||
|
||||
@@ -15,7 +15,7 @@ function reload_client_suggestions() {
|
||||
$.post(
|
||||
"scripts/pi-hole/php/groups.php",
|
||||
{ action: "get_unconfigured_clients", token: token },
|
||||
function(data) {
|
||||
function (data) {
|
||||
var sel = $("#select");
|
||||
var customWasSelected = sel.val() === "custom";
|
||||
sel.empty();
|
||||
@@ -29,18 +29,10 @@ function reload_client_suggestions() {
|
||||
text += " (" + data[key] + ")";
|
||||
}
|
||||
|
||||
sel.append(
|
||||
$("<option />")
|
||||
.val(key)
|
||||
.text(text)
|
||||
);
|
||||
sel.append($("<option />").val(key).text(text));
|
||||
}
|
||||
|
||||
sel.append(
|
||||
$("<option />")
|
||||
.val("custom")
|
||||
.text("Custom, specified below...")
|
||||
);
|
||||
sel.append($("<option />").val("custom").text("Custom, specified below..."));
|
||||
if (customWasSelected) {
|
||||
sel.val("custom");
|
||||
}
|
||||
@@ -53,7 +45,7 @@ function get_groups() {
|
||||
$.post(
|
||||
"scripts/pi-hole/php/groups.php",
|
||||
{ action: "get_groups", token: token },
|
||||
function(data) {
|
||||
function (data) {
|
||||
groups = data.data;
|
||||
initTable();
|
||||
},
|
||||
@@ -61,13 +53,13 @@ function get_groups() {
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$("#btnAdd").on("click", addClient);
|
||||
|
||||
reload_client_suggestions();
|
||||
get_groups();
|
||||
|
||||
$("#select").on("change", function() {
|
||||
$("#select").on("change", function () {
|
||||
$("#ip-custom").val("");
|
||||
$("#ip-custom").prop("disabled", $("#select option:selected").val() !== "custom");
|
||||
});
|
||||
@@ -94,10 +86,10 @@ function initTable() {
|
||||
{ data: "groups", searchable: false },
|
||||
{ data: "name", width: "80px", orderable: false }
|
||||
],
|
||||
drawCallback: function() {
|
||||
drawCallback: function () {
|
||||
$('button[id^="deleteClient_"]').on("click", deleteClient);
|
||||
},
|
||||
rowCallback: function(row, data) {
|
||||
rowCallback: function (row, data) {
|
||||
$(row).attr("data-id", data.id);
|
||||
var tooltip =
|
||||
"Added: " +
|
||||
@@ -161,7 +153,7 @@ function initTable() {
|
||||
includeSelectAllOption: true,
|
||||
buttonContainer: '<div id="container_' + data.id + '" class="btn-group"/>',
|
||||
maxHeight: 200,
|
||||
onDropdownShown: function() {
|
||||
onDropdownShown: function () {
|
||||
var el = $("#container_" + data.id);
|
||||
var top = el[0].getBoundingClientRect().top;
|
||||
var bottom = $(window).height() - top - el.height();
|
||||
@@ -179,7 +171,7 @@ function initTable() {
|
||||
el.css("top", offset.top + "px");
|
||||
el.css("left", offset.left + "px");
|
||||
},
|
||||
onDropdownHide: function() {
|
||||
onDropdownHide: function () {
|
||||
var el = $("#container" + data.id);
|
||||
var home = $("#selectHome" + data.id);
|
||||
home.append(el);
|
||||
@@ -205,11 +197,11 @@ function initTable() {
|
||||
[10, 25, 50, 100, "All"]
|
||||
],
|
||||
stateSave: true,
|
||||
stateSaveCallback: function(settings, data) {
|
||||
stateSaveCallback: function (settings, data) {
|
||||
// Store current state in client's local storage area
|
||||
localStorage.setItem("groups-clients-table", JSON.stringify(data));
|
||||
},
|
||||
stateLoadCallback: function() {
|
||||
stateLoadCallback: function () {
|
||||
// Receive previous state from client's local storage area
|
||||
var data = localStorage.getItem("groups-clients-table");
|
||||
// Return if not available
|
||||
@@ -229,7 +221,7 @@ function initTable() {
|
||||
}
|
||||
});
|
||||
|
||||
table.on("order.dt", function() {
|
||||
table.on("order.dt", function () {
|
||||
var order = table.order();
|
||||
if (order[0][0] !== 0 || order[0][1] !== "asc") {
|
||||
$("#resetButton").show();
|
||||
@@ -237,7 +229,7 @@ function initTable() {
|
||||
$("#resetButton").hide();
|
||||
}
|
||||
});
|
||||
$("#resetButton").on("click", function() {
|
||||
$("#resetButton").on("click", function () {
|
||||
table.order([[0, "asc"]]).draw();
|
||||
$("#resetButton").hide();
|
||||
});
|
||||
@@ -279,7 +271,7 @@ function addClient() {
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { action: "add_client", ip: ip, comment: comment, token: token },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully added client", ip);
|
||||
@@ -289,7 +281,7 @@ function addClient() {
|
||||
utils.showAlert("error", "", "Error while adding new client", response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert("error", "", "Error while adding new client", jqXHR.responseText);
|
||||
console.log(exception);
|
||||
@@ -340,7 +332,7 @@ function editClient() {
|
||||
token: token,
|
||||
comment: comment
|
||||
},
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully " + done + " client", ip_name);
|
||||
@@ -352,7 +344,7 @@ function editClient() {
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert(
|
||||
"error",
|
||||
@@ -383,20 +375,17 @@ function deleteClient() {
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { action: "delete_client", id: id, token: token },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "far fa-trash-alt", "Successfully deleted client ", ip_name);
|
||||
table
|
||||
.row(tr)
|
||||
.remove()
|
||||
.draw(false);
|
||||
table.row(tr).remove().draw(false);
|
||||
reload_client_suggestions();
|
||||
} else {
|
||||
utils.showAlert("error", "", "Error while deleting client with ID " + id, response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert("error", "", "Error while deleting client with ID " + id, jqXHR.responseText);
|
||||
console.log(exception);
|
||||
|
||||
@@ -129,7 +129,7 @@ function validateIPv6CIDR(ip) {
|
||||
return ipv6validator.test(ip);
|
||||
}
|
||||
|
||||
window.utils = (function() {
|
||||
window.utils = (function () {
|
||||
return {
|
||||
showAlert: showAlert,
|
||||
datetime: datetime,
|
||||
|
||||
@@ -17,7 +17,7 @@ function get_groups() {
|
||||
$.post(
|
||||
"scripts/pi-hole/php/groups.php",
|
||||
{ action: "get_groups", token: token },
|
||||
function(data) {
|
||||
function (data) {
|
||||
groups = data.data;
|
||||
initTable();
|
||||
},
|
||||
@@ -25,11 +25,11 @@ function get_groups() {
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
window.location.search
|
||||
.substr(1)
|
||||
.split("&")
|
||||
.forEach(function(item) {
|
||||
.forEach(function (item) {
|
||||
GETDict[item.split("=")[0]] = item.split("=")[1];
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
// sync description fields, reset inactive inputs on tab change
|
||||
$('a[data-toggle="tab"]').on("shown.bs.tab", function() {
|
||||
$('a[data-toggle="tab"]').on("shown.bs.tab", function () {
|
||||
var tabHref = $(this).attr("href");
|
||||
var val;
|
||||
if (tabHref === "#tab_domain") {
|
||||
@@ -81,10 +81,10 @@ function initTable() {
|
||||
{ data: "groups", searchable: false },
|
||||
{ data: null, width: "80px", orderable: false }
|
||||
],
|
||||
drawCallback: function() {
|
||||
drawCallback: function () {
|
||||
$('button[id^="deleteDomain_"]').on("click", deleteDomain);
|
||||
},
|
||||
rowCallback: function(row, data) {
|
||||
rowCallback: function (row, data) {
|
||||
$(row).attr("data-id", data.id);
|
||||
var tooltip =
|
||||
"Added: " +
|
||||
@@ -188,7 +188,7 @@ function initTable() {
|
||||
includeSelectAllOption: true,
|
||||
buttonContainer: '<div id="container_' + data.id + '" class="btn-group"/>',
|
||||
maxHeight: 200,
|
||||
onDropdownShown: function() {
|
||||
onDropdownShown: function () {
|
||||
var el = $("#container_" + data.id);
|
||||
var top = el[0].getBoundingClientRect().top;
|
||||
var bottom = $(window).height() - top - el.height();
|
||||
@@ -206,7 +206,7 @@ function initTable() {
|
||||
el.css("top", offset.top + "px");
|
||||
el.css("left", offset.left + "px");
|
||||
},
|
||||
onDropdownHide: function() {
|
||||
onDropdownHide: function () {
|
||||
var el = $("#container_" + data.id);
|
||||
var home = $("#selectHome_" + data.id);
|
||||
home.append(el);
|
||||
@@ -218,9 +218,7 @@ function initTable() {
|
||||
|
||||
// Highlight row (if url parameter "domainid=" is used)
|
||||
if ("domainid" in GETDict && data.id === parseInt(GETDict.domainid)) {
|
||||
$(row)
|
||||
.find("td")
|
||||
.addClass("highlight");
|
||||
$(row).find("td").addClass("highlight");
|
||||
}
|
||||
|
||||
var button =
|
||||
@@ -244,11 +242,11 @@ function initTable() {
|
||||
[10, 25, 50, 100, "All"]
|
||||
],
|
||||
stateSave: true,
|
||||
stateSaveCallback: function(settings, data) {
|
||||
stateSaveCallback: function (settings, data) {
|
||||
// Store current state in client's local storage area
|
||||
localStorage.setItem("groups-domains-table", JSON.stringify(data));
|
||||
},
|
||||
stateLoadCallback: function() {
|
||||
stateLoadCallback: function () {
|
||||
// Receive previous state from client's local storage area
|
||||
var data = localStorage.getItem("groups-domains-table");
|
||||
// Return if not available
|
||||
@@ -268,12 +266,9 @@ function initTable() {
|
||||
// Apply loaded state to table
|
||||
return data;
|
||||
},
|
||||
initComplete: function() {
|
||||
initComplete: function () {
|
||||
if ("domainid" in GETDict) {
|
||||
var pos = table
|
||||
.column(0, { order: "current" })
|
||||
.data()
|
||||
.indexOf(parseInt(GETDict.domainid));
|
||||
var pos = table.column(0, { order: "current" }).data().indexOf(parseInt(GETDict.domainid));
|
||||
if (pos >= 0) {
|
||||
var page = Math.floor(pos / table.page.info().length);
|
||||
table.page(page).draw(false);
|
||||
@@ -282,7 +277,7 @@ function initTable() {
|
||||
}
|
||||
});
|
||||
|
||||
table.on("order.dt", function() {
|
||||
table.on("order.dt", function () {
|
||||
var order = table.order();
|
||||
if (order[0][0] !== 0 || order[0][1] !== "asc") {
|
||||
$("#resetButton").show();
|
||||
@@ -290,7 +285,7 @@ function initTable() {
|
||||
$("#resetButton").hide();
|
||||
}
|
||||
});
|
||||
$("#resetButton").on("click", function() {
|
||||
$("#resetButton").on("click", function () {
|
||||
table.order([[0, "asc"]]).draw();
|
||||
$("#resetButton").hide();
|
||||
});
|
||||
@@ -358,7 +353,7 @@ function addDomain() {
|
||||
comment: comment,
|
||||
token: token
|
||||
},
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully added " + domain_regex, domain);
|
||||
@@ -370,7 +365,7 @@ function addDomain() {
|
||||
utils.showAlert("error", "", "Error while adding new " + domain_regex, response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert("error", "", "Error while adding new " + domain_regex, jqXHR.responseText);
|
||||
console.log(exception);
|
||||
@@ -448,7 +443,7 @@ function editDomain() {
|
||||
groups: groups,
|
||||
token: token
|
||||
},
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert(
|
||||
@@ -465,7 +460,7 @@ function editDomain() {
|
||||
response.message
|
||||
);
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert(
|
||||
"error",
|
||||
@@ -498,7 +493,7 @@ function deleteDomain() {
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { action: "delete_domain", id: id, token: token },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert(
|
||||
@@ -507,10 +502,7 @@ function deleteDomain() {
|
||||
"Successfully deleted " + domain_regex,
|
||||
domain
|
||||
);
|
||||
table
|
||||
.row(tr)
|
||||
.remove()
|
||||
.draw(false);
|
||||
table.row(tr).remove().draw(false);
|
||||
} else {
|
||||
utils.showAlert(
|
||||
"error",
|
||||
@@ -520,7 +512,7 @@ function deleteDomain() {
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert(
|
||||
"error",
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
var table;
|
||||
var token = $("#token").html();
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$("#btnAdd").on("click", addGroup);
|
||||
|
||||
table = $("#groupsTable").DataTable({
|
||||
@@ -27,10 +27,10 @@ $(document).ready(function() {
|
||||
{ data: "description" },
|
||||
{ data: null, width: "60px", orderable: false }
|
||||
],
|
||||
drawCallback: function() {
|
||||
drawCallback: function () {
|
||||
$('button[id^="deleteGroup_"]').on("click", deleteGroup);
|
||||
},
|
||||
rowCallback: function(row, data) {
|
||||
rowCallback: function (row, data) {
|
||||
$(row).attr("data-id", data.id);
|
||||
var tooltip =
|
||||
"Added: " +
|
||||
@@ -86,11 +86,11 @@ $(document).ready(function() {
|
||||
[10, 25, 50, 100, "All"]
|
||||
],
|
||||
stateSave: true,
|
||||
stateSaveCallback: function(settings, data) {
|
||||
stateSaveCallback: function (settings, data) {
|
||||
// Store current state in client's local storage area
|
||||
localStorage.setItem("groups-table", JSON.stringify(data));
|
||||
},
|
||||
stateLoadCallback: function() {
|
||||
stateLoadCallback: function () {
|
||||
// Receive previous state from client's local storage area
|
||||
var data = localStorage.getItem("groups-table");
|
||||
// Return if not available
|
||||
@@ -110,7 +110,7 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
table.on("order.dt", function() {
|
||||
table.on("order.dt", function () {
|
||||
var order = table.order();
|
||||
if (order[0][0] !== 0 || order[0][1] !== "asc") {
|
||||
$("#resetButton").show();
|
||||
@@ -118,7 +118,7 @@ $(document).ready(function() {
|
||||
$("#resetButton").hide();
|
||||
}
|
||||
});
|
||||
$("#resetButton").on("click", function() {
|
||||
$("#resetButton").on("click", function () {
|
||||
table.order([[0, "asc"]]).draw();
|
||||
$("#resetButton").hide();
|
||||
});
|
||||
@@ -141,7 +141,7 @@ function addGroup() {
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { action: "add_group", name: name, desc: desc, token: token },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully added group", name);
|
||||
@@ -152,7 +152,7 @@ function addGroup() {
|
||||
utils.showAlert("error", "", "Error while adding new group", response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert("error", "", "Error while adding new group", jqXHR.responseText);
|
||||
console.log(exception);
|
||||
@@ -208,7 +208,7 @@ function editGroup() {
|
||||
status: status,
|
||||
token: token
|
||||
},
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "fas fa-pencil-alt", "Successfully " + done + " group", name);
|
||||
@@ -221,7 +221,7 @@ function editGroup() {
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert(
|
||||
"error",
|
||||
@@ -246,19 +246,16 @@ function deleteGroup() {
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { action: "delete_group", id: id, token: token },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "far fa-trash-alt", "Successfully deleted group ", name);
|
||||
table
|
||||
.row(tr)
|
||||
.remove()
|
||||
.draw(false);
|
||||
table.row(tr).remove().draw(false);
|
||||
} else {
|
||||
utils.showAlert("error", "", "Error while deleting group with ID " + id, response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
error: function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert("error", "", "Error while deleting group with ID " + id, jqXHR.responseText);
|
||||
console.log(exception);
|
||||
|
||||
+52
-70
@@ -18,7 +18,7 @@ function padNumber(num) {
|
||||
|
||||
function objectToArray(p) {
|
||||
var keys = Object.keys(p);
|
||||
keys.sort(function(a, b) {
|
||||
keys.sort(function (a, b) {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ function objectToArray(p) {
|
||||
|
||||
var lastTooltipTime = 0;
|
||||
|
||||
var customTooltips = function(tooltip) {
|
||||
var customTooltips = function (tooltip) {
|
||||
// Tooltip Element
|
||||
var tooltipEl = document.getElementById("chartjs-tooltip");
|
||||
if (!tooltipEl) {
|
||||
@@ -76,12 +76,12 @@ var customTooltips = function(tooltip) {
|
||||
var titleLines = tooltip.title || [];
|
||||
var bodyLines = tooltip.body.map(getBody);
|
||||
var innerHtml = "<table><thead>";
|
||||
titleLines.forEach(function(title) {
|
||||
titleLines.forEach(function (title) {
|
||||
innerHtml += "<tr><th>" + title + "</th></tr>";
|
||||
});
|
||||
innerHtml += "</thead><tbody>";
|
||||
var printed = 0;
|
||||
bodyLines.forEach(function(body, i) {
|
||||
bodyLines.forEach(function (body, i) {
|
||||
var colors = tooltip.labelColors[i];
|
||||
var style = "background:" + colors.backgroundColor;
|
||||
style += "; border-color:" + colors.borderColor;
|
||||
@@ -129,7 +129,7 @@ var customTooltips = function(tooltip) {
|
||||
|
||||
var failures = 0;
|
||||
function updateQueriesOverTime() {
|
||||
$.getJSON("api.php?overTimeData10mins", function(data) {
|
||||
$.getJSON("api.php?overTimeData10mins", function (data) {
|
||||
if ("FTLnotrunning" in data) {
|
||||
return;
|
||||
}
|
||||
@@ -168,12 +168,12 @@ function updateQueriesOverTime() {
|
||||
$("#queries-over-time .overlay").hide();
|
||||
timeLineChart.update();
|
||||
})
|
||||
.done(function() {
|
||||
.done(function () {
|
||||
// Reload graph after 10 minutes
|
||||
failures = 0;
|
||||
setTimeout(updateQueriesOverTime, 600000);
|
||||
})
|
||||
.fail(function() {
|
||||
.fail(function () {
|
||||
failures++;
|
||||
if (failures < 5) {
|
||||
// Try again after 1 minute only if this has not failed more
|
||||
@@ -184,14 +184,14 @@ function updateQueriesOverTime() {
|
||||
}
|
||||
|
||||
function updateQueryTypesPie() {
|
||||
$.getJSON("api.php?getQueryTypes", function(data) {
|
||||
$.getJSON("api.php?getQueryTypes", function (data) {
|
||||
if ("FTLnotrunning" in data) {
|
||||
return;
|
||||
}
|
||||
|
||||
var colors = [];
|
||||
// Get colors from AdminLTE
|
||||
$.each($.AdminLTE.options.colors, function(key, value) {
|
||||
$.each($.AdminLTE.options.colors, function (key, value) {
|
||||
colors.push(value);
|
||||
});
|
||||
var v = [],
|
||||
@@ -205,7 +205,7 @@ function updateQueryTypesPie() {
|
||||
iter = data;
|
||||
}
|
||||
|
||||
$.each(iter, function(key, value) {
|
||||
$.each(iter, function (key, value) {
|
||||
v.push(value);
|
||||
c.push(colors.shift());
|
||||
k.push(key);
|
||||
@@ -223,7 +223,7 @@ function updateQueryTypesPie() {
|
||||
queryTypePieChart.options.animation.duration = 0;
|
||||
// Generate legend in separate div
|
||||
$("#query-types-legend").html(queryTypePieChart.generateLegend());
|
||||
$("#query-types-legend > ul > li").on("mousedown", function(e) {
|
||||
$("#query-types-legend > ul > li").on("mousedown", function (e) {
|
||||
if (e.which === 2) {
|
||||
// which == 2 is middle mouse button
|
||||
$(this).toggleClass("strike");
|
||||
@@ -243,23 +243,21 @@ function updateQueryTypesPie() {
|
||||
window.open("queries.php?querytype=" + ($(this).index() + 1), "_self");
|
||||
}
|
||||
});
|
||||
}).done(function() {
|
||||
}).done(function () {
|
||||
// Reload graph after minute
|
||||
setTimeout(updateQueryTypesPie, 60000);
|
||||
});
|
||||
}
|
||||
|
||||
function updateClientsOverTime() {
|
||||
$.getJSON("api.php?overTimeDataClients&getClientNames", function(data) {
|
||||
$.getJSON("api.php?overTimeDataClients&getClientNames", function (data) {
|
||||
if ("FTLnotrunning" in data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove graph if there are no results (e.g. privacy mode enabled)
|
||||
if (jQuery.isEmptyObject(data.over_time)) {
|
||||
$("#clients")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#clients").parent().remove();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -289,7 +287,7 @@ function updateClientsOverTime() {
|
||||
|
||||
// Get colors from AdminLTE
|
||||
var colors = [];
|
||||
$.each($.AdminLTE.options.colors, function(key, value) {
|
||||
$.each($.AdminLTE.options.colors, function (key, value) {
|
||||
colors.push(value);
|
||||
});
|
||||
|
||||
@@ -344,12 +342,12 @@ function updateClientsOverTime() {
|
||||
$("#clients .overlay").hide();
|
||||
clientsChart.update();
|
||||
})
|
||||
.done(function() {
|
||||
.done(function () {
|
||||
// Reload graph after 10 minutes
|
||||
failures = 0;
|
||||
setTimeout(updateClientsOverTime, 600000);
|
||||
})
|
||||
.fail(function() {
|
||||
.fail(function () {
|
||||
failures++;
|
||||
if (failures < 5) {
|
||||
// Try again after 1 minute only if this has not failed more
|
||||
@@ -360,14 +358,14 @@ function updateClientsOverTime() {
|
||||
}
|
||||
|
||||
function updateForwardDestinationsPie() {
|
||||
$.getJSON("api.php?getForwardDestinations", function(data) {
|
||||
$.getJSON("api.php?getForwardDestinations", function (data) {
|
||||
if ("FTLnotrunning" in data) {
|
||||
return;
|
||||
}
|
||||
|
||||
var colors = [];
|
||||
// Get colors from AdminLTE
|
||||
$.each($.AdminLTE.options.colors, function(key, value) {
|
||||
$.each($.AdminLTE.options.colors, function (key, value) {
|
||||
colors.push(value);
|
||||
});
|
||||
var v = [],
|
||||
@@ -376,7 +374,7 @@ function updateForwardDestinationsPie() {
|
||||
values = [];
|
||||
|
||||
// Collect values and colors
|
||||
$.each(data.forward_destinations, function(key, value) {
|
||||
$.each(data.forward_destinations, function (key, value) {
|
||||
if (key.indexOf("|") > -1) {
|
||||
key = key.substr(0, key.indexOf("|"));
|
||||
}
|
||||
@@ -385,7 +383,7 @@ function updateForwardDestinationsPie() {
|
||||
});
|
||||
|
||||
// Split data into individual arrays for the graphs
|
||||
$.each(values, function(key, value) {
|
||||
$.each(values, function (key, value) {
|
||||
k.push(value[0]);
|
||||
v.push(value[1]);
|
||||
c.push(value[2]);
|
||||
@@ -405,7 +403,7 @@ function updateForwardDestinationsPie() {
|
||||
forwardDestinationPieChart.options.animation.duration = 0;
|
||||
// Generate legend in separate div
|
||||
$("#forward-destinations-legend").html(forwardDestinationPieChart.generateLegend());
|
||||
$("#forward-destinations-legend > ul > li").on("mousedown", function(e) {
|
||||
$("#forward-destinations-legend > ul > li").on("mousedown", function (e) {
|
||||
if (e.which === 2) {
|
||||
// which == 2 is middle mouse button
|
||||
$(this).toggleClass("strike");
|
||||
@@ -426,7 +424,7 @@ function updateForwardDestinationsPie() {
|
||||
window.open("queries.php?forwarddest=" + obj, "_self");
|
||||
}
|
||||
});
|
||||
}).done(function() {
|
||||
}).done(function () {
|
||||
// Reload graph after one minute
|
||||
setTimeout(updateForwardDestinationsPie, 60000);
|
||||
});
|
||||
@@ -442,21 +440,19 @@ function escapeHtml(text) {
|
||||
"'": "'"
|
||||
};
|
||||
|
||||
return text.replace(/[&<>"']/g, function(m) {
|
||||
return text.replace(/[&<>"']/g, function (m) {
|
||||
return map[m];
|
||||
});
|
||||
}
|
||||
|
||||
function updateTopClientsChart() {
|
||||
$.getJSON("api.php?summaryRaw&getQuerySources&topClientsBlocked", function(data) {
|
||||
$.getJSON("api.php?summaryRaw&getQuerySources&topClientsBlocked", function (data) {
|
||||
if ("FTLnotrunning" in data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear tables before filling them with data
|
||||
$("#client-frequency td")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#client-frequency td").parent().remove();
|
||||
var clienttable = $("#client-frequency").find("tbody:last");
|
||||
var client, percentage, clientname, clientip, idx, url;
|
||||
for (client in data.top_sources) {
|
||||
@@ -503,9 +499,7 @@ function updateTopClientsChart() {
|
||||
}
|
||||
|
||||
// Clear tables before filling them with data
|
||||
$("#client-frequency-blocked td")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#client-frequency-blocked td").parent().remove();
|
||||
var clientblockedtable = $("#client-frequency-blocked").find("tbody:last");
|
||||
for (client in data.top_sources_blocked) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.top_sources_blocked, client)) {
|
||||
@@ -552,16 +546,12 @@ function updateTopClientsChart() {
|
||||
|
||||
// Remove table if there are no results (e.g. privacy mode enabled)
|
||||
if (jQuery.isEmptyObject(data.top_sources)) {
|
||||
$("#client-frequency")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#client-frequency").parent().remove();
|
||||
}
|
||||
|
||||
// Remove table if there are no results (e.g. privacy mode enabled)
|
||||
if (jQuery.isEmptyObject(data.top_sources_blocked)) {
|
||||
$("#client-frequency-blocked")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#client-frequency-blocked").parent().remove();
|
||||
}
|
||||
|
||||
$("#client-frequency .overlay").hide();
|
||||
@@ -572,18 +562,14 @@ function updateTopClientsChart() {
|
||||
}
|
||||
|
||||
function updateTopLists() {
|
||||
$.getJSON("api.php?summaryRaw&topItems", function(data) {
|
||||
$.getJSON("api.php?summaryRaw&topItems", function (data) {
|
||||
if ("FTLnotrunning" in data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear tables before filling them with data
|
||||
$("#domain-frequency td")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#ad-frequency td")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#domain-frequency td").parent().remove();
|
||||
$("#ad-frequency td").parent().remove();
|
||||
var domaintable = $("#domain-frequency").find("tbody:last");
|
||||
var adtable = $("#ad-frequency").find("tbody:last");
|
||||
var url, domain, percentage;
|
||||
@@ -616,9 +602,7 @@ function updateTopLists() {
|
||||
|
||||
// Remove table if there are no results (e.g. privacy mode enabled)
|
||||
if (jQuery.isEmptyObject(data.top_queries)) {
|
||||
$("#domain-frequency")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#domain-frequency").parent().remove();
|
||||
}
|
||||
|
||||
for (domain in data.top_ads) {
|
||||
@@ -650,9 +634,7 @@ function updateTopLists() {
|
||||
|
||||
// Remove table if there are no results (e.g. privacy mode enabled)
|
||||
if (jQuery.isEmptyObject(data.top_ads)) {
|
||||
$("#ad-frequency")
|
||||
.parent()
|
||||
.remove();
|
||||
$("#ad-frequency").parent().remove();
|
||||
}
|
||||
|
||||
$("#domain-frequency .overlay").hide();
|
||||
@@ -664,13 +646,13 @@ function updateTopLists() {
|
||||
|
||||
var FTLoffline = false;
|
||||
function updateSummaryData(runOnce) {
|
||||
var setTimer = function(timeInSeconds) {
|
||||
var setTimer = function (timeInSeconds) {
|
||||
if (!runOnce) {
|
||||
setTimeout(updateSummaryData, timeInSeconds * 1000);
|
||||
}
|
||||
};
|
||||
|
||||
$.getJSON("api.php?summary", function(data) {
|
||||
$.getJSON("api.php?summary", function (data) {
|
||||
updateSessionTimer();
|
||||
|
||||
if ("FTLnotrunning" in data) {
|
||||
@@ -699,7 +681,7 @@ function updateSummaryData(runOnce) {
|
||||
}
|
||||
|
||||
["ads_blocked_today", "dns_queries_today", "ads_percentage_today", "unique_clients"].forEach(
|
||||
function(today) {
|
||||
function (today) {
|
||||
var $todayElement = $("span#" + today);
|
||||
|
||||
if ($todayElement.text() !== data[today] && $todayElement.text() !== data[today] + "%") {
|
||||
@@ -715,33 +697,33 @@ function updateSummaryData(runOnce) {
|
||||
);
|
||||
}
|
||||
|
||||
window.setTimeout(function() {
|
||||
window.setTimeout(function () {
|
||||
[
|
||||
"ads_blocked_today",
|
||||
"dns_queries_today",
|
||||
"domains_being_blocked",
|
||||
"ads_percentage_today",
|
||||
"unique_clients"
|
||||
].forEach(function(header, idx) {
|
||||
].forEach(function (header, idx) {
|
||||
var textData = idx === 3 && data[header] !== "to" ? data[header] + "%" : data[header];
|
||||
$("span#" + header).text(textData);
|
||||
});
|
||||
$("span.glow").removeClass("glow");
|
||||
}, 500);
|
||||
})
|
||||
.done(function() {
|
||||
.done(function () {
|
||||
if (!FTLoffline) {
|
||||
setTimer(1);
|
||||
} else {
|
||||
setTimer(10);
|
||||
}
|
||||
})
|
||||
.fail(function() {
|
||||
.fail(function () {
|
||||
setTimer(300);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
// Pull in data via AJAX
|
||||
updateSummaryData();
|
||||
|
||||
@@ -780,7 +762,7 @@ $(document).ready(function() {
|
||||
enabled: true,
|
||||
mode: "x-axis",
|
||||
callbacks: {
|
||||
title: function(tooltipItem) {
|
||||
title: function (tooltipItem) {
|
||||
var label = tooltipItem[0].xLabel;
|
||||
var time = label.match(/(\d?\d):?(\d?\d?)/);
|
||||
var h = parseInt(time[1], 10);
|
||||
@@ -789,7 +771,7 @@ $(document).ready(function() {
|
||||
var to = padNumber(h) + ":" + padNumber(m + 4) + ":59";
|
||||
return "Upstreams from " + from + " to " + to;
|
||||
},
|
||||
label: function(tooltipItems, data) {
|
||||
label: function (tooltipItems, data) {
|
||||
if (tooltipItems.datasetIndex === 1) {
|
||||
var percentage = 0.0;
|
||||
var permitted = parseInt(data.datasets[0].data[tooltipItems.index]);
|
||||
@@ -862,11 +844,11 @@ $(document).ready(function() {
|
||||
enabled: false,
|
||||
mode: "x-axis",
|
||||
custom: customTooltips,
|
||||
itemSort: function(a, b) {
|
||||
itemSort: function (a, b) {
|
||||
return b.yLabel - a.yLabel;
|
||||
},
|
||||
callbacks: {
|
||||
title: function(tooltipItem) {
|
||||
title: function (tooltipItem) {
|
||||
var label = tooltipItem[0].xLabel;
|
||||
var time = label.match(/(\d?\d):?(\d?\d?)/);
|
||||
var h = parseInt(time[1], 10);
|
||||
@@ -875,7 +857,7 @@ $(document).ready(function() {
|
||||
var to = padNumber(h) + ":" + padNumber(m + 4) + ":59";
|
||||
return "Client activity from " + from + " to " + to;
|
||||
},
|
||||
label: function(tooltipItems, data) {
|
||||
label: function (tooltipItems, data) {
|
||||
return data.datasets[tooltipItems.datasetIndex].label + ": " + tooltipItems.yLabel;
|
||||
}
|
||||
}
|
||||
@@ -924,7 +906,7 @@ $(document).ready(function() {
|
||||
updateTopClientsChart();
|
||||
}
|
||||
|
||||
$("#queryOverTimeChart").click(function(evt) {
|
||||
$("#queryOverTimeChart").click(function (evt) {
|
||||
var activePoints = timeLineChart.getElementAtEvent(evt);
|
||||
if (activePoints.length > 0) {
|
||||
//get the internal index of slice in pie chart
|
||||
@@ -958,10 +940,10 @@ $(document).ready(function() {
|
||||
enabled: false,
|
||||
custom: customTooltips,
|
||||
callbacks: {
|
||||
title: function() {
|
||||
title: function () {
|
||||
return "Query types";
|
||||
},
|
||||
label: function(tooltipItems, data) {
|
||||
label: function (tooltipItems, data) {
|
||||
var dataset = data.datasets[tooltipItems.datasetIndex];
|
||||
var label = data.labels[tooltipItems.index];
|
||||
return label + ": " + dataset.data[tooltipItems.index].toFixed(1) + "%";
|
||||
@@ -995,10 +977,10 @@ $(document).ready(function() {
|
||||
enabled: false,
|
||||
custom: customTooltips,
|
||||
callbacks: {
|
||||
title: function() {
|
||||
title: function () {
|
||||
return "Forward destinations";
|
||||
},
|
||||
label: function(tooltipItems, data) {
|
||||
label: function (tooltipItems, data) {
|
||||
var dataset = data.datasets[tooltipItems.datasetIndex];
|
||||
var label = data.labels[tooltipItems.index];
|
||||
return label + ": " + dataset.data[tooltipItems.index].toFixed(1) + "%";
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// This code has been taken from
|
||||
// https://datatables.net/plug-ins/sorting/ip-address
|
||||
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
|
||||
"ip-address-pre": function(a) {
|
||||
"ip-address-pre": function (a) {
|
||||
if (!a) {
|
||||
return 0;
|
||||
}
|
||||
@@ -84,11 +84,11 @@ jQuery.extend(jQuery.fn.dataTableExt.oSort, {
|
||||
return x;
|
||||
},
|
||||
|
||||
"ip-address-asc": function(a, b) {
|
||||
"ip-address-asc": function (a, b) {
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
},
|
||||
|
||||
"ip-address-desc": function(a, b) {
|
||||
"ip-address-desc": function (a, b) {
|
||||
return a < b ? 1 : a > b ? -1 : 0;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ function handleAjaxError(xhr, textStatus) {
|
||||
|
||||
function getTimestamp() {
|
||||
if (!Date.now) {
|
||||
Date.now = function() {
|
||||
Date.now = function () {
|
||||
return new Date().getTime();
|
||||
};
|
||||
}
|
||||
@@ -55,9 +55,9 @@ function mixColors(ratio, rgb1, rgb2) {
|
||||
];
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
tableApi = $("#network-entries").DataTable({
|
||||
rowCallback: function(row, data) {
|
||||
rowCallback: function (row, data) {
|
||||
var color,
|
||||
mark,
|
||||
lastQuery = parseInt(data.lastQuery);
|
||||
@@ -115,7 +115,7 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
$("td:eq(0)", row).html(ips.join("<br>"));
|
||||
$("td:eq(0)", row).hover(function() {
|
||||
$("td:eq(0)", row).hover(function () {
|
||||
this.title = data.ip.join("\n");
|
||||
});
|
||||
|
||||
@@ -146,7 +146,7 @@ $(document).ready(function() {
|
||||
{
|
||||
data: "firstSeen",
|
||||
width: "8%",
|
||||
render: function(data, type) {
|
||||
render: function (data, type) {
|
||||
if (type === "display") {
|
||||
return moment.unix(data).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");
|
||||
}
|
||||
@@ -157,7 +157,7 @@ $(document).ready(function() {
|
||||
{
|
||||
data: "lastQuery",
|
||||
width: "8%",
|
||||
render: function(data, type) {
|
||||
render: function (data, type) {
|
||||
if (type === "display") {
|
||||
return moment.unix(data).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");
|
||||
}
|
||||
@@ -173,11 +173,11 @@ $(document).ready(function() {
|
||||
[10, 25, 50, 100, "All"]
|
||||
],
|
||||
stateSave: true,
|
||||
stateSaveCallback: function(settings, data) {
|
||||
stateSaveCallback: function (settings, data) {
|
||||
// Store current state in client's local storage area
|
||||
localStorage.setItem("network_table", JSON.stringify(data));
|
||||
},
|
||||
stateLoadCallback: function() {
|
||||
stateLoadCallback: function () {
|
||||
// Receive previous state from client's local storage area
|
||||
var data = localStorage.getItem("network_table");
|
||||
// Return if not available
|
||||
|
||||
@@ -37,12 +37,12 @@ function add(domain, list) {
|
||||
alertModal.modal("show");
|
||||
|
||||
// add Domain to List after Modal has faded in
|
||||
alertModal.one("shown.bs.modal", function() {
|
||||
alertModal.one("shown.bs.modal", function () {
|
||||
$.ajax({
|
||||
url: "scripts/pi-hole/php/add.php",
|
||||
method: "post",
|
||||
data: { domain: domain, list: list, token: token },
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
alProcessing.hide();
|
||||
if (
|
||||
response.indexOf("not a valid argument") >= 0 ||
|
||||
@@ -53,7 +53,7 @@ function add(domain, list) {
|
||||
alNetworkErr.hide();
|
||||
alCustomErr.html(response.replace("[✗]", ""));
|
||||
alFailure.fadeIn(1000);
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
alertModal.modal("hide");
|
||||
}, 3000);
|
||||
} else {
|
||||
@@ -61,17 +61,17 @@ function add(domain, list) {
|
||||
alSuccess.children(alDomain).html(domain);
|
||||
alSuccess.children(alList).html(listtype);
|
||||
alSuccess.fadeIn(1000);
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
alertModal.modal("hide");
|
||||
}, 2000);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
// Network Error
|
||||
alProcessing.hide();
|
||||
alNetworkErr.show();
|
||||
alFailure.fadeIn(1000);
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
alertModal.modal("hide");
|
||||
}, 3000);
|
||||
}
|
||||
@@ -79,16 +79,10 @@ function add(domain, list) {
|
||||
});
|
||||
|
||||
// Reset Modal after it has faded out
|
||||
alertModal.one("hidden.bs.modal", function() {
|
||||
alertModal.one("hidden.bs.modal", function () {
|
||||
alProcessing.show();
|
||||
alSuccess.add(alFailure).hide();
|
||||
alProcessing
|
||||
.add(alSuccess)
|
||||
.children(alDomain)
|
||||
.html("")
|
||||
.end()
|
||||
.children(alList)
|
||||
.html("");
|
||||
alProcessing.add(alSuccess).children(alDomain).html("").end().children(alList).html("");
|
||||
alCustomErr.html("");
|
||||
});
|
||||
}
|
||||
@@ -111,13 +105,13 @@ function autofilter() {
|
||||
return $("#autofilter").prop("checked");
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
// Do we want to filter queries?
|
||||
var GETDict = {};
|
||||
window.location.search
|
||||
.substr(1)
|
||||
.split("&")
|
||||
.forEach(function(item) {
|
||||
.forEach(function (item) {
|
||||
GETDict[item.split("=")[0]] = item.split("=")[1];
|
||||
});
|
||||
|
||||
@@ -141,7 +135,7 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
tableApi = $("#all-queries").DataTable({
|
||||
rowCallback: function(row, data) {
|
||||
rowCallback: function (row, data) {
|
||||
// DNSSEC status
|
||||
var dnssec_status;
|
||||
switch (data[5]) {
|
||||
@@ -274,15 +268,15 @@ $(document).ready(function() {
|
||||
|
||||
if (regexLink) {
|
||||
$("td:eq(4)", row).hover(
|
||||
function() {
|
||||
function () {
|
||||
this.title = "Click to show matching regex filter";
|
||||
this.style.color = "#72afd2";
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
this.style.color = "";
|
||||
}
|
||||
);
|
||||
$("td:eq(4)", row).click(function() {
|
||||
$("td:eq(4)", row).click(function () {
|
||||
var new_tab = window.open("groups-domains.php?domainid=" + data[9], "_blank");
|
||||
if (new_tab) {
|
||||
new_tab.focus();
|
||||
@@ -359,9 +353,9 @@ $(document).ready(function() {
|
||||
ajax: {
|
||||
url: APIstring,
|
||||
error: handleAjaxError,
|
||||
dataSrc: function(data) {
|
||||
dataSrc: function (data) {
|
||||
var dataIndex = 0;
|
||||
return data.data.map(function(x) {
|
||||
return data.data.map(function (x) {
|
||||
x[0] = x[0] * 1e6 + dataIndex++;
|
||||
return x;
|
||||
});
|
||||
@@ -373,7 +367,7 @@ $(document).ready(function() {
|
||||
columns: [
|
||||
{
|
||||
width: "15%",
|
||||
render: function(data, type) {
|
||||
render: function (data, type) {
|
||||
if (type === "display") {
|
||||
return moment
|
||||
.unix(Math.floor(data / 1e6))
|
||||
@@ -395,11 +389,11 @@ $(document).ready(function() {
|
||||
[10, 25, 50, 100, "All"]
|
||||
],
|
||||
stateSave: true,
|
||||
stateSaveCallback: function(settings, data) {
|
||||
stateSaveCallback: function (settings, data) {
|
||||
// Store current state in client's local storage area
|
||||
localStorage.setItem("query_log_table", JSON.stringify(data));
|
||||
},
|
||||
stateLoadCallback: function() {
|
||||
stateLoadCallback: function () {
|
||||
// Receive previous state from client's local storage area
|
||||
var data = localStorage.getItem("query_log_table");
|
||||
// Return if not available
|
||||
@@ -422,17 +416,17 @@ $(document).ready(function() {
|
||||
defaultContent: ""
|
||||
}
|
||||
],
|
||||
initComplete: function() {
|
||||
initComplete: function () {
|
||||
var api = this.api();
|
||||
// Query type IPv4 / IPv6
|
||||
api.$("td:eq(1)").click(function() {
|
||||
api.$("td:eq(1)").click(function () {
|
||||
if (autofilter()) {
|
||||
api.search(this.textContent).draw();
|
||||
$("#resetButton").show();
|
||||
}
|
||||
});
|
||||
api.$("td:eq(1)").hover(
|
||||
function() {
|
||||
function () {
|
||||
if (autofilter()) {
|
||||
this.title = "Click to show only " + this.textContent + " queries";
|
||||
this.style.color = "#72afd2";
|
||||
@@ -441,13 +435,13 @@ $(document).ready(function() {
|
||||
this.style.color = "";
|
||||
}
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
this.style.color = "";
|
||||
}
|
||||
);
|
||||
api.$("td:eq(1)").css("cursor", "pointer");
|
||||
// Domain
|
||||
api.$("td:eq(2)").click(function() {
|
||||
api.$("td:eq(2)").click(function () {
|
||||
if (autofilter()) {
|
||||
var domain = this.textContent.split("\n")[0];
|
||||
api.search(domain).draw();
|
||||
@@ -455,7 +449,7 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
api.$("td:eq(2)").hover(
|
||||
function() {
|
||||
function () {
|
||||
if (autofilter()) {
|
||||
var domain = this.textContent.split("\n")[0];
|
||||
this.title = "Click to show only queries with domain " + domain;
|
||||
@@ -465,20 +459,20 @@ $(document).ready(function() {
|
||||
this.style.color = "";
|
||||
}
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
this.style.color = "";
|
||||
}
|
||||
);
|
||||
api.$("td:eq(2)").css("cursor", "pointer");
|
||||
// Client
|
||||
api.$("td:eq(3)").click(function() {
|
||||
api.$("td:eq(3)").click(function () {
|
||||
if (autofilter()) {
|
||||
api.search(this.textContent).draw();
|
||||
$("#resetButton").show();
|
||||
}
|
||||
});
|
||||
api.$("td:eq(3)").hover(
|
||||
function() {
|
||||
function () {
|
||||
if (autofilter()) {
|
||||
this.title = "Click to show only queries made by " + this.textContent;
|
||||
this.style.color = "#72afd2";
|
||||
@@ -487,7 +481,7 @@ $(document).ready(function() {
|
||||
this.style.color = "";
|
||||
}
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
this.style.color = "";
|
||||
}
|
||||
);
|
||||
@@ -495,7 +489,7 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$("#all-queries tbody").on("click", "button", function() {
|
||||
$("#all-queries tbody").on("click", "button", function () {
|
||||
var data = tableApi.row($(this).parents("tr")).data();
|
||||
if (data[4] === "2" || data[4] === "3") {
|
||||
add(data[2], "black");
|
||||
@@ -504,7 +498,7 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$("#resetButton").click(function() {
|
||||
$("#resetButton").click(function () {
|
||||
tableApi.search("").draw();
|
||||
$("#resetButton").hide();
|
||||
});
|
||||
@@ -526,7 +520,7 @@ $(document).ready(function() {
|
||||
localStorage.setItem("query_log_filter_chkbox", true);
|
||||
}
|
||||
|
||||
$("#autofilter").click(function() {
|
||||
$("#autofilter").click(function () {
|
||||
localStorage.setItem("query_log_filter_chkbox", $("#autofilter").prop("checked"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ function httpGet(ta, quiet, theUrl) {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
xmlhttp.onreadystatechange = function () {
|
||||
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
|
||||
ta.show();
|
||||
ta.empty();
|
||||
@@ -50,9 +50,7 @@ function httpGet(ta, quiet, theUrl) {
|
||||
|
||||
function eventsource() {
|
||||
var ta = $("#output");
|
||||
var domain = $("#domain")
|
||||
.val()
|
||||
.trim();
|
||||
var domain = $("#domain").val().trim();
|
||||
var q = $("#quiet");
|
||||
|
||||
if (domain.length === 0) {
|
||||
@@ -85,7 +83,7 @@ function eventsource() {
|
||||
|
||||
source.addEventListener(
|
||||
"message",
|
||||
function(e) {
|
||||
function (e) {
|
||||
if (!quiet) {
|
||||
ta.append(e.data);
|
||||
} else {
|
||||
@@ -98,7 +96,7 @@ function eventsource() {
|
||||
// Will be called when script has finished
|
||||
source.addEventListener(
|
||||
"error",
|
||||
function() {
|
||||
function () {
|
||||
source.close();
|
||||
},
|
||||
false
|
||||
@@ -109,7 +107,7 @@ function eventsource() {
|
||||
}
|
||||
|
||||
// Handle enter button
|
||||
$(document).keypress(function(e) {
|
||||
$(document).keypress(function (e) {
|
||||
if (e.which === 13 && $("#domain").is(":focus")) {
|
||||
// Enter was pressed, and the input has focus
|
||||
exact = "";
|
||||
@@ -117,36 +115,32 @@ $(document).keypress(function(e) {
|
||||
}
|
||||
});
|
||||
// Handle button
|
||||
$("#btnSearch").on("click", function() {
|
||||
$("#btnSearch").on("click", function () {
|
||||
exact = "";
|
||||
eventsource();
|
||||
});
|
||||
// Handle exact button
|
||||
$("#btnSearchExact").on("click", function() {
|
||||
$("#btnSearchExact").on("click", function () {
|
||||
exact = "exact";
|
||||
eventsource();
|
||||
});
|
||||
|
||||
// Wrap form-group's buttons to next line when viewed on a small screen
|
||||
$(window).on("resize", function() {
|
||||
$(window).on("resize", function () {
|
||||
if ($(window).width() < 991) {
|
||||
$(".form-group.input-group")
|
||||
.removeClass("input-group")
|
||||
.addClass("input-group-block");
|
||||
$(".form-group.input-group").removeClass("input-group").addClass("input-group-block");
|
||||
$(".form-group.input-group-block > input").css("margin-bottom", "5px");
|
||||
$(".form-group.input-group-block > .input-group-btn")
|
||||
.removeClass("input-group-btn")
|
||||
.addClass("btn-block text-center");
|
||||
} else {
|
||||
$(".form-group.input-group-block")
|
||||
.removeClass("input-group-block")
|
||||
.addClass("input-group");
|
||||
$(".form-group.input-group-block").removeClass("input-group-block").addClass("input-group");
|
||||
$(".form-group.input-group > input").css("margin-bottom", "");
|
||||
$(".form-group.input-group > .btn-block.text-center")
|
||||
.removeClass("btn-block text-center")
|
||||
.addClass("input-group-btn");
|
||||
}
|
||||
});
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$(window).trigger("resize");
|
||||
});
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
$(function() {
|
||||
$("[data-static]").on("click", function() {
|
||||
$(function () {
|
||||
$("[data-static]").on("click", function () {
|
||||
var row = $(this).closest("tr");
|
||||
var mac = row.find("#MAC").text();
|
||||
var ip = row.find("#IP").text();
|
||||
@@ -19,10 +19,10 @@ $(function() {
|
||||
$(".confirm-poweroff").confirm({
|
||||
text: "Are you sure you want to send a poweroff command to your Pi-Hole?",
|
||||
title: "Confirmation required",
|
||||
confirm: function() {
|
||||
confirm: function () {
|
||||
$("#poweroffform").submit();
|
||||
},
|
||||
cancel: function() {
|
||||
cancel: function () {
|
||||
// nothing to do
|
||||
},
|
||||
confirmButton: "Yes, poweroff",
|
||||
@@ -35,10 +35,10 @@ $(".confirm-poweroff").confirm({
|
||||
$(".confirm-reboot").confirm({
|
||||
text: "Are you sure you want to send a reboot command to your Pi-Hole?",
|
||||
title: "Confirmation required",
|
||||
confirm: function() {
|
||||
confirm: function () {
|
||||
$("#rebootform").submit();
|
||||
},
|
||||
cancel: function() {
|
||||
cancel: function () {
|
||||
// nothing to do
|
||||
},
|
||||
confirmButton: "Yes, reboot",
|
||||
@@ -52,10 +52,10 @@ $(".confirm-reboot").confirm({
|
||||
$(".confirm-restartdns").confirm({
|
||||
text: "Are you sure you want to send a restart command to your DNS server?",
|
||||
title: "Confirmation required",
|
||||
confirm: function() {
|
||||
confirm: function () {
|
||||
$("#restartdnsform").submit();
|
||||
},
|
||||
cancel: function() {
|
||||
cancel: function () {
|
||||
// nothing to do
|
||||
},
|
||||
confirmButton: "Yes, restart DNS",
|
||||
@@ -69,10 +69,10 @@ $(".confirm-restartdns").confirm({
|
||||
$(".confirm-flushlogs").confirm({
|
||||
text: "Are you sure you want to flush your logs?",
|
||||
title: "Confirmation required",
|
||||
confirm: function() {
|
||||
confirm: function () {
|
||||
$("#flushlogsform").submit();
|
||||
},
|
||||
cancel: function() {
|
||||
cancel: function () {
|
||||
// nothing to do
|
||||
},
|
||||
confirmButton: "Yes, flush logs",
|
||||
@@ -86,10 +86,10 @@ $(".confirm-flushlogs").confirm({
|
||||
$(".confirm-flusharp").confirm({
|
||||
text: "Are you sure you want to flush your network table?",
|
||||
title: "Confirmation required",
|
||||
confirm: function() {
|
||||
confirm: function () {
|
||||
$("#flusharpform").submit();
|
||||
},
|
||||
cancel: function() {
|
||||
cancel: function () {
|
||||
// nothing to do
|
||||
},
|
||||
confirmButton: "Yes, flush my network table",
|
||||
@@ -103,10 +103,10 @@ $(".confirm-flusharp").confirm({
|
||||
$(".confirm-disablelogging-noflush").confirm({
|
||||
text: "Are you sure you want to disable logging?",
|
||||
title: "Confirmation required",
|
||||
confirm: function() {
|
||||
confirm: function () {
|
||||
$("#disablelogsform-noflush").submit();
|
||||
},
|
||||
cancel: function() {
|
||||
cancel: function () {
|
||||
// nothing to do
|
||||
},
|
||||
confirmButton: "Yes, disable logs",
|
||||
@@ -121,10 +121,10 @@ $(".api-token").confirm({
|
||||
text:
|
||||
"Make sure that nobody else can scan this code around you. They will have full access to the API without having to know the password. Note that the generation of the QR code will take some time.",
|
||||
title: "Confirmation required",
|
||||
confirm: function() {
|
||||
confirm: function () {
|
||||
window.open("scripts/pi-hole/php/api_token.php");
|
||||
},
|
||||
cancel: function() {
|
||||
cancel: function () {
|
||||
// nothing to do
|
||||
},
|
||||
confirmButton: "Yes, show API token",
|
||||
@@ -135,15 +135,13 @@ $(".api-token").confirm({
|
||||
dialogClass: "modal-dialog modal-mg"
|
||||
});
|
||||
|
||||
$("#DHCPchk").click(function() {
|
||||
$("#DHCPchk").click(function () {
|
||||
$("input.DHCPgroup").prop("disabled", !this.checked);
|
||||
$("#dhcpnotice")
|
||||
.prop("hidden", !this.checked)
|
||||
.addClass("lookatme");
|
||||
$("#dhcpnotice").prop("hidden", !this.checked).addClass("lookatme");
|
||||
});
|
||||
|
||||
function loadCacheInfo() {
|
||||
$.getJSON("api.php?getCacheInfo", function(data) {
|
||||
$.getJSON("api.php?getCacheInfo", function (data) {
|
||||
if ("FTLnotrunning" in data) {
|
||||
return;
|
||||
}
|
||||
@@ -156,13 +154,9 @@ function loadCacheInfo() {
|
||||
var cachelivefreed = parseInt(data.cacheinfo["cache-live-freed"]);
|
||||
$("#cache-live-freed").text(cachelivefreed);
|
||||
if (cachelivefreed > 0) {
|
||||
$("#cache-live-freed")
|
||||
.parent("tr")
|
||||
.addClass("lookatme");
|
||||
$("#cache-live-freed").parent("tr").addClass("lookatme");
|
||||
} else {
|
||||
$("#cache-live-freed")
|
||||
.parent("tr")
|
||||
.removeClass("lookatme");
|
||||
$("#cache-live-freed").parent("tr").removeClass("lookatme");
|
||||
}
|
||||
|
||||
// Update cache info every 10 seconds
|
||||
@@ -171,7 +165,7 @@ function loadCacheInfo() {
|
||||
}
|
||||
|
||||
var leasetable, staticleasetable;
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
if (document.getElementById("DHCPLeasesTable")) {
|
||||
leasetable = $("#DHCPLeasesTable").DataTable({
|
||||
dom: "<'row'<'col-sm-12'tr>><'row'<'col-sm-6'i><'col-sm-6'f>>",
|
||||
@@ -195,7 +189,7 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
//call draw() on each table... they don't render properly with scrollX and scrollY set... ¯\_(ツ)_/¯
|
||||
$('a[data-toggle="tab"]').on("shown.bs.tab", function() {
|
||||
$('a[data-toggle="tab"]').on("shown.bs.tab", function () {
|
||||
leasetable.draw();
|
||||
staticleasetable.draw();
|
||||
});
|
||||
@@ -204,8 +198,8 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
// Handle hiding of alerts
|
||||
$(function() {
|
||||
$("[data-hide]").on("click", function() {
|
||||
$(function () {
|
||||
$("[data-hide]").on("click", function () {
|
||||
$(this)
|
||||
.closest("." + $(this).attr("data-hide"))
|
||||
.hide();
|
||||
@@ -213,12 +207,12 @@ $(function() {
|
||||
});
|
||||
|
||||
// DHCP leases tooltips
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip({ html: true, container: "body" });
|
||||
});
|
||||
|
||||
// Change "?tab=" parameter in URL for save and reload
|
||||
$(".nav-tabs a").on("shown.bs.tab", function(e) {
|
||||
$(".nav-tabs a").on("shown.bs.tab", function (e) {
|
||||
var tab = e.target.hash.substring(1);
|
||||
window.history.pushState("", "", "?tab=" + tab);
|
||||
if (tab === "piholedhcp") {
|
||||
@@ -229,10 +223,10 @@ $(".nav-tabs a").on("shown.bs.tab", function(e) {
|
||||
});
|
||||
|
||||
// Auto dismissal for info notifications
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
var alInfo = $("#alInfo");
|
||||
if (alInfo.length) {
|
||||
alInfo.delay(3000).fadeOut(2000, function() {
|
||||
alInfo.delay(3000).fadeOut(2000, function () {
|
||||
alInfo.hide();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ var interval = 200;
|
||||
// Function that asks the API for new data
|
||||
function reloadData() {
|
||||
clearTimeout(timer);
|
||||
$.getJSON("scripts/pi-hole/php/tailLog.php?FTL&offset=" + offset, function(data) {
|
||||
$.getJSON("scripts/pi-hole/php/tailLog.php?FTL&offset=" + offset, function (data) {
|
||||
pre.append(data.lines);
|
||||
|
||||
if (scrolling && offset !== data.offset) {
|
||||
@@ -29,9 +29,9 @@ function reloadData() {
|
||||
timer = setTimeout(reloadData, interval);
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$(function () {
|
||||
// Get offset at first loading of page
|
||||
$.getJSON("scripts/pi-hole/php/tailLog.php?FTL", function(data) {
|
||||
$.getJSON("scripts/pi-hole/php/tailLog.php?FTL", function (data) {
|
||||
offset = data.offset;
|
||||
});
|
||||
pre = $("#output");
|
||||
@@ -39,11 +39,11 @@ $(function() {
|
||||
reloadData();
|
||||
});
|
||||
|
||||
$("#chk1").click(function() {
|
||||
$("#chk1").click(function () {
|
||||
$("#chk2").prop("checked", this.checked);
|
||||
scrolling = this.checked;
|
||||
});
|
||||
$("#chk2").click(function() {
|
||||
$("#chk2").click(function () {
|
||||
$("#chk1").prop("checked", this.checked);
|
||||
scrolling = this.checked;
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ var interval = 200;
|
||||
// Function that asks the API for new data
|
||||
function reloadData() {
|
||||
clearTimeout(timer);
|
||||
$.getJSON("scripts/pi-hole/php/tailLog.php?offset=" + offset, function(data) {
|
||||
$.getJSON("scripts/pi-hole/php/tailLog.php?offset=" + offset, function (data) {
|
||||
pre.append(data.lines);
|
||||
|
||||
if (scrolling && offset !== data.offset) {
|
||||
@@ -29,9 +29,9 @@ function reloadData() {
|
||||
timer = setTimeout(reloadData, interval);
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$(function () {
|
||||
// Get offset at first loading of page
|
||||
$.getJSON("scripts/pi-hole/php/tailLog.php", function(data) {
|
||||
$.getJSON("scripts/pi-hole/php/tailLog.php", function (data) {
|
||||
offset = data.offset;
|
||||
});
|
||||
pre = $("#output");
|
||||
@@ -39,11 +39,11 @@ $(function() {
|
||||
reloadData();
|
||||
});
|
||||
|
||||
$("#chk1").click(function() {
|
||||
$("#chk1").click(function () {
|
||||
$("#chk2").prop("checked", this.checked);
|
||||
scrolling = this.checked;
|
||||
});
|
||||
$("#chk2").click(function() {
|
||||
$("#chk2").click(function () {
|
||||
$("#chk1").prop("checked", this.checked);
|
||||
scrolling = this.checked;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user