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:
		@@ -127,8 +127,12 @@ function socket(request, response, client) {
 | 
				
			|||||||
				options.url = message.url;
 | 
									options.url = message.url;
 | 
				
			||||||
				let sessionId = makeSessionId();
 | 
									let sessionId = makeSessionId();
 | 
				
			||||||
				if (blobId) {
 | 
									if (blobId) {
 | 
				
			||||||
 | 
										if (message.edit_only) {
 | 
				
			||||||
 | 
											response.send(JSON.stringify({action: 'ready', edit_only: true}), 0x1);
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
						process = await core.getSessionProcessBlob(blobId, sessionId, options);
 | 
											process = await core.getSessionProcessBlob(blobId, sessionId, options);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				if (process) {
 | 
									if (process) {
 | 
				
			||||||
					process.app.readOutput(function(message) {
 | 
										process.app.readOutput(function(message) {
 | 
				
			||||||
						response.send(JSON.stringify(message), 0x1);
 | 
											response.send(JSON.stringify(message), 0x1);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,6 @@ let gCurrentFile;
 | 
				
			|||||||
let gFiles = {};
 | 
					let gFiles = {};
 | 
				
			||||||
let gApp = {files: {}, emoji: '📦'};
 | 
					let gApp = {files: {}, emoji: '📦'};
 | 
				
			||||||
let gEditor;
 | 
					let gEditor;
 | 
				
			||||||
let gSplit;
 | 
					 | 
				
			||||||
let gOriginalInput;
 | 
					let gOriginalInput;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let kErrorColor = "#dc322f";
 | 
					let kErrorColor = "#dc322f";
 | 
				
			||||||
@@ -383,18 +382,18 @@ function editing() {
 | 
				
			|||||||
	return document.getElementById("editPane").style.display != 'none';
 | 
						return document.getElementById("editPane").style.display != 'none';
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function is_edit_only() {
 | 
				
			||||||
 | 
						return window.location.search == '?editonly=1' || window.innerWidth < 1024;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function edit() {
 | 
					function edit() {
 | 
				
			||||||
	if (editing()) {
 | 
						if (editing()) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	window.localStorage.setItem('editing', '1');
 | 
						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("editPane").style.display = 'flex';
 | 
				
			||||||
 | 
						document.getElementById('viewPane').style.display =  is_edit_only() ? 'none' : 'flex';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ensureLoaded([
 | 
						ensureLoaded([
 | 
				
			||||||
		{tagName: "script", attributes: {src: "/codemirror/codemirror.min.js"}},
 | 
							{tagName: "script", attributes: {src: "/codemirror/codemirror.min.js"}},
 | 
				
			||||||
@@ -513,10 +512,7 @@ function load(path) {
 | 
				
			|||||||
function closeEditor() {
 | 
					function closeEditor() {
 | 
				
			||||||
	window.localStorage.setItem('editing', '0');
 | 
						window.localStorage.setItem('editing', '0');
 | 
				
			||||||
	document.getElementById("editPane").style.display = 'none';
 | 
						document.getElementById("editPane").style.display = 'none';
 | 
				
			||||||
	if (gSplit) {
 | 
						document.getElementById('viewPane').style.display = 'flex';
 | 
				
			||||||
		gSplit.destroy();
 | 
					 | 
				
			||||||
		gSplit = undefined;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function explodePath() {
 | 
					function explodePath() {
 | 
				
			||||||
@@ -755,6 +751,7 @@ function _receive_websocket_message(message) {
 | 
				
			|||||||
			send({event: "hashChange", hash: window.location.hash});
 | 
								send({event: "hashChange", hash: window.location.hash});
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		document.getElementsByTagName('tf-navigation')[0].version = message.version;
 | 
							document.getElementsByTagName('tf-navigation')[0].version = message.version;
 | 
				
			||||||
 | 
							document.getElementById('viewPane').style.display = message.edit_only ? 'none' : 'flex';
 | 
				
			||||||
		send({action: 'enableStats', enabled: true});
 | 
							send({action: 'enableStats', enabled: true});
 | 
				
			||||||
	} else if (message && message.action == "ping") {
 | 
						} else if (message && message.action == "ping") {
 | 
				
			||||||
		send({action: "pong"});
 | 
							send({action: "pong"});
 | 
				
			||||||
@@ -943,6 +940,7 @@ function connectSocket(path) {
 | 
				
			|||||||
				action: "hello",
 | 
									action: "hello",
 | 
				
			||||||
				path: connect_path,
 | 
									path: connect_path,
 | 
				
			||||||
				url: window.location.href,
 | 
									url: window.location.href,
 | 
				
			||||||
 | 
									edit_only: editing() && is_edit_only(),
 | 
				
			||||||
				api: Object.entries(k_api).map(([key, value]) => [].concat([key], value.args)),
 | 
									api: Object.entries(k_api).map(([key, value]) => [].concat([key], value.args)),
 | 
				
			||||||
			}));
 | 
								}));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -934,8 +934,6 @@ loadSettings().then(function() {
 | 
				
			|||||||
			return staticDirectoryHandler(request, response, 'deps/codemirror/', match[1]);
 | 
								return staticDirectoryHandler(request, response, 'deps/codemirror/', match[1]);
 | 
				
			||||||
		} else if (match = /^\/speedscope\/([\.\w-/]*)$/.exec(request.uri)) {
 | 
							} else if (match = /^\/speedscope\/([\.\w-/]*)$/.exec(request.uri)) {
 | 
				
			||||||
			return staticDirectoryHandler(request, response, 'deps/speedscope/', match[1]);
 | 
								return staticDirectoryHandler(request, response, 'deps/speedscope/', match[1]);
 | 
				
			||||||
		} else if (match = /^\/split\/([\.\w-/]*)$/.exec(request.uri)) {
 | 
					 | 
				
			||||||
			return staticDirectoryHandler(request, response, 'deps/split/', match[1]);
 | 
					 | 
				
			||||||
		} else if (match = /^\/static(\/.*)/.exec(request.uri)) {
 | 
							} else if (match = /^\/static(\/.*)/.exec(request.uri)) {
 | 
				
			||||||
			return staticFileHandler(request, response, null, match[1]);
 | 
								return staticFileHandler(request, response, null, match[1]);
 | 
				
			||||||
		} else if (request.uri == "/robots.txt") {
 | 
							} else if (request.uri == "/robots.txt") {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@
 | 
				
			|||||||
	<body style="display: flex; flex-flow: column">
 | 
						<body style="display: flex; flex-flow: column">
 | 
				
			||||||
		<tf-navigation></tf-navigation>
 | 
							<tf-navigation></tf-navigation>
 | 
				
			||||||
		<div id="content" class="hbox" style="flex: 1 1; width: 100%">
 | 
							<div id="content" class="hbox" style="flex: 1 1; width: 100%">
 | 
				
			||||||
			<div id="editPane" class="vbox" style="display: none">
 | 
								<div id="editPane" class="vbox" style="flex: 1 1; display: none">
 | 
				
			||||||
				<div class="navigation hbox">
 | 
									<div class="navigation hbox">
 | 
				
			||||||
					<input type="button" id="closeEditor" name="closeEditor" value="Close">
 | 
										<input type="button" id="closeEditor" name="closeEditor" value="Close">
 | 
				
			||||||
					<input type="button" id="save" name="save" value="Save">
 | 
										<input type="button" id="save" name="save" value="Save">
 | 
				
			||||||
@@ -27,7 +27,7 @@
 | 
				
			|||||||
					</div>
 | 
										</div>
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
			<div id="viewPane" class="vbox" style="flex: 1 0; overflow: auto">
 | 
								<div id="viewPane" class="vbox" style="flex: 1 1; overflow: auto">
 | 
				
			||||||
				<iframe id="document" sandbox="allow-forms allow-scripts allow-top-navigation allow-modals allow-downloads" style="width: 100%; height: 100%; border: 0"></iframe>
 | 
									<iframe id="document" sandbox="allow-forms allow-scripts allow-top-navigation allow-modals allow-downloads" style="width: 100%; height: 100%; border: 0"></iframe>
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
		</div>
 | 
							</div>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								deps/split/split.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								deps/split/split.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										1
									
								
								deps/split/split.min.js.map
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								deps/split/split.min.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user