mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
added beautifier button in text editor
This commit is contained in:
parent
ec862ec747
commit
c35395e302
@ -1,4 +1,5 @@
|
||||
var ace = require('brace');
|
||||
var beautify = require('js-beautify').js_beautify;
|
||||
require('brace/mode/javascript');
|
||||
require('../netscript');
|
||||
require('brace/theme/chaos');
|
||||
@ -57,6 +58,15 @@ function scriptEditorInit() {
|
||||
console.log("Error finding 'script-editor-buttons-wrapper'");
|
||||
return;
|
||||
}
|
||||
var beautifyButton = createElement("a", {
|
||||
class:"a-link-button", display:"inline-block",
|
||||
innerText:"beautify",
|
||||
clickListener:()=>{
|
||||
beautifyScript();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
var closeButton = createElement("a", {
|
||||
class:"a-link-button", display:"inline-block",
|
||||
innerText:"Save & Close (Ctrl/Cmd + b)",
|
||||
@ -90,6 +100,7 @@ function scriptEditorInit() {
|
||||
target:"_blank"
|
||||
});
|
||||
|
||||
wrapper.appendChild(beautifyButton);
|
||||
wrapper.appendChild(closeButton);
|
||||
wrapper.appendChild(scriptEditorRamText);
|
||||
wrapper.appendChild(scriptEditorRamCheck);
|
||||
@ -243,6 +254,13 @@ $(document).keydown(function(e) {
|
||||
}
|
||||
});
|
||||
|
||||
function beautifyScript() {
|
||||
var editor = ace.edit('javascript-editor');
|
||||
var code = editor.getValue();
|
||||
code = beautify(code, { indent_size: 4 })
|
||||
editor.setValue(code);
|
||||
}
|
||||
|
||||
function saveAndCloseScriptEditor() {
|
||||
var filename = document.getElementById("script-editor-filename").value;
|
||||
var editor = ace.edit('javascript-editor');
|
||||
|
Loading…
Reference in New Issue
Block a user