var socket = io.connect() var docker = new Docker(socket, error, sigstack) var parameters = docker.graphics.parameters console.log(localStorage) function error(msg, data) { $('#status').removeClass().addClass('error') $('#error').html('

Error

'+(new Date()).toLocaleString()+'

'+msg+'

'+data+'
').show() } function sigstack() { $('#error').hide() $('#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) $('#clock').text((new Date()).toLocaleString()) $('#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') } 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() $('#orientation').on('click', () => { setParameters() sigstack() }) if (localStorage.position) $('body').removeClass().addClass(localStorage.position) $('header').attr('draggable', 'true') .on('dragstart', (event) => { event.originalEvent.dataTransfer.setData("text", ""); }) $('*').on('dragover', (event) => { event.preventDefault() var e = event.originalEvent var obj = $('body') var w = window.innerWidth var h = window.innerHeight if (e.clientY < h*.1) { obj.removeClass().addClass('top') if (localStorage) localStorage.position = 'top'; } else if (e.clientY > h*.9) { obj.removeClass().addClass('bottom') if (localStorage) localStorage.position = 'bottom'; } else if (e.clientX < w*.1) { obj.removeClass().addClass('left') if (localStorage) localStorage.position = 'left'; } else if (e.clientX > w*.9) { obj.removeClass().addClass('right') if (localStorage) localStorage.position = 'right'; } }).on('drop', (event) => { event.preventDefault() }) } $(init)