Created
June 22, 2012 07:07
-
-
Save roundrobin/2970914 to your computer and use it in GitHub Desktop.
just another inlet to tributary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pathWay = []; | |
//DONT REMOVE LINE BELOW | |
g.append('text') | |
.attr('y',293) | |
.attr('id','pathWay') | |
.text('var pathWay = [];') | |
var addText = function(){ | |
var text = d3.select('#pathWay') | |
var textValue = text.text(); | |
var search = /var pathWay = \[(.*)\]/; | |
var result = search.exec(textValue); | |
if(textValue == 'var pathWay = [];') | |
add ='[1,2]'; | |
else | |
add = ',[1,2]'; | |
var modify = result[1]+add; | |
var finalString = 'var pathWay = ['+(modify)+'];'; | |
//console.log('String',finalString); | |
var test = text.text(finalString); | |
test = test.text(); | |
//tribView.code_editor.setLine(0,test); | |
console.log('Test', ''); | |
} | |
var button1 = createButton('Add path to Editor', addText) | |
.attr('transform','translate('+[32,83]+')') | |
var removeText = function(){ | |
var text = tribView.code_editor.setLine(0,'var pathWay = []; ') | |
} | |
var button2 = createButton('Remove path from editor', removeText) | |
.attr('transform','translate('+[30,156]+')') | |
function createButton(name,callback){ | |
var buttonGroup = g.append('g') | |
.on('click',callback) | |
var rect = buttonGroup.append('rect') | |
.attr('width',122) | |
.attr('height',45) | |
.attr('fill',"#922F2F") | |
var text = buttonGroup.append('text') | |
.attr('id','pathWay') | |
.attr('dominant-baseline','hanging') | |
.attr('font-size','30') | |
.text(name) | |
.attr('transform','translate('+[10,9]+')') | |
var textLength = text.node().getBBox().width; | |
rect.attr('width',textLength+20) | |
return buttonGroup; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment