mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-18 06:02:53 +08:00
59 lines
2.0 KiB
HTML
59 lines
2.0 KiB
HTML
<script type="text/javascript">
|
|
//<![CDATA[
|
|
let node_id = "<%=self.section%>";
|
|
let node_config_url = '<%=self.api.url("node_config")%>/' + node_id;
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
waitForElement('select[name*="<%=self.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("<%=self.config%>", "<%=self.section%>", "remarks").value,
|
|
group: getOption("<%=self.config%>", "<%=self.section%>", "group").value,
|
|
type: getOption("<%=self.config%>", "<%=self.section%>", "type").value,
|
|
//protocol: ''
|
|
}, node_config_url);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
waitForElement('select[name*="<%=self.config%>"][name*="protocol"]', function(el) {
|
|
let o_val = el.value;
|
|
el.addEventListener("change", () => {
|
|
el.blur();
|
|
if (el.value.startsWith("_") || (o_val.startsWith("_") && !el.value.startsWith("_"))) {
|
|
let name_split = el.name.split(".");
|
|
let name = name_split[name_split.length - 1];
|
|
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("<%=self.config%>", "<%=self.section%>", "remarks").value,
|
|
group: getOption("<%=self.config%>", "<%=self.section%>", "group").value,
|
|
protocol: getOption("<%=self.config%>", "<%=self.section%>", name).value,
|
|
}, node_config_url);
|
|
} else {
|
|
window.location.href = node_config_url + "?select_proto=" + el.value;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
//]]>
|
|
</script>
|