diff --git a/scripts/pi-hole/js/settings-advanced.js b/scripts/pi-hole/js/settings-advanced.js
index 9f73bf74..3d7e4332 100644
--- a/scripts/pi-hole/js/settings-advanced.js
+++ b/scripts/pi-hole/js/settings-advanced.js
@@ -24,42 +24,24 @@ function addAllowedValues(allowed) {
}
}
-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 =
- '
";
+}
+
+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 =
+ '
+ `);
});
+
+ // Dynamically fill the tabs with config topics
Object.keys(data.config).forEach(function (topic) {
var value = data.config[topic];
generateRow(topic, topic, value, data);
});
$("#advanced-overlay").hide();
+ // Select the first tab and show the content
+ $("#advanced-settings-menu ul li:first-child").addClass("active");
+ $("#advanced-settings-tabs > div:first-child").addClass("active in");
+
$("button[id='save']").on("click", function () {
saveSettings();
});
@@ -365,28 +373,32 @@ function initOnlyChanged() {
function applyOnlyChanged() {
if (localStorage.getItem("only-changed") === "true") {
- // Hide all boxes that have a data-key attribute
+ // Show only modified settings (hide tabs menu and empty tabs).
+
+ // Hide the tabs menu
+ $("#advanced-settings-menu").hide();
+
+ // Show all tabs, except the ones containing "data-modified='true'" attribute
+ // to prevent empty tabs (using the same classes used by Boostrap3)
+ $("#advanced-settings-tabs > .tab-pane").addClass("in active");
+ $("#advanced-settings-tabs > .tab-pane:not(:has(h3[data-modified='true']))").removeClass(
+ "in active"
+ );
+
+ // Hide all boxes with data-key attribute, except the ones with "data-modified='true'" attribute
$(".box-title[data-key]").not("[data-modified='true']").closest(".box").hide();
} else {
- // Show all boxes that have a data-key attribute
+ // Show the tabs menu and activate only the first button (deactivate other buttons)
+ $("#advanced-settings-menu").show();
+ $("#advanced-settings-menu ul li").removeClass("active");
+ $("#advanced-settings-menu ul li:first-child").addClass("active");
+
+ // Hide all tabs, except the first one (removing the classes used by Boostrap3)
+ $("#advanced-settings-tabs > .tab-pane:not(:first-child)").removeClass("in active");
+
+ // Show all boxes with data-key attribute
$(".box-title[data-key]").closest(".box").show();
}
-
- // Hide group headers on the all settings page after toggling to show only
- // modified settings if there are no modified settings within that group. This
- // prevents empty boxes when only-changed is enabled by hiding all boxes if
- // the box does not have at least one visible box as a child
- $(".box-title:not([data-key])").each(function () {
- const box = $(this).closest(".box");
- if (
- box.find(".box-title[data-key]:visible").length === 0 &&
- localStorage.getItem("only-changed") === "true"
- ) {
- box.hide();
- } else {
- box.show();
- }
- });
}
$(document).ready(function () {
diff --git a/settings-all.lp b/settings-all.lp
index f7253619..40c49f6b 100644
--- a/settings-all.lp
+++ b/settings-all.lp
@@ -14,11 +14,21 @@ PageTitle = "All Settings"
mg.include('scripts/pi-hole/lua/settings_header.lp','r')
?>