1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00
openmptcprouter-feeds/luci-app-adguardhome/luasrc/view/AdGuardHome/yamleditor.htm
2023-07-24 15:26:29 +08:00

39 lines
No EOL
1.8 KiB
HTML
Executable file

<%+cbi/valueheader%>
<script src="/luci-static/resources/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="/luci-static/resources/codemirror/lib/codemirror.css"/>
<script src="/luci-static/resources/codemirror/mode/yaml/yaml.js"></script>
<link rel="stylesheet" href="/luci-static/resources/codemirror/theme/dracula.css"/>
<link rel="stylesheet" href="/luci-static/resources/codemirror/addon/fold/foldgutter.css"/>
<script src="/luci-static/resources/codemirror/addon/fold/foldcode.js"></script>
<script src="/luci-static/resources/codemirror/addon/fold/foldgutter.js"></script>
<script src="/luci-static/resources/codemirror/addon/fold/indent-fold.js"></script>
<script type="text/javascript">//<![CDATA[
var editor = CodeMirror.fromTextArea(document.getElementById("cbid.AdGuardHome.AdGuardHome.escconf"), {
mode: "text/yaml", //实现groovy代码高亮
styleActiveLine: true,
lineNumbers: true, //显示行号
theme: "dracula", //设置主题
lineWrapping: true, //代码折叠
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
matchBrackets: true //括号匹配
}
);
function reload_config(){
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[reloadconfig]])%>', null,
function(x, data) {
location.reload();
});}
function use_template(){
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[gettemplateconfig]])%>', null,
function(x, data) {
editor.setValue(x.responseText)
});}
//]]>
</script>
<%fs=require"nixio.fs"%>
<%if fs.access("/tmp/AdGuardHometmpconfig.yaml") then%>
<input type="button" id="apply_update_button" value="<%:Reload Config%>" onclick=" return reload_config() "/>
<%end%>
<input type="button" id="template_button" value="<%:Use template%>" onclick=" return use_template() "/>
<%+cbi/valuefooter%>