From 553a632aa4556740090cc3278f021f41100ba646 Mon Sep 17 00:00:00 2001 From: eli173 Date: Sat, 29 Aug 2015 22:55:32 -0500 Subject: [PATCH] some formatting stuff --- graph.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 27 +++++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 2 deletions(-) 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
+ + + +
+ + + +
+
+
+
+ + -- 2.39.2