diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index 73c1dfab..4eee5c20 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -84,6 +84,23 @@ $(".confirm-flushlogs").confirm({ dialogClass: "modal-dialog modal-mg" }); +$(".confirm-disablelogging").confirm({ + text: "Note that disabling query logging will render graphs on the web user interface useless. Are you sure you want to disable your logging?", + title: "Confirmation required", + confirm(button) { + $("#disablelogsform").submit(); + }, + cancel(button) { + // nothing to do + }, + confirmButton: "Yes, disable logs", + cancelButton: "No, go back", + post: true, + confirmButtonClass: "btn-danger", + cancelButtonClass: "btn-success", + dialogClass: "modal-dialog modal-mg" +}); + $(".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", @@ -118,9 +135,6 @@ $(document).ready(function() { "scrollY": "200px", "scrollX" : true }); - $("#leaseexpand").on( "click", function () { - setTimeout(function(){leasetable.draw();},100); - } ); } if(document.getElementById("DHCPStaticLeasesTable")) { @@ -132,10 +146,13 @@ $(document).ready(function() { "scrollY": "200px", "scrollX" : true }); - $("#leaseexpand").on( "click", function () { - setTimeout(function(){staticleasetable.draw();},100); - } ); } + //call draw() on each table... they don't render properly with scrollX and scrollY set... ¯\_(ツ)_/¯ + $("a[data-toggle=\"tab\"]").on("shown.bs.tab", function (e) { + leasetable.draw(); + staticleasetable.draw(); + }); + } ); // Handle hiding of alerts @@ -152,12 +169,47 @@ $(document).ready(function(){ // Handle list deletion $("button[id^='adlist-btn-']").on("click", function (e) { + var id = parseInt($(this).context.id.replace(/[^0-9\.]/g, ""), 10); e.preventDefault(); - var status = $(this).siblings("input[name^='adlist-del-']").is(":checked"); + var status = $("input[name=\"adlist-del-"+id+"\"]").is(":checked"); var textType = status ? "none" : "line-through"; - $(this).siblings("input[name^='adlist-del-']").prop("checked", !status); - $(this).siblings("input[name^='adlist-enable-']").prop("disabled", !status); - $(this).siblings("a").css("text-decoration", textType); + // Check hidden delete box (or reset) + $("input[name=\"adlist-del-"+id+"\"]").prop("checked", !status); + // Untick and disable check box (or reset) + $("input[name=\"adlist-enable-"+id+"\"]").prop("checked", status).prop("disabled", !status); + // Strink through text (or reset) + $("a[id=\"adlist-text-"+id+"\"]").css("text-decoration", textType); + // Highlight that the button has to be clicked in order to make the change live + $("button[id=\"blockinglistsaveupdate\"]").addClass("btn-danger").css("font-weight", "bold"); + +}); + +// Javascript to go to specified tab on save or hyperlink +$(function () { + if(location.hash.length > 0) + { + var activeTab = $("[href=" + location.hash + "]"); + activeTab && activeTab.tab("show"); + } +}); +// Change hash for save and reload +$(".nav-tabs a").on("shown.bs.tab", function (e) { + window.location.hash = e.target.hash; + window.scrollTo(0, 0); +}); + +// Auto dismissal for info and error notifications +$(document).ready(function(){ + var alInfo = $("#alInfo"); + var alError = $("#alError"); + if(alInfo.length) + { + alInfo.delay(3000).fadeOut(2000, function() { alInfo.hide(); }); + } + if(alError.length) + { + alError.delay(3000).fadeOut(2000, function() { alError.hide(); }); + } }); diff --git a/settings.php b/settings.php index 2ef1de67..4450b873 100644 --- a/settings.php +++ b/settings.php @@ -5,940 +5,1218 @@ * * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. */ - require "scripts/pi-hole/php/header.php"; - require "scripts/pi-hole/php/savesettings.php"; - // Reread ini file as things might have been changed - $setupVars = parse_ini_file("/etc/pihole/setupVars.conf"); +require "scripts/pi-hole/php/header.php"; +require "scripts/pi-hole/php/savesettings.php"; +// Reread ini file as things might have been changed +$setupVars = parse_ini_file("/etc/pihole/setupVars.conf"); -function command_exist($cmd) { - return !empty(shell_exec(sprintf("which %s", escapeshellarg($cmd)))); +function command_exist($cmd) +{ + return !empty(shell_exec(sprintf("which %s", escapeshellarg($cmd)))); } + ?> refresh to the gravity page and start updating immediately -?> - - +if (isset($_POST["submit"])) { + if ($_POST["submit"] == "saveupdate") { + // If that is the case -> refresh to the gravity page and start updating immediately + ?> + + - -
Warning: PHP has been compiled without IPv6 support.
-Current status: - - Enabled (recommended) - - Disabled -
- -Note that disabling will render graphs on the web user interface useless
- -