mirror of https://github.com/IoTcat/PyOne.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.0 KiB
67 lines
2.0 KiB
{%extends 'admin/layout.html'%} |
|
|
|
{%block content%} |
|
<style type="text/css" media="screen"> |
|
#editor { |
|
/*height:800px;*/ |
|
} |
|
</style> |
|
<div class="mdui-container"> |
|
<h4>添加文件 - {{filename}}</h4> |
|
<pre id="editor" ></pre> |
|
<button class="mdui-btn mdui-btn-icon" onclick="SubmitNew()"> |
|
<i class="mdui-icon material-icons"></i> |
|
</button> |
|
</div> |
|
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ace.js"></script> |
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ext-language_tools.js"></script> |
|
<script> |
|
|
|
var editor = ace.edit("editor"); |
|
editor.setTheme("ace/theme/ambiance"); |
|
editor.setFontSize(18); |
|
editor.session.setMode("ace/mode/Text"); |
|
|
|
//Autocompletion |
|
editor.setOptions({ |
|
enableBasicAutocompletion: true, |
|
enableSnippets: true, |
|
enableLiveAutocompletion: true, |
|
maxLines: Infinity |
|
}); |
|
function SubmitNew(){ |
|
if(!confirm("确定添加文件?")){ |
|
return ; |
|
} |
|
content=editor.getValue(); |
|
$.ajax({ |
|
type: "POST", |
|
url: "{{url_for('admin.setFile')}}", |
|
dataType:'json', |
|
data: {path:'{{path}}',filename:'{{filename}}',content:content}, |
|
beforeSend:function(xhr){ |
|
var index = layer.load(2, { |
|
shade: [0.1,'#fff'] //0.1透明度的白色背景 |
|
}); |
|
}, |
|
success: function(result){ |
|
if(result.status==0){ |
|
alert(result.msg); |
|
window.location.reload(); |
|
} |
|
else{ |
|
alert('修改成功'); |
|
window.location.reload(); |
|
} |
|
}, |
|
complete:function(xhr){ |
|
$('#layui-layer-shade1').remove(); |
|
} |
|
|
|
}); |
|
|
|
} |
|
</script> |
|
{%endblock content%}
|
|
|