parent
742ce9dad3
commit
0ed09713e8
@ -135,7 +135,7 @@ end
|
||||
---- Haproxy Port
|
||||
o = s:option(Value, "haproxy_port", translate("Haproxy Port"))
|
||||
o.datatype = "port"
|
||||
o.default = 1181
|
||||
o.default = 65535
|
||||
o.rmempty = false
|
||||
|
||||
---- Node Weight
|
||||
@ -158,4 +158,6 @@ o:value(0, translate("Primary"))
|
||||
o:value(1, translate("Standby"))
|
||||
o.rmempty = false
|
||||
|
||||
s:append(Template(appname .. "/haproxy/js"))
|
||||
|
||||
return m
|
||||
|
40
luci-app-passwall/luasrc/view/passwall/haproxy/js.htm
Normal file
40
luci-app-passwall/luasrc/view/passwall/haproxy/js.htm
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
let monitorStartTime = Date.now();
|
||||
|
||||
const monitorInterval = setInterval(function () {
|
||||
// 超过5秒后停止监控
|
||||
if (Date.now() - monitorStartTime > 5000) {
|
||||
clearInterval(monitorInterval);
|
||||
return;
|
||||
}
|
||||
|
||||
const rows = Array.from(document.querySelectorAll("tr.cbi-section-table-row"))
|
||||
.filter(row => !row.classList.contains("placeholder")); // 排除无配置行
|
||||
|
||||
if (rows.length === 0) return;
|
||||
|
||||
const lastRow = rows[rows.length - 1];
|
||||
const lastPortInput = lastRow.querySelector("input[name$='.haproxy_port']");
|
||||
|
||||
// 没找到最后一行的 port 输入框或 port 不是 65535,跳过
|
||||
if (!lastPortInput || lastPortInput.value !== "65535") return;
|
||||
|
||||
if (rows.length === 1) {
|
||||
lastPortInput.value = "1181";
|
||||
} else {
|
||||
const prevRow = rows[rows.length - 2];
|
||||
const prevPortInput = prevRow.querySelector("input[name$='.haproxy_port']");
|
||||
const prevValue = prevPortInput ? prevPortInput.value.trim() : "";
|
||||
if (prevValue === "" || prevValue === "0") {
|
||||
lastPortInput.value = "1181";
|
||||
} else {
|
||||
lastPortInput.value = prevValue;
|
||||
}
|
||||
}
|
||||
}, 300); // 每 300ms 检查一次
|
||||
});
|
||||
//]]>
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user