From: eli173 Date: Sat, 29 Aug 2015 18:15:25 +0000 (-0500) Subject: some select stuff X-Git-Url: https://git.eli173.com/?a=commitdiff_plain;h=03147c46c25523754be53f93736f66605f875de5;p=graphbyhand some select stuff --- diff --git a/graph.js b/graph.js index 7d99dac..00232ef 100644 --- a/graph.js +++ b/graph.js @@ -16,7 +16,7 @@ curr_ed = null; evt = null; -main = function() { +var main = function() { var canvas = new fabric.Canvas("surface",{backgroundColor:'white'}); canvas.on('mouse:down',function(o){mousedown(o,canvas)}); @@ -24,6 +24,13 @@ main = function() { } +var setMode = function(ch) { + mode = ch; + if(mode!='s') { + document.getElementById("editor").style.display = "none"; + } +} + var movement = function(options,canvas) { vert = options.target; edges = []; @@ -75,6 +82,14 @@ var mousedown = function(options,canvas) { if(options.target && options.target.type == 'Vertex') { curr_ed = options.target; document.getElementById("label").value = curr_ed.label; + document.getElementById("elementid").innerHTML = curr_ed.id; + neighbors = getNeighbors(curr_ed,canvas); + nbrstrs = [] + neighbors.map(function(e) { + nbrstrs.push("Label: "+e.label+", id:"+e.id+"
"); + }); + nbstring = nbrstrs.join('\n'); + document.getElementById("neighbors").innerHTML = nbstring; document.getElementById("editor").style.display = "block"; } @@ -147,6 +162,7 @@ var Vertex = fabric.util.createClass(fabric.Circle, { this.set({'edges':options.edges||[]}); this.set({'hasControls':false}); this.set({'hasBorders':false}); + this.id = v_counter++; }, toObject: function() { return fabric.util.object.extend(this.callSuper('toObject'), { diff --git a/index.html b/index.html index 88dcb18..4414c46 100644 --- a/index.html +++ b/index.html @@ -13,14 +13,15 @@
- - - - + + + +