Изменить 'ace/index.html'

This commit is contained in:
2019-09-05 09:30:03 +02:00
parent bf6b585a6b
commit 619e39f873

View File

@@ -57,12 +57,14 @@
</head>
<body>
<div class="toolbar">
<button id="btnLoad" onclick="load()" class="btn"></button>
<button id="btnSave" onClick="save()" class="btn btn_g"></button>
<button id="btnUndo" onClick="editor.undo()" class="btn"></button>
<button id="btnRedo" onClick="editor.redo()" class="btn btn_g"></button>
<button id="btnFs" onclick="toggleFullscreen()" class="btn"></button>
</div>
<div class="inner" id="editor"></div>
<div class="inner" id="editor"></div>
<script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
@@ -152,6 +154,29 @@
document.body.removeChild(element);
}
function load() {
var input = document.createElement('input');
input.type = 'file';
input.onchange = e => {
// getting a hold of the file reference
var file = e.target.files[0];
// setting up the reader
var reader = new FileReader();
reader.readAsText(file,'UTF-8');
// here we tell the reader what to do when it's done reading...
reader.onload = readerEvent => {
var content = readerEvent.target.result; // this is the content!
editor.setValue(content);
}
}
input.click();
}
window.editor = editor;