Browse Source

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

master
KaiSD 5 years ago
parent
commit
619e39f873
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      ace/index.html

+ 25
- 0
ace/index.html 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;


Loading…
Cancel
Save