From 44e1a9b8cd69358e803a7553e87518289e671f52 Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Wed, 17 Jan 2024 19:17:41 -0300 Subject: [PATCH 01/17] Move code used to format icons to a dedicated function also surround the icons with a SPAN tag. Signed-off-by: RD WebDesign --- scripts/pi-hole/js/settings-advanced.js | 26 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/pi-hole/js/settings-advanced.js b/scripts/pi-hole/js/settings-advanced.js index 9f73bf74..a2dd44f8 100644 --- a/scripts/pi-hole/js/settings-advanced.js +++ b/scripts/pi-hole/js/settings-advanced.js @@ -24,6 +24,22 @@ function addAllowedValues(allowed) { } } +function boxIcons(value) { + return ( + '' + + (value.modified + ? '  ' + : "") + + (value.flags.restart_dnsmasq + ? '  ' + : "") + + (value.flags.env_var + ? '  ' + : "") + + "" + ); +} + function generateRow(topic, key, value) { // If the value is an object, we need to recurse if (!("description" in value)) { @@ -44,15 +60,7 @@ function generateRow(topic, key, value) { (value.modified ? "true" : "false") + '">' + key + - (value.modified - ? '  ' - : "") + - (value.flags.restart_dnsmasq - ? '  ' - : "") + - (value.flags.env_var - ? '  ' - : "") + + boxIcons(value) + "" + "

" + utils.escapeHtml(value.description).replaceAll("\n", "
") + From e9df0064894d565e12bd39f064acfa929dd9fd8a Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Wed, 17 Jan 2024 19:37:40 -0300 Subject: [PATCH 02/17] Move value details and layout to a dedicated function Signed-off-by: RD WebDesign --- scripts/pi-hole/js/settings-advanced.js | 92 ++++++++++++++----------- 1 file changed, 51 insertions(+), 41 deletions(-) diff --git a/scripts/pi-hole/js/settings-advanced.js b/scripts/pi-hole/js/settings-advanced.js index a2dd44f8..b110c972 100644 --- a/scripts/pi-hole/js/settings-advanced.js +++ b/scripts/pi-hole/js/settings-advanced.js @@ -40,34 +40,8 @@ function boxIcons(value) { ); } -function generateRow(topic, key, value) { - // If the value is an object, we need to recurse - if (!("description" in value)) { - Object.keys(value).forEach(function (subkey) { - var subvalue = value[subkey]; - generateRow(topic, key + "." + subkey, subvalue); - }); - return; - } - - // else: we have a setting we can display - var box = - '

' + - '
' + - '

' + - key + - boxIcons(value) + - "

" + - "

" + - utils.escapeHtml(value.description).replaceAll("\n", "
") + - "

" + - "
" + - '
' + - '
'; +function valueDetails(key, value) { + // Define default hint text let defaultValueHint = ""; if (value.modified) { defaultValueHint = ""; @@ -99,16 +73,19 @@ function generateRow(topic, key, value) { } } + // Define extraAttributes, if needed let extraAttributes = ""; if (value.flags.env_var) { extraAttributes = " disabled"; } + // Format the output depending on the value type + let content = ""; switch (value.type) { case "IPv4 address": case "IPv6 address": case "string": { - box += + content += '' + '
' + '' + '' + '' + '' + '' + '