src/js/editSDC.js
//writing as a function so that I can use it when I create new boxes
writing as a function so that I can use it when I create new boxes
writing as a function so that I can use it when I create new boxes
function addDeleter(base){
		var r = Math.max(params.SDCBoxWidth/20., 8.);
		var deleter = base.append('g')
			.attr('class','SDCdeleter')
			.on('click', function(){
				var orgText = params.cleanString(d3.select(this.parentNode).select('text').attr('orgText'));
				d3.select(this.parentNode).remove();
				var index = -1;
				params.selectionWords.forEach(function(d, i){
					if (params.cleanString(d) == orgText) index = i;
				})
				if (index > -1) params.selectionWords.splice(index, 1);
				var answersGroup = params.answers.filter(function(d){return (d.task == 'para' && params.cleanString(d.groupname) == params.cleanString(params.groupname));})[0];
				delete answersGroup[orgText];
				formatSDC();
			})
		deleter.append('circle')
				.attr('class','SDCdeleter')
				.attr('cx', '0px')
				.attr('cy', '0px')
				.attr('r', r + 'px')
				.style('fill', 'lightgray')
				.style('stroke', 'gray')
		deleter.append('text')
				.attr('class','SDCdeleter')
				.attr('x', '0px')
				.attr('y', '0px')
				.attr('text-anchor','middle')
				.attr('alignment-baseline','central')
				.style('font-size', (2.*r) + 'px')
				.style('line-height', (2.*r) + 'px')
				.style('fill','gray')
				.style('cursor','pointer')
				.text('X')
	}
function addDeleter ( base ) { var r = Math . max ( params . SDCBoxWidth / 20. , 8. ) ; var deleter = base . append ( 'g' ) . attr ( 'class' , 'SDCdeleter' ) . on ( 'click' , function ( ) { var orgText = params . cleanString ( d3 . select ( this . parentNode ) . select ( 'text' ) . attr ( 'orgText' ) ) ; d3 . select ( this . parentNode ) . remove ( ) ; var index = - 1 ; params . selectionWords . forEach ( function ( d , i ) { if ( params . cleanString ( d ) == orgText ) index = i ; } ) if ( index > - 1 ) params . selectionWords . splice ( index , 1 ) ; var answersGroup = params . answers . filter ( function ( d ) { return ( d . task == 'para' && params . cleanString ( d . groupname ) == params . cleanString ( params . groupname ) ) ; } ) [ 0 ] ; delete answersGroup [ orgText ] ; formatSDC ( ) ; } ) deleter . append ( 'circle' ) . attr ( 'class' , 'SDCdeleter' ) . attr ( 'cx' , '0px' ) . attr ( 'cy' , '0px' ) . attr ( 'r' , r + 'px' ) . style ( 'fill' , 'lightgray' ) . style ( 'stroke' , 'gray' ) deleter . append ( 'text' ) . attr ( 'class' , 'SDCdeleter' ) . attr ( 'x' , '0px' ) . attr ( 'y' , '0px' ) . attr ( 'text-anchor' , 'middle' ) . attr ( 'alignment-baseline' , 'central' ) . style ( 'font-size' , ( 2. * r ) + 'px' ) . style ( 'line-height' , ( 2. * r ) + 'px' ) . style ( 'fill' , 'gray' ) . style ( 'cursor' , 'pointer' ) . text ( 'X' ) }
writing as a function so that I can use it when I create new boxes
writing as a function so that I can use it when I create new boxes
//remove the node //remove it from the selection words //remove it from the answers //console.log('removing', orgText, index, params.selectionWords, params.answers) //reformat