mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-02 09:53:56 +08:00
29 lines
1013 B
HTML
29 lines
1013 B
HTML
<%
|
|
local map = self.map
|
|
local api = map.api
|
|
local prefix = self.option_prefix or ""
|
|
-%>
|
|
<div class="cbi-value" id="cbi-<%=self.config.."-"..section.."-"..self.option%>" data-index="<%=self.index%>" data-depends="<%=pcdata(self:deplist2json(section))%>">
|
|
<label class="cbi-value-title"><%:Generate key%></label>
|
|
<div class="cbi-value-field">
|
|
<input class="btn cbi-button" type="button" onclick="gen_wireguard_key(this)" value="<%:Generate key%>" />
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function gen_wireguard_key() {
|
|
XHR.get('<%=api.url("gen_wireguard_key")%>', {},
|
|
function(x, data) {
|
|
if (x && x.status == 200 && data.code == 1) {
|
|
const private_key_dom = getOption("<%=self.config%>", "<%=section%>", "<%=prefix%>wireguard_private_key");
|
|
private_key_dom.value = data.data.private_key;
|
|
|
|
const public_key_dom = getOption("<%=self.config%>", "<%=section%>", "<%=prefix%>wireguard_public_key");
|
|
public_key_dom.value = data.data.public_key;
|
|
} else {
|
|
alert("<%:Error%>");
|
|
}
|
|
});
|
|
}
|
|
</script>
|