add config editor elements to ihr web

workspace
Brendan Howell 5 years ago
parent 8cfd7b94ae
commit fb993f5b2e

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Screenless Office - config file editor</title> <title>Screenless Office - edit ${cfgfile}</title>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
#editor { #editor {
position: absolute; position: absolute;
@ -14,27 +14,21 @@
</head> </head>
<body> <body>
<h3>The Screenless Office</h3> <h3>The Screenless Office</h3>
<h4> edit config file <em>$cfgfile</em></h4> <h4> edit config file <em>${cfgfile}</em></h4>
<div id="editor">$cfgdata</div> <div id="editor">${cfgdata}</div>
<form id="cfgform" action="/config/$bureau" method="post"> <form id="cfgform" action="/config/${bureau}" method="post">
<input type="hidden" value="$cfgdata" name="cfgdata_field" id="cfgdata_field" /> <input type="hidden" value="${cfgdata}" name="cfgdata_field" id="cfgdata_field" />
<input type="submit" value="Save" name="operation" onclick="saveConfig()"> <input type="submit" value="Save" name="operation" onclick="saveConfig()">
</form> </form>
#BUTTON
#FIELD for CFGDATA and CFGFILE
#JAVASCRIPT to confirm and submit data
<script src="/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script> <script src="/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script> <script>
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai"); editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/$mode"); editor.session.setMode("ace/mode/${mode}");
function saveConfig(){ function saveConfig(){
let cfgdata_field = document.getElementById("cfgdata_field"); let cfgdata_field = document.getElementById("cfgdata_field");
cfgdata_field.value = editor.getValue(); cfgdata_field.value = editor.getValue();
if(confirm("Really overwrite $cfgfile?")){ if(confirm("Really overwrite ${cfgfile}?")){
document.forms[0].submit(); document.forms[0].submit();
} }
} }

Loading…
Cancel
Save