kenzok8-package/luci-app-openclash/luasrc/view/openclash/input_rename.htm
github-actions[bot] 19d8492c5a update 03-20 01:01
2022-03-20 01:01:06 +08:00

24 lines
955 B
HTML

<%+cbi/valueheader%>
<script type="text/javascript">
//<![CDATA[
function import_new_file_name(btn, file_path, file_name) {
var new_file_name = prompt("<%:Paste the new file name (including the extension) here:%>", "");
if (new_file_name == null || new_file_name == "") {
return false;
}
if (file_path == "/etc/openclash/config/" && new_file_name.split('.').pop() != "yaml" && new_file_name.split('.').pop() != "yml") {
alert('<%:Illegal extension!%>')
return false;
}
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "rename_file")%>', {new_file_name: new_file_name, file_path: file_path, file_name: file_name}, function(x, status) {
if (x && x.status == 200)
{
location.reload();
}
});
}
//]]>
</script>
<input type="button" class="btn cbi-button cbi-button-reset" value="<%:Rename%>" onclick="return import_new_file_name(this, '<%=self.option%>', '<%=self.value%>')" />
<%+cbi/valuefooter%>