{ "name": "Ace Editor", "icon": "\u{1D4D0}", "desc": "A GopalOS implementation of the Ace Editor (https://ace.c9.io/).", "id": "ace-editor", "defaultRelease": "alpha", "releases": { "alpha": { "version": "v0.5.0-alpha", "app-files": { "ace-editor": { type: "pgm", content() { if (document.getElementById("app_ace-editor_window")) { document.getElementById("app_ace-editor_window").style.display = "block"; } else { document.getElementById("windows").insertAdjacentHTML("beforeend", getRef("/apps/ace-editor/window")); getRef("/apps/ace-editor/load")(); } focusWin(document.getElementById("app_ace-editor_window")); regTbarIcon("/apps/ace-editor/ace-editor", "app_ace-editor_window", "\u{1D4D0}", true); refreshWindows(); } }, "load": { type: "js", content() { if (getRef("/apps/ace-editor/first-run") == true) {} else { writeRef("/apps/ace-editor/first-run", true); getRef("/apps/ace-editor/ace/ace")(); getRef("/apps/ace-editor/ace/theme-clouds_midnight")(); } getRef("/apps/ace-editor")["current-ace-editor"] = ace.edit("app_ace-editor_editor"); } }, "current-ace-editor": { type: "var", content: null }, "first-run": { type: "var", content: false }, "open": { type: "js", content(path) { if (["txt", "cfg", "css", "html"].includes(getRef(path, true).type)) { document.getElementById("app_ace-editor_editor").value = getRef(path); } else if (getRef(path, true).type == "js") { document.getElementById("app_ace-editor_editor").value = String(getRef(path)); } else if (getRef(path, true).type == "json") { document.getElementById("app_ace-editor_editor").value = JSON.stringify(getRef(path)); } else {} } }, "save": { type: "js", content(path) { if (["txt", "cfg", "css", "html"].includes(getRef(path, true).type)) { writeRef(path, document.getElementById("app_ace-editor_editor").value); } else if (getRef(path, true).type == "js") { writeRef(path, eval(document.getElementById("app_ace-editor_editor").value)); } if (getRef(path, true).type == "json") { let isValidJSON = true; try { JSON.parse(document.getElementById("app_ace-editor_editor").value); } catch(err) { document.getElementById("app_ace-editor_statbar").innerHTML = `${err.name}: ${err.message}`; isValidJSON = false; } finally { if (!isValidJSON) {} else { document.getElementById("app_ace-editor_statbar").innerHTML = "Saving..."; writeRef(path, JSON.parse(document.getElementById("app_ace-editor_editor").value)); document.getElementById("app_ace-editor_statbar").innerHTML = "Ready"; } } } else {} } }, "window": { type: "html", content: `