From 6a61320ea0b6a96bb33cc7e1049b7ca5fb7a3614 Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 17 Oct 2025 10:28:16 -0700 Subject: [PATCH] Add contextual bridged interface settings --- app/js/ui/main.js | 32 +++++++++++++++++++++++ templates/hostapd/advanced.php | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/app/js/ui/main.js b/app/js/ui/main.js index 008765c6..dc623236 100644 --- a/app/js/ui/main.js +++ b/app/js/ui/main.js @@ -78,6 +78,38 @@ $(document).on("submit", ".js-dhcp-settings-form", function(e) { $(".js-add-dhcp-upstream-server").trigger("click"); }); +document.addEventListener('DOMContentLoaded', function() { + const bridgeCheckbox = document.getElementById('chxbridgedenable'); + const bridgeSection = document.getElementById('bridgeStaticIpSection'); + const staticIpInput = document.getElementById('bridgeStaticIp'); + const previewIp = document.getElementById('previewStaticIp'); + + // toggle visibility + bridgeCheckbox.addEventListener('change', function() { + bridgeSection.style.display = this.checked ? 'block' : 'none'; + }); + + staticIpInput.addEventListener('input', function() { + previewIp.textContent = this.value || 'your-static-ip'; + }); + + const form = bridgeCheckbox.closest('form'); + if (form) { + form.addEventListener('submit', function(e) { + if (bridgeCheckbox.checked) { + const staticIp = staticIpInput.value.trim(); + const gateway = document.getElementById('bridgeGateway').value.trim(); + + if (staticIp && !gateway) { + e.preventDefault(); + // raise alert + return false; + } + } + }); + } +}); + /** * mark a form field, e.g. a select box, with the class `.js-field-preset` * and give it an attribute `data-field-preset-target` with a text field's diff --git a/templates/hostapd/advanced.php b/templates/hostapd/advanced.php index 1476d5d4..fa46009f 100644 --- a/templates/hostapd/advanced.php +++ b/templates/hostapd/advanced.php @@ -10,6 +10,54 @@ + +
+
+
+
+
+

+ br0 interface to maintain connectivity during bridged mode. Leave blank to use DHCP (not recommended)."); ?> +

+ +
+
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+