mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-09-14 04:14:40 +08:00
update 2026-07-27 22:20:34
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
<%
|
||||
local api = require "luci.passwall.api"
|
||||
local appname = api.appname
|
||||
-%>
|
||||
|
||||
<style>
|
||||
@media screen and (min-width: 1152px) {
|
||||
#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;
|
||||
}
|
||||
}
|
||||
</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 lbssHiddenInput = lastRow.querySelector("div.cbi-dropdown > div > input[type='hidden'][name$='.lbss']");
|
||||
if (!lbssHiddenInput) {
|
||||
if (lastVal !== secondLastVal && secondLastVal !== "" && secondLastVal !== "0") {
|
||||
lastInput.value = secondLastVal;
|
||||
}
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
@@ -1,30 +0,0 @@
|
||||
<%
|
||||
local api = require "luci.passwall.api"
|
||||
local haproxy_enable = api.uci_get_type("global_haproxy", "balancing_enable", "0")
|
||||
local console_port = api.uci_get_type("global_haproxy", "console_port", "")
|
||||
-%>
|
||||
<p id="_status"></p>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
const haproxy_enable = "<%=haproxy_enable%>";
|
||||
if (haproxy_enable == "1") {
|
||||
function openwebui(){
|
||||
var url = window.location.hostname + ":<%=console_port%>";
|
||||
window.open('http://' + url, 'target', '');
|
||||
}
|
||||
XHR.poll(5, '<%=api.url("haproxy_status")%>', null,
|
||||
function(x, result) {
|
||||
if (x && x.status == 200) {
|
||||
var _status = document.getElementById('_status');
|
||||
if (_status) {
|
||||
if (result.status) {
|
||||
_status.innerHTML = '<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Enter interface%>" onclick="openwebui()" />';
|
||||
} else {
|
||||
_status.innerHTML = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
//]]></script>
|
||||
Reference in New Issue
Block a user