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