From: eli173 Date: Sun, 30 Aug 2015 03:55:32 +0000 (-0500) Subject: some formatting stuff X-Git-Url: https://git.eli173.com/?a=commitdiff_plain;h=553a632aa4556740090cc3278f021f41100ba646;p=graphbyhand some formatting stuff --- diff --git a/graph.js b/graph.js index 00232ef..276d28b 100644 --- a/graph.js +++ b/graph.js @@ -21,6 +21,14 @@ var main = function() { canvas.on('mouse:down',function(o){mousedown(o,canvas)}); canvas.on('object:moving',function(o){movement(o,canvas)}); + document.getElementById("fmt").onclick = function(e) { + ezformatter(canvas); + } + document.getElementById("label").onkeypress = function(e) { + if(e.key="Enter") { + submit() + } + }; } @@ -150,6 +158,53 @@ var getNeighbors = function(vert,canvas) { return neighbors; } +var ezformatter = function(canvas) { + var retstr = ""; + var useedges = document.getElementById("radioedge").checked; + var useids = document.getElementById("idlblid").checked; + canvas.forEachObject(function(o) { + if(useedges && o.type == 'Edge') { + console.log("a"); + if(!useids) { + retstr = retstr.concat("("+o.vertices[0].label+ + ", "+o.vertices[1].label+") "); + } + else { + retstr = retstr.concat("("+o.vertices[0].id+ + ", "+o.vertices[1].id+") "); + } + } + else if(o.type == 'Vertex') { + + + } + }); + document.getElementById("results").value = retstr; + document.getElementById("results").style.display = "block"; +} + +var runformatter = function(canvas) { + retstr = ""; + fstr = document.getElementById("formatstr").value; + var in_escape = false; + for(i=0;iRemove +
+ Formatter
+ + + +
+ + + +
+
+
+
+ +