forked from cory/tildefriends
Support an edit-only mode, which brings up the editor without running the app. Helpful if the app hangs the client. Also on mobile, where both don't fit side-by-side.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4405 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -6,7 +6,6 @@ let gCurrentFile;
|
||||
let gFiles = {};
|
||||
let gApp = {files: {}, emoji: '📦'};
|
||||
let gEditor;
|
||||
let gSplit;
|
||||
let gOriginalInput;
|
||||
|
||||
let kErrorColor = "#dc322f";
|
||||
@ -383,18 +382,18 @@ function editing() {
|
||||
return document.getElementById("editPane").style.display != 'none';
|
||||
}
|
||||
|
||||
function is_edit_only() {
|
||||
return window.location.search == '?editonly=1' || window.innerWidth < 1024;
|
||||
}
|
||||
|
||||
function edit() {
|
||||
if (editing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.localStorage.setItem('editing', '1');
|
||||
if (gSplit) {
|
||||
gSplit.destroy();
|
||||
gSplit = undefined;
|
||||
}
|
||||
gSplit = Split(['#editPane', '#viewPane'], {minSize: 0});
|
||||
document.getElementById("editPane").style.display = 'flex';
|
||||
document.getElementById('viewPane').style.display = is_edit_only() ? 'none' : 'flex';
|
||||
|
||||
ensureLoaded([
|
||||
{tagName: "script", attributes: {src: "/codemirror/codemirror.min.js"}},
|
||||
@ -513,10 +512,7 @@ function load(path) {
|
||||
function closeEditor() {
|
||||
window.localStorage.setItem('editing', '0');
|
||||
document.getElementById("editPane").style.display = 'none';
|
||||
if (gSplit) {
|
||||
gSplit.destroy();
|
||||
gSplit = undefined;
|
||||
}
|
||||
document.getElementById('viewPane').style.display = 'flex';
|
||||
}
|
||||
|
||||
function explodePath() {
|
||||
@ -755,6 +751,7 @@ function _receive_websocket_message(message) {
|
||||
send({event: "hashChange", hash: window.location.hash});
|
||||
}
|
||||
document.getElementsByTagName('tf-navigation')[0].version = message.version;
|
||||
document.getElementById('viewPane').style.display = message.edit_only ? 'none' : 'flex';
|
||||
send({action: 'enableStats', enabled: true});
|
||||
} else if (message && message.action == "ping") {
|
||||
send({action: "pong"});
|
||||
@ -943,6 +940,7 @@ function connectSocket(path) {
|
||||
action: "hello",
|
||||
path: connect_path,
|
||||
url: window.location.href,
|
||||
edit_only: editing() && is_edit_only(),
|
||||
api: Object.entries(k_api).map(([key, value]) => [].concat([key], value.args)),
|
||||
}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user