mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-17 14:02:59 +08:00
131 lines
3.7 KiB
HTML
131 lines
3.7 KiB
HTML
<%
|
|
local map = self.map
|
|
local appname = map.config
|
|
-%>
|
|
|
|
<style>
|
|
@media screen and (min-width: 1153px) {
|
|
#cbi-<%=appname%>-haproxy_config input[id*=".<%=appname%>."][id$=".haproxy_port"],
|
|
#cbi-<%=appname%>-haproxy_config input[id*=".<%=appname%>."][id$=".lbweight"] {
|
|
width: 100px !important;
|
|
min-width: unset !important;
|
|
max-width: unset !important;
|
|
text-align: center !important;
|
|
}
|
|
|
|
#cbi-<%=appname%>-haproxy_config select[id*=".<%=appname%>."][id$=".export"] {
|
|
width: 130px !important;
|
|
min-width: unset !important;
|
|
max-width: unset !important;
|
|
}
|
|
|
|
#cbi-<%=appname%>-haproxy_config select[id*=".<%=appname%>."][id$=".backup"] {
|
|
width: 100px !important;
|
|
min-width: unset !important;
|
|
max-width: unset !important;
|
|
}
|
|
}
|
|
|
|
@media screen and (max-width: 1152px) {
|
|
/* Use the same narrow-screen table layout across themes. */
|
|
#cbi-<%=appname%>-haproxy_config .cbi-section-table,
|
|
#cbi-<%=appname%>-haproxy_config .cbi-section-table > tbody {
|
|
display: block;
|
|
}
|
|
|
|
#cbi-<%=appname%>-haproxy_config .cbi-section-table-titles {
|
|
display: none !important;
|
|
}
|
|
|
|
#cbi-<%=appname%>-haproxy_config .cbi-section-table-row {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
#cbi-<%=appname%>-haproxy_config .cbi-section-table-row > .td {
|
|
display: block;
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
flex: 1 1 50%;
|
|
min-width: 0;
|
|
width: auto !important;
|
|
height: auto;
|
|
}
|
|
|
|
#cbi-<%=appname%>-haproxy_config .cbi-section-table-row > .td[data-title]::before {
|
|
content: attr(data-title);
|
|
display: block;
|
|
}
|
|
|
|
#cbi-<%=appname%>-haproxy_config .cbi-section-table-row > .td.cbi-section-actions {
|
|
flex: 1 1 100%;
|
|
}
|
|
|
|
#cbi-<%=appname%>-haproxy_config .cbi-value-field input:not([type="checkbox"], [type="radio"], [type="hidden"]),
|
|
#cbi-<%=appname%>-haproxy_config .cbi-value-field select {
|
|
box-sizing: border-box;
|
|
min-width: 0;
|
|
max-width: 100%;
|
|
}
|
|
|
|
/* Keep the enable column compact in mobile table cards. */
|
|
#cbi-<%=appname%>-haproxy_config .cbi-section-table-row > .td[data-name="enabled"] {
|
|
flex: 0 0 4.5em;
|
|
}
|
|
|
|
#cbi-<%=appname%>-haproxy_config .cbi-section-table-row > .td[data-name="lbss"] {
|
|
flex: 1 1 calc(100% - 4.5em);
|
|
min-width: 0;
|
|
}
|
|
}
|
|
</style>
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
let monitorStartTime = Date.now();
|
|
|
|
const monitorInterval = setInterval(function () {
|
|
if (Date.now() - monitorStartTime > 3000) {
|
|
clearInterval(monitorInterval);
|
|
return;
|
|
}
|
|
|
|
const rows = Array.from(document.querySelectorAll("tr.cbi-section-table-row"))
|
|
.filter(row => !row.classList.contains("placeholder")); // 排除无配置行
|
|
|
|
if (rows.length <= 1) return;
|
|
|
|
const lastRow = rows[rows.length - 1];
|
|
const secondLastRow = rows[rows.length - 2];
|
|
|
|
const lastInput = lastRow.querySelector("input[name$='.haproxy_port']");
|
|
const secondLastInput = secondLastRow.querySelector("input[name$='.haproxy_port']");
|
|
|
|
if (!lastInput || !secondLastInput) return;
|
|
|
|
// 如果还没绑定 change 事件,绑定一次
|
|
if (!lastInput.dataset.bindChange) {
|
|
lastInput.dataset.bindChange = "1";
|
|
lastInput.addEventListener("input", () => {
|
|
lastInput.dataset.userModified = "1";
|
|
});
|
|
}
|
|
|
|
// 如果用户手动修改过,就不再自动设置
|
|
if (lastInput.dataset.userModified === "1") return;
|
|
|
|
const lastVal = lastInput.value.trim();
|
|
const secondLastVal = secondLastInput.value.trim();
|
|
|
|
const lbssInput = lastRow.querySelector("input[type='text'][name$='.lbss']");
|
|
const hasNodeSelected = lbssInput && lbssInput.value && lbssInput.value.trim() !== "";
|
|
if (!hasNodeSelected) {
|
|
if (lastVal !== secondLastVal && secondLastVal !== "" && secondLastVal !== "0") {
|
|
lastInput.value = secondLastVal;
|
|
}
|
|
}
|
|
}, 300);
|
|
});
|
|
//]]>
|
|
</script>
|