forked from cory/tildefriends
An attempt at making some live graphs of relevant stats. Needs more thought.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3780 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -8,6 +8,8 @@ var gFiles = {};
|
||||
var gApp = {files: {}};
|
||||
var gEditor;
|
||||
var gSplit;
|
||||
var gStats = {};
|
||||
var gGraph;
|
||||
|
||||
var kErrorColor = "#dc322f";
|
||||
var kStatusColor = "#fff";
|
||||
@ -77,6 +79,7 @@ function edit() {
|
||||
return;
|
||||
}
|
||||
|
||||
closeStats();
|
||||
gSplit = Split(['#editPane', '#viewPane'], {minSize: 0});
|
||||
|
||||
ensureLoaded([
|
||||
@ -152,6 +155,15 @@ function trace() {
|
||||
request.send();
|
||||
}
|
||||
|
||||
function stats() {
|
||||
closeEditor();
|
||||
gSplit = Split(['#statsPane', '#viewPane'], {minSize: 0});
|
||||
document.getElementById("statsPane").style.display = 'flex';
|
||||
gGraph = new SmoothieChart({ grid: { strokeStyle: 'rgb(125, 0, 0)', fillStyle: 'rgb(60, 0, 0)', lineWidth: 1, millisPerLine: 10000, verticalSections: 6 } });
|
||||
gStats = {};
|
||||
gGraph.streamTo(document.getElementById('graph'), 10000);
|
||||
}
|
||||
|
||||
function guessMode(name) {
|
||||
return name.endsWith(".js") ? "javascript" :
|
||||
name.endsWith(".html") ? "htmlmixed" :
|
||||
@ -252,10 +264,20 @@ function load() {
|
||||
request.send();
|
||||
}
|
||||
|
||||
function closeStats() {
|
||||
document.getElementById("statsPane").style.display = 'none';
|
||||
if (gSplit) {
|
||||
gSplit.destroy();
|
||||
gSplit = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function closeEditor() {
|
||||
document.getElementById("editPane").style.display = 'none';
|
||||
gSplit.destroy();
|
||||
gSplit = undefined;
|
||||
if (gSplit) {
|
||||
gSplit.destroy();
|
||||
gSplit = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function explodePath() {
|
||||
@ -422,12 +444,25 @@ function receive(message) {
|
||||
} else if (message && message.action == "ping") {
|
||||
gSocket.send(JSON.stringify({action: "pong"}));
|
||||
} else if (message && message.action == "error") {
|
||||
if (typeof(message.error) == 'string') {
|
||||
setStatusMessage(message.error, '#f00', false);
|
||||
} else {
|
||||
setStatusMessage(message.error.message + '\n' + message.error.stack, '#f00', false);
|
||||
if (message.error) {
|
||||
if (typeof(message.error) == 'string') {
|
||||
setStatusMessage(message.error, '#f00', false);
|
||||
} else {
|
||||
setStatusMessage(message.error.message + '\n' + message.error.stack, '#f00', false);
|
||||
}
|
||||
}
|
||||
console.log('error', message);
|
||||
} else if (message && message.action == "stats") {
|
||||
if (gGraph) {
|
||||
var now = new Date().getTime();
|
||||
for (var key of Object.keys(message.stats)) {
|
||||
if (!gStats[key]) {
|
||||
gStats[key] = new TimeSeries();
|
||||
gGraph.addTimeSeries(gStats[key]);
|
||||
}
|
||||
gStats[key].append(now, message.stats[key]);
|
||||
}
|
||||
}
|
||||
console.log(message.error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,7 +475,6 @@ function keyEvent(event) {
|
||||
charCode: event.charCode,
|
||||
character: String.fromCharCode(event.keyCode || event.which),
|
||||
altKey: event.altKey,
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user