return false;
}
+function prompt_download() {
+ let editor = ace.edit('code-editor');
+ let code = editor.getValue();
+
+ let blob = new Blob([ code ], {
+ type: 'text/plain'
+ });
+
+ let download_link = document.createElement('a');
+ download_link.download = `onyx-${Date.now()}.onyx`;
+ download_link.href = window.URL.createObjectURL(blob);
+ download_link.onclick = function(e) {
+ // revokeObjectURL needs a delay to work properly
+ setTimeout(() => {
+ window.URL.revokeObjectURL(this.href);
+ }, 1500);
+ };
+
+ download_link.click();
+ download_link.remove();
+}
+
window.onload = () => {
let editor = ace.edit('code-editor');
<option value="tomorrow-night-bright">Tomorrow Night Bright</option>
</select>
+ <button onclick="prompt_download()">Save</button>
<button onclick="submit_code()">Run</button>
<button onclick="kill_code()">Stop</button>