Make some attempt to restore some editor/stats/... state using localStorage.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3855 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
cb315c717b
commit
b488db9137
@ -129,11 +129,13 @@ function socket(request, response, client) {
|
||||
setTimeout(ping, process.timeout);
|
||||
}
|
||||
} else if (message.action == 'enableStats') {
|
||||
if (process) {
|
||||
process.stats = message.enabled;
|
||||
if (!gStatsTimer) {
|
||||
sendStats();
|
||||
gStatsTimer = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (process && process.eventHandlers['message']) {
|
||||
await invoke(process.eventHandlers['message'], [message]);
|
||||
|
@ -82,6 +82,7 @@ function edit() {
|
||||
return;
|
||||
}
|
||||
|
||||
window.localStorage.setItem('editing', '1');
|
||||
if (gSplit) {
|
||||
gSplit.destroy();
|
||||
gSplit = undefined;
|
||||
@ -114,10 +115,12 @@ function edit() {
|
||||
}
|
||||
|
||||
function hideFiles() {
|
||||
window.localStorage.setItem('files', '0');
|
||||
document.getElementById('filesPane').classList.add('collapsed');
|
||||
}
|
||||
|
||||
function showFiles() {
|
||||
window.localStorage.setItem('files', '1');
|
||||
document.getElementById('filesPane').classList.remove('collapsed');
|
||||
}
|
||||
|
||||
@ -163,11 +166,13 @@ function trace() {
|
||||
}
|
||||
|
||||
function stats() {
|
||||
window.localStorage.setItem('stats', '1');
|
||||
document.getElementById("statsPane").style.display = 'flex';
|
||||
send({action: 'enableStats', enabled: true});
|
||||
}
|
||||
|
||||
function closeStats() {
|
||||
window.localStorage.setItem('stats', '0');
|
||||
document.getElementById("statsPane").style.display = 'none';
|
||||
send({action: 'enableStats', enabled: false});
|
||||
}
|
||||
@ -254,6 +259,7 @@ function load(path) {
|
||||
}
|
||||
|
||||
function closeEditor() {
|
||||
window.localStorage.setItem('editing', '0');
|
||||
document.getElementById("editPane").style.display = 'none';
|
||||
if (gSplit) {
|
||||
gSplit.destroy();
|
||||
@ -391,6 +397,10 @@ function receive(message) {
|
||||
if (window.location.hash) {
|
||||
send({event: "hashChange", hash: window.location.hash});
|
||||
}
|
||||
if (window.localStorage.getItem('stats') == '1') {
|
||||
/* Stats were opened before we connected. */
|
||||
send({action: 'enableStats', enabled: true});
|
||||
}
|
||||
} else if (message && message.action == "setDocument") {
|
||||
var iframe = document.getElementById("document");
|
||||
iframe.srcdoc = message.content;
|
||||
@ -427,10 +437,11 @@ function receive(message) {
|
||||
timeseries: new TimeSeries(),
|
||||
};
|
||||
gGraphs[key] = graph;
|
||||
graph.canvas.width = '320';
|
||||
graph.canvas.width = '240';
|
||||
graph.canvas.width = 240;
|
||||
graph.canvas.height = 64;
|
||||
var div = document.createElement('div');
|
||||
div.innerText = key;
|
||||
div.style.flex = '0';
|
||||
document.getElementById('graphs').appendChild(div);
|
||||
document.getElementById('graphs').appendChild(graph.canvas);
|
||||
graph.chart.streamTo(graph.canvas, 1000);
|
||||
@ -783,4 +794,20 @@ window.addEventListener("load", function() {
|
||||
}
|
||||
enableDragDrop();
|
||||
connectSocket(window.location.pathname);
|
||||
|
||||
if (window.localStorage.getItem('editing') == '1') {
|
||||
edit();
|
||||
} else {
|
||||
closeEditor();
|
||||
}
|
||||
if (window.localStorage.getItem('files') == '1') {
|
||||
showFiles();
|
||||
} else {
|
||||
hideFiles();
|
||||
}
|
||||
if (window.localStorage.getItem('stats') == '1') {
|
||||
stats();
|
||||
} else {
|
||||
closeStats();
|
||||
}
|
||||
});
|
||||
|
@ -19,11 +19,11 @@
|
||||
<span id="login"></span>
|
||||
</div>
|
||||
<div id="content" class="hbox" style="flex: 1 1; width: 100%">
|
||||
<div id="statsPane" class="vbox" style="display: none; flex 1 0 320px">
|
||||
<div id="statsPane" class="vbox" style="display: none; flex 1 1">
|
||||
<div class="hbox">
|
||||
<input type="button" id="closeStats" name="closeStats" value="Close" onclick="closeStats()">
|
||||
</div>
|
||||
<div id="graphs"></div>
|
||||
<div id="graphs" class="vbox" style="height: 100%"></div>
|
||||
</div>
|
||||
<div id="editPane" class="vbox" style="display: none">
|
||||
<div class="navigation">
|
||||
|
Loading…
Reference in New Issue
Block a user