mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-02 05:03:56 +08:00
74 lines
2.3 KiB
HTML
74 lines
2.3 KiB
HTML
<%
|
|
local map = self.map
|
|
local api = map.api
|
|
local sid = self.section
|
|
local config = map.config
|
|
-%>
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
let node_id = "<%=sid%>";
|
|
let node_config_url = '<%=api.url("node_config")%>/' + node_id;
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
waitForElement('select[name*="<%=config%>"][name*="type"]', function(el) {
|
|
let o_val = el.value;
|
|
el.addEventListener("change", () => {
|
|
el.blur();
|
|
if (o_val != el.value) {
|
|
let save = true;
|
|
if (save) {
|
|
/*
|
|
const saveBtn = document.getElementsByClassName('cbi-button-save');
|
|
if (saveBtn && saveBtn.length > 0) {
|
|
saveBtn[saveBtn.length - 1].click();
|
|
}
|
|
*/
|
|
update_config(node_id, {
|
|
remarks: getOption("<%=config%>", "<%=sid%>", "remarks").value,
|
|
group: getOption("<%=config%>", "<%=sid%>", "group").value,
|
|
type: el.value,
|
|
protocol: ''
|
|
}, node_config_url);
|
|
}
|
|
}
|
|
});
|
|
const fromUrlCache = JSON.parse(sessionStorage.getItem("fromUrl"));
|
|
if (fromUrlCache && fromUrlCache.savetime && (Date.now() - fromUrlCache.timestamp) < fromUrlCache.savetime) {
|
|
fromUrl(fromUrlCache.link, true)
|
|
} else {
|
|
sessionStorage.removeItem("fromUrl");
|
|
}
|
|
});
|
|
waitForElement('select[name*="<%=config%>"][name*="protocol"]', function(el) {
|
|
let o_val = el.value;
|
|
const name_split = el.name.split(".");
|
|
const name = name_split[name_split.length - 1];
|
|
el.addEventListener("change", () => {
|
|
el.blur();
|
|
if (el.value.startsWith("_") || (o_val.startsWith("_") && !el.value.startsWith("_"))) {
|
|
if (el.value.startsWith("_")) {
|
|
const map = document.getElementById("cbi-<%=config%>");
|
|
const hiddenInput = document.createElement('input');
|
|
hiddenInput.type = 'hidden';
|
|
hiddenInput.name = 'load' + el.value;
|
|
hiddenInput.value = '1';
|
|
map.appendChild(hiddenInput);
|
|
}
|
|
const saveBtn = document.getElementsByClassName('cbi-button-save');
|
|
if (saveBtn && saveBtn.length > 0) {
|
|
saveBtn[saveBtn.length - 1].click();
|
|
}
|
|
/*
|
|
update_config(node_id, {
|
|
remarks: getOption("<%=config%>", "<%=sid%>", "remarks").value,
|
|
group: getOption("<%=config%>", "<%=sid%>", "group").value,
|
|
protocol: el.value,
|
|
}, node_config_url);
|
|
*/
|
|
}
|
|
});
|
|
});
|
|
});
|
|
//]]>
|
|
</script>
|