<commit_before>sigma.publicPrototype.bindEvents = function () {
  dom = document.querySelector('#js-graph canvas:last-child');
  edgeCanvas = document.querySelector('#sigma_hover_1');
  ctx = edgeCanvas.getContext('2d');
  var letsdraw = false;
	
  var sigInst = this;
  var $element = $(this);
  mouseDown = false;
  selectedNodeName = null;
  selectedNode2Name = null;
  var popUp;
  
  /*** ACTIONS ON GRAPH EVENTS ***/
  function submitNewInteraction() {
  	popUp && popUp.remove();
  }
  mouseDownOvernodes = function(e) {
  	// When clic on node without release : start line drawing
  	popUp && popUp.remove();
  	mouseDown = true;
  	
  	sigInst.iterNodes(function (n) {
	    if (n.id == selectedNodeName) {
	      selectedNode = n;
	    }
	  });
	
	letsdraw = true;
    ctx.strokeStyle = 'white';
    ctx.lineWidth = 1;
    ctx.lineCap = 'round';
    debX = selectedNode.displayX;//e.pageX;
    debY = selectedNode.displayY;//e.pageY;
  };
  mouseUpOvernodes = function(e) {
  	// When release clic on node :
  	//		- if the node is the same as mousedown, we display it info
  	//		- if the node is a second one, we create a link between the two nodes
  	
  	if (selectedNode2Name == null) {
  		sigInst.hideNodeinfo();
    	sigInst.showNodeinfo(selectedNodeName);
  	}
  	else {
  		console.log("Link creation between "+selectedNodeName+ " and "+selectedNode2Name);
  		
  		sigInst.iterNodes(function (n) {
		    if (n.id == selectedNodeName) {
		      selectedNode = n;
		    }
		    else if (n.id == selectedNode2Name) {
		      selectedNode2 = n;
		    }
		  });
  		console.log(selectedNode);
  		console.log(selectedNode2);
  		
  		popUp = $(
          '<div class="node-info-popup"></div>'
        ).append(
          "Vous souhaitez créer un lien entre "+selectedNode.label+ " et "+selectedNode2.label+" ?"+
          '<br /><button id="submitNewInt">Confirmer</button>'
        ).attr(
          'id',
          'link-creation'+sigInst.getID()
        ).css({
          'display': 'inline-block',
          'border-radius': 3,
          'padding': 5,
          'background': '#fff',
          'color': '#000',
          'box-shadow': '0 0 4px #666',
          'position': 'absolute',
          'left': selectedNode.displayX,
          'top': selectedNode.displayY+15
        });
        
        $(document.getElementById('js-graph')).append(popUp);
  		
  	}
    
    // At the end of mouse release, we return at the beginning state 
    mouseDown = false;
  	selectedNodeName = null;
  	selectedNode2Name = null;
  	letsdraw = false;
  	ctx.clearRect(0, 0, dom.offsetWidth, dom.offsetHeight);
  };
  mouseDownOutnodes = function(e) {
  	popUp && popUp.remove();
  };
  mouseUpOutnodes = function(e) {
    // At the end of mouse release, we return at the beginning state
  	mouseDown = false;
  	selectedNodeName = null;
  	selectedNode2Name = null;
  	letsdraw = false;
  	ctx.clearRect(0, 0, dom.offsetWidth, dom.offsetHeight);<commit_msg>prevent link creation between a node and itself<commit_after>sigma.publicPrototype.bindEvents = function () {
  dom = document.querySelector('#js-graph canvas:last-child');
  edgeCanvas = document.querySelector('#sigma_hover_1');
  ctx = edgeCanvas.getContext('2d');
  var letsdraw = false;
	
  var sigInst = this;
  var $element = $(this);
  mouseDown = false;
  selectedNodeName = null;
  selectedNode2Name = null;
  var popUp;
  
  /*** ACTIONS ON GRAPH EVENTS ***/
  function submitNewInteraction() {
  	
  }
  function cancelNewInteraction() {
  	popUp && popUp.remove();
  }
  mouseDownOvernodes = function(e) {
  	// When clic on node without release : start line drawing
  	popUp && popUp.remove();
  	mouseDown = true;
  	
  	sigInst.iterNodes(function (n) {
	    if (n.id == selectedNodeName) {
	      selectedNode = n;
	    }
	  });
	
	letsdraw = true;
    ctx.strokeStyle = 'white';
    ctx.lineWidth = 1;
    ctx.lineCap = 'round';
    debX = selectedNode.displayX;//e.pageX;
    debY = selectedNode.displayY;//e.pageY;
  };
  mouseUpOvernodes = function(e) {
  	// When release clic on node :
  	//		- if the node is the same as mousedown, we display it info
  	//		- if the node is a second one, we create a link between the two nodes
  	
  	if (selectedNode2Name == null || selectedNode2Name == selectedNodeName) {
  		sigInst.hideNodeinfo();
    	sigInst.showNodeinfo(selectedNodeName);
  	}
  	else {
  		console.log("Link creation between "+selectedNodeName+ " and "+selectedNode2Name);
  		
  		sigInst.iterNodes(function (n) {
		    if (n.id == selectedNodeName) {
		      selectedNode = n;
		    }
		    else if (n.id == selectedNode2Name) {
		      selectedNode2 = n;
		    }
		  });
  		console.log(selectedNode);
  		console.log(selectedNode2);
  		
  		popUp = $(
          '<div class="node-info-popup"></div>'
        ).append(
      		"Vous souhaitez créer un lien entre "+selectedNode.label+ " et "+selectedNode2.label+" ?"+
      		'<br /><button id="submitNewInt">Confirmer</button>'+'<button id="cancelNewInt">Annuler</button>'
    	).attr(
          'id',
          'link-creation'+sigInst.getID()
        ).css({
          'display': 'inline-block',
          'border-radius': 3,
          'padding': 5,
          'background': '#fff',
          'color': '#000',
          'box-shadow': '0 0 4px #666',
          'position': 'absolute',
          'left': selectedNode.displayX,
          'top': selectedNode.displayY+15
        });
        
        $(document.getElementById('js-graph')).append(popUp);
        
	    $('#submitNewInt').click(submitNewInteraction);
	    $('#cancelNewInt').click(cancelNewInteraction);
  		
        
        
  		
  	}
    
    // At the end of mouse release, we return at the beginning state 
    mouseDown = false;
  	selectedNodeName = null;
  	selectedNode2Name = null;
  	letsdraw = false;
  	ctx.clearRect(0, 0, dom.offsetWidth, dom.offsetHeight);
  };
  mouseDownOutnodes = function(e) {
  	popUp && popUp.remove();
  };
  mouseUpOutnodes = function(e) {
    // At the end of mouse release, we return at the beginning state
  	mouseDown = false;
  	selectedNodeName = null;
  	selectedNode2Name = null;
  	letsdraw = false;
  	ctx.clearRect(0, 0, dom.offsetWidth, dom.offsetHeight);
{'fraction_non_alphanumeric': 0.13463085089271354, 'fraction_numerical': 0.009490107769020428, 'mean_word_length': 2.571510626076967, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3425474', 'n_tokens_mistral': 2108, 'n_tokens_neox': 2036, 'n_words': 463}