diff --git a/files/app/main/status/e/tunnels.ut b/files/app/main/status/e/tunnels.ut index a637c508..afc3cc21 100755 --- a/files/app/main/status/e/tunnels.ut +++ b/files/app/main/status/e/tunnels.ut @@ -420,38 +420,41 @@ This value is used by default, but each tunnel may overide it. server = e.target.value; } }); - htmx.on("input[name=tunnel_range_start]", "change", e => { - available.l = {}; - available.w = {}; - if (e.target.validity.valid) { - const l = e.target.value.split(".").map(v => parseInt(v)); - const w = [ l[0], l[1], (l[2] === 255 ? 0 : l[2] + 1), l[3] ]; - for (let i = 0; i < 62; i++) { - available.l[`${l[0]}.${l[1]}.${l[2]}.${l[3]}`] = 1; - l[3] += 4; - if (l[3] >= 252) { - l[2]++; - if (l[2] === 256) { - l[2] = 0; + const rangeStart = htmx.find("input[name=tunnel_range_start]"); + if (rangeStart) { + htmx.on(rangeStart, "change", e => { + available.l = {}; + available.w = {}; + if (e.target.validity.valid) { + const l = e.target.value.split(".").map(v => parseInt(v)); + const w = [ l[0], l[1], (l[2] === 255 ? 0 : l[2] + 1), l[3] ]; + for (let i = 0; i < 62; i++) { + available.l[`${l[0]}.${l[1]}.${l[2]}.${l[3]}`] = 1; + l[3] += 4; + if (l[3] >= 252) { + l[2]++; + if (l[2] === 256) { + l[2] = 0; + } + l[3] = 4; } - l[3] = 4; + } + let p = {{uciMesh.get("aredn", "@supernode[0]", "enable") === "1" ? 6526 : 5525}}; + for (let i = 0; i < 126; i++) { + available.w[`${w[0]}.${w[1]}.${w[2]}.${w[3]}:${p}`] = 1; + w[3] += 2; + if (w[3] >= 254) { + w[2]++; + if (w[2] === 256) { + w[2] = 0; + } + w[3] = 2; + } + p++; } } - let p = {{uciMesh.get("aredn", "@supernode[0]", "enable") === "1" ? 6526 : 5525}}; - for (let i = 0; i < 126; i++) { - available.w[`${w[0]}.${w[1]}.${w[2]}.${w[3]}:${p}`] = 1; - w[3] += 2; - if (w[3] >= 254) { - w[2]++; - if (w[2] === 256) { - w[2] = 0; - } - w[3] = 2; - } - p++; - } - } - }); + }); + } function newTunnelEntry() { const type = htmx.find("#tunnel-templates select").value;