<commit_before>var React       = require('react');
var InfoPane    = require('./info-pane');
var LinkView    = require('./link-view');
var NodeWell    = require('./node-well-view');
var NodeEditView= require('./node-edit-view');
var LinkEditView= require('./link-edit-view');
var StatusMenu  = require('./status-menu-view');
var LinkManager = require('./models/link-manager');
var _           = require('lodash');
var log         = require('loglevel');
var $           = require('./vendor/touchpunch');

log.setLevel(log.levels.TRACE);

var AppView = React.createClass({
  getInitialState: function() { 
    var state = {
      selectedNode: null,
      selectedConnection: null
    };
    return state;
  },

  componentWillUpdate: function() {
  },

  componentDidUpdate: function() {
    log.info("Did Update: AppView ");
  },

  setupDeleteKeyHandler: function(linkManager) {
    var deleteFunction = linkManager.deleteSelected.bind(linkManager);
    $(document).on("keyup", function (e) {
      if (e.which === 8 && !$(e.target).is("input, textarea")) {
        e.preventDefault();
        deleteFunction();
      }
    });
  },

  componentDidMount: function() {
    var linkManager = this.props.linkManager;
    var data = this.props.data;

    this.setupDeleteKeyHandler(linkManager);
    linkManager.addSelectionListener(function(selections) {
      var selectedNode = selections.node;
      var selectedConnection = selections.connection;
      this.setState({selectedNode: selectedNode});
      this.setState({selectedConnection: selectedConnection});
      log.info("updated selections: + selections");
    }.bind(this));
  
    if(data && data.length > 0) {
      linkManager.loadData(JSON.parse(data));
    }
    else {
      linkManager.loadDataFromUrl(this.props.url);
    }

  },

  getData: function() {
    var linkManager = this.props.linkManager;
    return linkManager.toJsonString();
  },

  render: function() {
    var linkManager = this.props.linkManager;
    var selectedNode = this.state.selectedNode;
    var selectedConnection = this.state.selectedConnection;
    var onNodeChanged = function(node,title,image) {
      linkManager.changeNode(title,image);
    }.bind(this);

    var onLinkChanged = function(link, title, color, deleted) {
      linkManager.changeLink(title,color,deleted);
    };
    
    var getData = this.getData.bind(this);
    return (
      <div className = "app">
        <StatusMenu getData={getData} />
        <LinkView linkManager={linkManager}/>
        <div className="bottomTools">
          <NodeWell />  
          <NodeEditView node={selectedNode} onNodeChanged={onNodeChanged}/>
          <LinkEditView link={selectedConnection} onLinkChanged={onLinkChanged}/>
        </div>
      </div>
    );
  }
});

var linkManager = LinkManager.instance('building-models');
var url = "serialized.json";
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

jsPlumb.bind("ready", function() {
  // debugger;
  var data = getParameterByName('data');

  React.render(
    <AppView url={url} linkManager={linkManager} data={data}/>,
    $('#app')[0]
  );
});

module.exports = AppView;
<commit_msg>[#90121702] Catch the key event sooner.<commit_after>var React       = require('react');
var InfoPane    = require('./info-pane');
var LinkView    = require('./link-view');
var NodeWell    = require('./node-well-view');
var NodeEditView= require('./node-edit-view');
var LinkEditView= require('./link-edit-view');
var StatusMenu  = require('./status-menu-view');
var LinkManager = require('./models/link-manager');
var _           = require('lodash');
var log         = require('loglevel');
var $           = require('./vendor/touchpunch');

log.setLevel(log.levels.TRACE);

var AppView = React.createClass({
  getInitialState: function() { 
    var state = {
      selectedNode: null,
      selectedConnection: null
    };
    return state;
  },

  componentWillUpdate: function() {
  },

  componentDidUpdate: function() {
    log.info("Did Update: AppView ");
  },

  setupDeleteKeyHandler: function(linkManager) {
    var deleteFunction = linkManager.deleteSelected.bind(linkManager);
    $(window).on("keydown", function (e) {
      if (e.which === 8 && !$(e.target).is("input, textarea")) {
        e.preventDefault();
        deleteFunction();
      }
    });
  },

  componentDidMount: function() {
    var linkManager = this.props.linkManager;
    var data = this.props.data;

    this.setupDeleteKeyHandler(linkManager);
    linkManager.addSelectionListener(function(selections) {
      var selectedNode = selections.node;
      var selectedConnection = selections.connection;
      this.setState({selectedNode: selectedNode});
      this.setState({selectedConnection: selectedConnection});
      log.info("updated selections: + selections");
    }.bind(this));
  
    if(data && data.length > 0) {
      linkManager.loadData(JSON.parse(data));
    }
    else {
      linkManager.loadDataFromUrl(this.props.url);
    }

  },

  getData: function() {
    var linkManager = this.props.linkManager;
    return linkManager.toJsonString();
  },

  render: function() {
    var linkManager = this.props.linkManager;
    var selectedNode = this.state.selectedNode;
    var selectedConnection = this.state.selectedConnection;
    var onNodeChanged = function(node,title,image) {
      linkManager.changeNode(title,image);
    }.bind(this);

    var onLinkChanged = function(link, title, color, deleted) {
      linkManager.changeLink(title,color,deleted);
    };
    
    var getData = this.getData.bind(this);
    return (
      <div className = "app">
        <StatusMenu getData={getData} />
        <LinkView linkManager={linkManager}/>
        <div className="bottomTools">
          <NodeWell />  
          <NodeEditView node={selectedNode} onNodeChanged={onNodeChanged}/>
          <LinkEditView link={selectedConnection} onLinkChanged={onLinkChanged}/>
        </div>
      </div>
    );
  }
});

var linkManager = LinkManager.instance('building-models');
var url = "serialized.json";
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

jsPlumb.bind("ready", function() {
  // debugger;
  var data = getParameterByName('data');

  React.render(
    <AppView url={url} linkManager={linkManager} data={data}/>,
    $('#app')[0]
  );
});

module.exports = AppView;

{'fraction_non_alphanumeric': 0.16191595650896268, 'fraction_numerical': 0.0023508668821627977, 'mean_word_length': 3.2570356472795496, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '216046', 'n_tokens_mistral': 2043, 'n_tokens_neox': 2015, 'n_words': 375}