From ef13e69125c495e7f3d0c017b54624ad54ea7cab Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 13 May 2020 22:01:58 +0100 Subject: [PATCH 1/4] Use REPLACE into instead of INSERT into. This allows for a domain's white/blacklist status to be toggled Signed-off-by: Adam Warner --- scripts/pi-hole/php/groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/groups.php b/scripts/pi-hole/php/groups.php index 94a5c079..a16c8d6a 100644 --- a/scripts/pi-hole/php/groups.php +++ b/scripts/pi-hole/php/groups.php @@ -443,7 +443,7 @@ if ($_POST['action'] == 'get_groups') { $domains = explode(' ', trim($_POST['domain'])); $total = count($domains); $added = 0; - $stmt = $db->prepare('INSERT INTO domainlist (domain,type,comment) VALUES (:domain,:type,:comment)'); + $stmt = $db->prepare('REPLACE INTO domainlist (domain,type,comment) VALUES (:domain,:type,:comment)'); if (!$stmt) { throw new Exception('While preparing statement: ' . $db->lastErrorMsg()); } From 6b8e12a0d1601968ba1d8b1c0f78e6257bc765a5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 13 May 2020 23:54:22 +0200 Subject: [PATCH 2/4] Fix autocomplete bug on group pages. Signed-off-by: DL6ER --- scripts/pi-hole/js/groups-adlists.js | 10 ++++++---- scripts/pi-hole/js/groups-clients.js | 14 ++++++++------ scripts/pi-hole/js/groups-domains.js | 14 ++++++++------ scripts/pi-hole/js/groups.js | 9 +++++++++ 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/scripts/pi-hole/js/groups-adlists.js b/scripts/pi-hole/js/groups-adlists.js index 87a7292f..fc223019 100644 --- a/scripts/pi-hole/js/groups-adlists.js +++ b/scripts/pi-hole/js/groups-adlists.js @@ -210,10 +210,12 @@ function initTable() { // Disable autocorrect in the search box var input = document.querySelector("input[type=search]"); - input.setAttribute("autocomplete", "off"); - input.setAttribute("autocorrect", "off"); - input.setAttribute("autocapitalize", "off"); - input.setAttribute("spellcheck", false); + if (input !== null) { + input.setAttribute("autocomplete", "off"); + input.setAttribute("autocorrect", "off"); + input.setAttribute("autocapitalize", "off"); + input.setAttribute("spellcheck", false); + } } function addAdlist() { diff --git a/scripts/pi-hole/js/groups-clients.js b/scripts/pi-hole/js/groups-clients.js index 49da0613..18762c67 100644 --- a/scripts/pi-hole/js/groups-clients.js +++ b/scripts/pi-hole/js/groups-clients.js @@ -64,12 +64,6 @@ $(document).ready(function () { $("#ip-custom").val(""); $("#ip-custom").prop("disabled", $("#select option:selected").val() !== "custom"); }); - // Disable autocorrect in the search box - var input = document.querySelector("input[type=search]"); - input.setAttribute("autocomplete", "off"); - input.setAttribute("autocorrect", "off"); - input.setAttribute("autocapitalize", "off"); - input.setAttribute("spellcheck", false); }); function initTable() { @@ -230,6 +224,14 @@ function initTable() { return data; } }); + // Disable autocorrect in the search box + var input = document.querySelector("input[type=search]"); + if (input !== null) { + input.setAttribute("autocomplete", "off"); + input.setAttribute("autocorrect", "off"); + input.setAttribute("autocapitalize", "off"); + input.setAttribute("spellcheck", false); + } table.on("order.dt", function () { var order = table.order(); diff --git a/scripts/pi-hole/js/groups-domains.js b/scripts/pi-hole/js/groups-domains.js index ebacb62d..3869d966 100644 --- a/scripts/pi-hole/js/groups-domains.js +++ b/scripts/pi-hole/js/groups-domains.js @@ -52,12 +52,6 @@ $(document).ready(function () { $("#wildcard_checkbox").prop("checked", false); } }); - // Disable autocorrect in the search box - var input = document.querySelector("input[type=search]"); - input.setAttribute("autocomplete", "off"); - input.setAttribute("autocorrect", "off"); - input.setAttribute("autocapitalize", "off"); - input.setAttribute("spellcheck", false); $("#add2black, #add2white").on("click", addDomain); @@ -286,6 +280,14 @@ function initTable() { } } }); + // Disable autocorrect in the search box + var input = document.querySelector("input[type=search]"); + if (input !== null) { + input.setAttribute("autocomplete", "off"); + input.setAttribute("autocorrect", "off"); + input.setAttribute("autocapitalize", "off"); + input.setAttribute("spellcheck", false); + } table.on("order.dt", function () { var order = table.order(); diff --git a/scripts/pi-hole/js/groups.js b/scripts/pi-hole/js/groups.js index 5ca900e5..879f457a 100644 --- a/scripts/pi-hole/js/groups.js +++ b/scripts/pi-hole/js/groups.js @@ -110,6 +110,15 @@ $(document).ready(function () { } }); + // Disable autocorrect in the search box + var input = document.querySelector("input[type=search]"); + if (input !== null) { + input.setAttribute("autocomplete", "off"); + input.setAttribute("autocorrect", "off"); + input.setAttribute("autocapitalize", "off"); + input.setAttribute("spellcheck", false); + } + table.on("order.dt", function () { var order = table.order(); if (order[0][0] !== 0 || order[0][1] !== "asc") { From 9b92548ae115ceeb4dbcf619b0fefb8a70e047e8 Mon Sep 17 00:00:00 2001 From: Jack'lul Date: Thu, 14 May 2020 17:38:49 +0200 Subject: [PATCH 3/4] Make sure ip-custom field is editable when no suggestions are available Signed-off-by: Jack'lul --- scripts/pi-hole/js/groups-clients.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/pi-hole/js/groups-clients.js b/scripts/pi-hole/js/groups-clients.js index 18762c67..7b775d87 100644 --- a/scripts/pi-hole/js/groups-clients.js +++ b/scripts/pi-hole/js/groups-clients.js @@ -32,6 +32,10 @@ function reload_client_suggestions() { sel.append($("