forked from cory/tildefriends
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
10
core/app.js
10
core/app.js
@ -129,10 +129,12 @@ function socket(request, response, client) {
|
|||||||
setTimeout(ping, process.timeout);
|
setTimeout(ping, process.timeout);
|
||||||
}
|
}
|
||||||
} else if (message.action == 'enableStats') {
|
} else if (message.action == 'enableStats') {
|
||||||
process.stats = message.enabled;
|
if (process) {
|
||||||
if (!gStatsTimer) {
|
process.stats = message.enabled;
|
||||||
sendStats();
|
if (!gStatsTimer) {
|
||||||
gStatsTimer = true;
|
sendStats();
|
||||||
|
gStatsTimer = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (process && process.eventHandlers['message']) {
|
if (process && process.eventHandlers['message']) {
|
||||||
|
@ -82,6 +82,7 @@ function edit() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.localStorage.setItem('editing', '1');
|
||||||
if (gSplit) {
|
if (gSplit) {
|
||||||
gSplit.destroy();
|
gSplit.destroy();
|
||||||
gSplit = undefined;
|
gSplit = undefined;
|
||||||
@ -114,10 +115,12 @@ function edit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hideFiles() {
|
function hideFiles() {
|
||||||
|
window.localStorage.setItem('files', '0');
|
||||||
document.getElementById('filesPane').classList.add('collapsed');
|
document.getElementById('filesPane').classList.add('collapsed');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showFiles() {
|
function showFiles() {
|
||||||
|
window.localStorage.setItem('files', '1');
|
||||||
document.getElementById('filesPane').classList.remove('collapsed');
|
document.getElementById('filesPane').classList.remove('collapsed');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,11 +166,13 @@ function trace() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stats() {
|
function stats() {
|
||||||
|
window.localStorage.setItem('stats', '1');
|
||||||
document.getElementById("statsPane").style.display = 'flex';
|
document.getElementById("statsPane").style.display = 'flex';
|
||||||
send({action: 'enableStats', enabled: true});
|
send({action: 'enableStats', enabled: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeStats() {
|
function closeStats() {
|
||||||
|
window.localStorage.setItem('stats', '0');
|
||||||
document.getElementById("statsPane").style.display = 'none';
|
document.getElementById("statsPane").style.display = 'none';
|
||||||
send({action: 'enableStats', enabled: false});
|
send({action: 'enableStats', enabled: false});
|
||||||
}
|
}
|
||||||
@ -254,6 +259,7 @@ function load(path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeEditor() {
|
function closeEditor() {
|
||||||
|
window.localStorage.setItem('editing', '0');
|
||||||
document.getElementById("editPane").style.display = 'none';
|
document.getElementById("editPane").style.display = 'none';
|
||||||
if (gSplit) {
|
if (gSplit) {
|
||||||
gSplit.destroy();
|
gSplit.destroy();
|
||||||
@ -391,6 +397,10 @@ function receive(message) {
|
|||||||
if (window.location.hash) {
|
if (window.location.hash) {
|
||||||
send({event: "hashChange", hash: 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") {
|
} else if (message && message.action == "setDocument") {
|
||||||
var iframe = document.getElementById("document");
|
var iframe = document.getElementById("document");
|
||||||
iframe.srcdoc = message.content;
|
iframe.srcdoc = message.content;
|
||||||
@ -427,10 +437,11 @@ function receive(message) {
|
|||||||
timeseries: new TimeSeries(),
|
timeseries: new TimeSeries(),
|
||||||
};
|
};
|
||||||
gGraphs[key] = graph;
|
gGraphs[key] = graph;
|
||||||
graph.canvas.width = '320';
|
graph.canvas.width = 240;
|
||||||
graph.canvas.width = '240';
|
graph.canvas.height = 64;
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.innerText = key;
|
div.innerText = key;
|
||||||
|
div.style.flex = '0';
|
||||||
document.getElementById('graphs').appendChild(div);
|
document.getElementById('graphs').appendChild(div);
|
||||||
document.getElementById('graphs').appendChild(graph.canvas);
|
document.getElementById('graphs').appendChild(graph.canvas);
|
||||||
graph.chart.streamTo(graph.canvas, 1000);
|
graph.chart.streamTo(graph.canvas, 1000);
|
||||||
@ -783,4 +794,20 @@ window.addEventListener("load", function() {
|
|||||||
}
|
}
|
||||||
enableDragDrop();
|
enableDragDrop();
|
||||||
connectSocket(window.location.pathname);
|
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>
|
<span id="login"></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="content" class="hbox" style="flex: 1 1; width: 100%">
|
<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">
|
<div class="hbox">
|
||||||
<input type="button" id="closeStats" name="closeStats" value="Close" onclick="closeStats()">
|
<input type="button" id="closeStats" name="closeStats" value="Close" onclick="closeStats()">
|
||||||
</div>
|
</div>
|
||||||
<div id="graphs"></div>
|
<div id="graphs" class="vbox" style="height: 100%"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="editPane" class="vbox" style="display: none">
|
<div id="editPane" class="vbox" style="display: none">
|
||||||
<div class="navigation">
|
<div class="navigation">
|
||||||
|
Loading…
Reference in New Issue
Block a user