parent
0ed09713e8
commit
d83dfa27b1
@ -135,7 +135,7 @@ end
|
|||||||
---- Haproxy Port
|
---- Haproxy Port
|
||||||
o = s:option(Value, "haproxy_port", translate("Haproxy Port"))
|
o = s:option(Value, "haproxy_port", translate("Haproxy Port"))
|
||||||
o.datatype = "port"
|
o.datatype = "port"
|
||||||
o.default = 65535
|
o.default = 1181
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
|
|
||||||
---- Node Weight
|
---- Node Weight
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
let monitorStartTime = Date.now();
|
let monitorStartTime = Date.now();
|
||||||
|
|
||||||
const monitorInterval = setInterval(function () {
|
const monitorInterval = setInterval(function () {
|
||||||
// 超过5秒后停止监控
|
if (Date.now() - monitorStartTime > 3000) {
|
||||||
if (Date.now() - monitorStartTime > 5000) {
|
|
||||||
clearInterval(monitorInterval);
|
clearInterval(monitorInterval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -14,27 +13,34 @@
|
|||||||
const rows = Array.from(document.querySelectorAll("tr.cbi-section-table-row"))
|
const rows = Array.from(document.querySelectorAll("tr.cbi-section-table-row"))
|
||||||
.filter(row => !row.classList.contains("placeholder")); // 排除无配置行
|
.filter(row => !row.classList.contains("placeholder")); // 排除无配置行
|
||||||
|
|
||||||
if (rows.length === 0) return;
|
if (rows.length <= 1) return;
|
||||||
|
|
||||||
const lastRow = rows[rows.length - 1];
|
const lastRow = rows[rows.length - 1];
|
||||||
const lastPortInput = lastRow.querySelector("input[name$='.haproxy_port']");
|
const secondLastRow = rows[rows.length - 2];
|
||||||
|
|
||||||
// 没找到最后一行的 port 输入框或 port 不是 65535,跳过
|
const lastInput = lastRow.querySelector("input[name$='.haproxy_port']");
|
||||||
if (!lastPortInput || lastPortInput.value !== "65535") return;
|
const secondLastInput = secondLastRow.querySelector("input[name$='.haproxy_port']");
|
||||||
|
|
||||||
if (rows.length === 1) {
|
if (!lastInput || !secondLastInput) return;
|
||||||
lastPortInput.value = "1181";
|
|
||||||
} else {
|
// 如果还没绑定 change 事件,绑定一次
|
||||||
const prevRow = rows[rows.length - 2];
|
if (!lastInput.dataset.bindChange) {
|
||||||
const prevPortInput = prevRow.querySelector("input[name$='.haproxy_port']");
|
lastInput.dataset.bindChange = "1";
|
||||||
const prevValue = prevPortInput ? prevPortInput.value.trim() : "";
|
lastInput.addEventListener("input", () => {
|
||||||
if (prevValue === "" || prevValue === "0") {
|
lastInput.dataset.userModified = "1";
|
||||||
lastPortInput.value = "1181";
|
});
|
||||||
} else {
|
|
||||||
lastPortInput.value = prevValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果用户手动修改过,就不再自动设置
|
||||||
|
if (lastInput.dataset.userModified === "1") return;
|
||||||
|
|
||||||
|
const lastVal = lastInput.value.trim();
|
||||||
|
const secondLastVal = secondLastInput.value.trim();
|
||||||
|
|
||||||
|
if (lastVal !== secondLastVal && secondLastVal !== "" && secondLastVal !== "0") {
|
||||||
|
lastInput.value = secondLastVal;
|
||||||
}
|
}
|
||||||
}, 300); // 每 300ms 检查一次
|
}, 300);
|
||||||
});
|
});
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user