|
|
|
@ -1,11 +1,10 @@ |
|
|
|
|
var socket = io.connect() |
|
|
|
|
var docker = new Docker(socket, error, sigstack) |
|
|
|
|
var parameters = docker.graphics.parameters |
|
|
|
|
console.log(localStorage) |
|
|
|
|
|
|
|
|
|
function error(msg, data) { |
|
|
|
|
function error(e) { |
|
|
|
|
$('#status').removeClass().addClass('error') |
|
|
|
|
$('#error').html('<h1>Error</h1><p>'+(new Date()).toLocaleString()+'</p><p>'+msg+'</p><pre>'+data+'</pre>').show() |
|
|
|
|
$('#error').html('<h1>Error</h1><p>'+(new Date()).toLocaleString()+'</p><p>'+e.msg+'</p><pre>'+e.data+'</pre>').show() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function sigstack() { |
|
|
|
@ -13,31 +12,33 @@ function sigstack() { |
|
|
|
|
$('#clock').text((new Date()).toLocaleString()) |
|
|
|
|
$('#status').removeClass().addClass('wait') |
|
|
|
|
var dot = docker.graphics.stack(parameters) |
|
|
|
|
var svg = docker.graphics.viz(dot, error) |
|
|
|
|
$('#stacks').html(svg) |
|
|
|
|
$('a#dot').attr('href', 'data:text/vnd.graphviz;base64,'+btoa(dot)) |
|
|
|
|
.attr('target', '_blank') |
|
|
|
|
.attr('download', window.location.hostname+'.dot') |
|
|
|
|
try { |
|
|
|
|
$('#clock').text((new Date()).toLocaleString()) |
|
|
|
|
var svg = docker.graphics.viz(dot) |
|
|
|
|
$('#stacks').html(svg) |
|
|
|
|
$('#status').removeClass().addClass('success') |
|
|
|
|
$('a#svg').attr('href', 'data:image/svg;base64,'+btoa(svg)) |
|
|
|
|
.attr('target', '_blank') |
|
|
|
|
.attr('download', window.location.hostname+'.svg') |
|
|
|
|
$('a#dot').attr('href', 'data:text/vnd.graphviz;base64,'+btoa(dot)) |
|
|
|
|
.attr('target', '_blank') |
|
|
|
|
.attr('download', window.location.hostname+'.dot') |
|
|
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
error(e) |
|
|
|
|
} |
|
|
|
|
$('#clock').text((new Date()).toLocaleString()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function setParameters() { |
|
|
|
|
localStorage.rankdir = (++localStorage.rankdir)%setParameters.rankdirs.length |
|
|
|
|
parameters.rankdir = setParameters.rankdirs[localStorage.rankdir] |
|
|
|
|
$('#orientation').removeClass().addClass(parameters.rankdir.toLowerCase()) |
|
|
|
|
console.log(localStorage.rankdir) |
|
|
|
|
} |
|
|
|
|
setParameters.rankdirs = ['LR', 'TB', 'RL', 'BT'] |
|
|
|
|
if (!localStorage.rankdir) |
|
|
|
|
localStorage.rankdir = -1 |
|
|
|
|
else |
|
|
|
|
--localStorage.rankdir |
|
|
|
|
console.log(localStorage.rankdir) |
|
|
|
|
|
|
|
|
|
function init() { |
|
|
|
|
setParameters() |
|
|
|
|