<commit_before>var React = require('react/addons');
var update = React.addons.update;
var assign = require('react/lib/Object.assign');
var classNames = require('classnames');

var render = require('../../lib/render.jsx');
var router = require('../../lib/router.jsx');
var Cartesian = require('../../lib/cartesian');
var Link = require('../../components/link/link.jsx');
var Loading = require('../../components/loading/loading.jsx');
var {Menu, PrimaryButton, SecondaryButton} = require('../../components/action-menu/action-menu.jsx');
var types = require('../../components/el/el.jsx').types;
var ElementGroup = require('../../components/element-group/element-group.jsx');

var api = require('../../lib/api');

var MAX_ZOOM = 0.8;
var MIN_ZOOM = 0.18;
var DEFAULT_ZOOM = 0.5;
var ZOOM_SENSITIVITY = 300;

var Page = React.createClass({
  render: function () {
    var classes = classNames('page-container', {
      selected: this.props.selected,
      unselected: this.props.unselected
    });
    var style = {
      backgroundColor: this.props.page.styles.backgroundColor,
      transform: this.props.transform
    };
    return (<div className={classes} style={style} onClick={this.props.onClick}>
      <ElementGroup elements={this.props.page.elements} />
    </div>);
  }
});

var Project = React.createClass({
  mixins: [router],
  getInitialState: function () {
    return {
      loading: true,
      selectedEl: '',
      pages: [],
      camera: {
        x: 0,
        y: 0
      },
      zoom: DEFAULT_ZOOM
    };
  },

  uri: function () {
    return `/users/1/projects/${this.state.params.project}/pages`;
  },

  componentWillMount: function () {

    var width = 320;
    var height = 440;
    var gutter = 20;

    this.cartesian = new Cartesian({
      allCoords: [],
      width,
      height,
      gutter
    });
    this.load();
  },

  componentDidUpdate: function (prevProps) {
    if (this.props.isVisible && !prevProps.isVisible) {
      this.load();
    }
    if (window.Android) window.Android.setState(JSON.stringify(this.state));
  },

  componentDidMount: function () {
    var el = this.getDOMNode();
    var bounding = this.refs.bounding;
    var boundingEl = bounding.getDOMNode();
    var startX, startY, startDistance, currentX, currentY, currentZoom;
    var didMove = false;

    if (window.Android) {
      var state = JSON.parse(window.Android.getState());
      if (state.params && state.params.page === this.state.params.page) {
        this.setState({
          selectedEl: state.selectedEl,
          camera: state.camera,
          zoom: state.zoom
        });
      }
    }

    el.addEventListener('touchstart', (event) => {
      console.log('start', event.touches.length);
      didMove = false;

      if (event.touches.length > 1) {
        var dx = event.touches[1].clientX - event.touches[0].clientX;
        var dy = event.touches[1].clientY - event.touches[0].clientY;
        startDistance = Math.sqrt(dx*dx + dy*dy);
      } else {
        startX = event.touches[0].clientX;
        startY = event.touches[0].clientY;
        boundingEl.style.transition = 'none';
      }

    });

    el.addEventListener('touchmove', (event) => {
      console.log('touchmove', event.touches.length);
      didMove = true;
      var translateStr = 'translate(' + this.state.camera.x + 'px, ' + this.state.camera.y + 'px)';
      var scaleStr = 'scale(' + this.state.zoom + ')';
      var center;
      if (event.touches.length > 1) {
        currentZoom = this.state.zoom;
        var dx = event.touches[1].clientX - event.touches[0].clientX
        var dy = event.touches[1].clientY - event.touches[0].clientY;
        var distance = Math.sqrt(dx*dx + dy*dy);

        currentZoom = currentZoom + ((distance - startDistance) / ZOOM_SENSITIVITY);
        currentZoom = Math.min(Math.max(currentZoom, MIN_ZOOM), MAX_ZOOM);
        scaleStr = 'scale(' + currentZoom + ')';
      }

      var x = this.state.camera.x;
      var y = this.state.camera.y;
      currentX = x + (event.touches[0].clientX - startX);
      currentY = y + (event.touches[0].clientY - startY);
      translateStr = 'translate(' + currentX + 'px, ' + currentY + 'px)';
      boundingEl.style.transform = translateStr + ' ' + scaleStr;
    });

    el.addEventListener('touchend', (event) => {
      console.log('end', event.touches.length, event);
      if (event.touches.length === 0) {
        boundingEl.style.transition = '';
        if (!didMove) return;

        var state = {camera: {
          x: currentX,
          y: currentY
        }};
        if (typeof currentZoom !== 'undefined') state.zoom = currentZoom;
        this.setState(state);
        startX, startY, startDistance, currentX, currentY, currentZoom = undefined;
      } else {
        startX = event.touches[0].clientX;
        startY = event.touches[0].clientY;
        this.state.camera.x = currentX;
        this.state.camera.y = currentY;
        this.state.zoom = currentZoom;
      }

    });
  },
  selectPage: function (el) {
    return () => {<commit_msg>Remove logs from project.jsx. Resolves GH-1874<commit_after>var React = require('react/addons');
var update = React.addons.update;
var assign = require('react/lib/Object.assign');
var classNames = require('classnames');

var render = require('../../lib/render.jsx');
var router = require('../../lib/router.jsx');
var Cartesian = require('../../lib/cartesian');
var Link = require('../../components/link/link.jsx');
var Loading = require('../../components/loading/loading.jsx');
var {Menu, PrimaryButton, SecondaryButton} = require('../../components/action-menu/action-menu.jsx');
var types = require('../../components/el/el.jsx').types;
var ElementGroup = require('../../components/element-group/element-group.jsx');

var api = require('../../lib/api');

var MAX_ZOOM = 0.8;
var MIN_ZOOM = 0.18;
var DEFAULT_ZOOM = 0.5;
var ZOOM_SENSITIVITY = 300;

var Page = React.createClass({
  render: function () {
    var classes = classNames('page-container', {
      selected: this.props.selected,
      unselected: this.props.unselected
    });
    var style = {
      backgroundColor: this.props.page.styles.backgroundColor,
      transform: this.props.transform
    };
    return (<div className={classes} style={style} onClick={this.props.onClick}>
      <ElementGroup elements={this.props.page.elements} />
    </div>);
  }
});

var Project = React.createClass({
  mixins: [router],
  getInitialState: function () {
    return {
      loading: true,
      selectedEl: '',
      pages: [],
      camera: {
        x: 0,
        y: 0
      },
      zoom: DEFAULT_ZOOM
    };
  },

  uri: function () {
    return `/users/1/projects/${this.state.params.project}/pages`;
  },

  componentWillMount: function () {

    var width = 320;
    var height = 440;
    var gutter = 20;

    this.cartesian = new Cartesian({
      allCoords: [],
      width,
      height,
      gutter
    });
    this.load();
  },

  componentDidUpdate: function (prevProps) {
    if (this.props.isVisible && !prevProps.isVisible) {
      this.load();
    }
    if (window.Android) window.Android.setState(JSON.stringify(this.state));
  },

  componentDidMount: function () {
    var el = this.getDOMNode();
    var bounding = this.refs.bounding;
    var boundingEl = bounding.getDOMNode();
    var startX, startY, startDistance, currentX, currentY, currentZoom;
    var didMove = false;

    if (window.Android) {
      var state = JSON.parse(window.Android.getState());
      if (state.params && state.params.page === this.state.params.page) {
        this.setState({
          selectedEl: state.selectedEl,
          camera: state.camera,
          zoom: state.zoom
        });
      }
    }

    el.addEventListener('touchstart', (event) => {
      didMove = false;

      if (event.touches.length > 1) {
        var dx = event.touches[1].clientX - event.touches[0].clientX;
        var dy = event.touches[1].clientY - event.touches[0].clientY;
        startDistance = Math.sqrt(dx*dx + dy*dy);
      } else {
        startX = event.touches[0].clientX;
        startY = event.touches[0].clientY;
        boundingEl.style.transition = 'none';
      }

    });

    el.addEventListener('touchmove', (event) => {
      didMove = true;
      var translateStr = 'translate(' + this.state.camera.x + 'px, ' + this.state.camera.y + 'px)';
      var scaleStr = 'scale(' + this.state.zoom + ')';
      var center;
      if (event.touches.length > 1) {
        currentZoom = this.state.zoom;
        var dx = event.touches[1].clientX - event.touches[0].clientX
        var dy = event.touches[1].clientY - event.touches[0].clientY;
        var distance = Math.sqrt(dx*dx + dy*dy);

        currentZoom = currentZoom + ((distance - startDistance) / ZOOM_SENSITIVITY);
        currentZoom = Math.min(Math.max(currentZoom, MIN_ZOOM), MAX_ZOOM);
        scaleStr = 'scale(' + currentZoom + ')';
      }

      var x = this.state.camera.x;
      var y = this.state.camera.y;
      currentX = x + (event.touches[0].clientX - startX);
      currentY = y + (event.touches[0].clientY - startY);
      translateStr = 'translate(' + currentX + 'px, ' + currentY + 'px)';
      boundingEl.style.transform = translateStr + ' ' + scaleStr;
    });

    el.addEventListener('touchend', (event) => {
      if (event.touches.length === 0) {
        boundingEl.style.transition = '';
        if (!didMove) return;

        var state = {camera: {
          x: currentX,
          y: currentY
        }};
        if (typeof currentZoom !== 'undefined') state.zoom = currentZoom;
        this.setState(state);
        startX, startY, startDistance, currentX, currentY, currentZoom = undefined;
      } else {
        startX = event.touches[0].clientX;
        startY = event.touches[0].clientY;
        this.state.camera.x = currentX;
        this.state.camera.y = currentY;
        this.state.zoom = currentZoom;
      }

    });
  },
  selectPage: function (el) {
    return () => {
{'fraction_non_alphanumeric': 0.15908179631114674, 'fraction_numerical': 0.00801924619085806, 'mean_word_length': 2.544227353463588, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, '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': '5429986', 'n_tokens_mistral': 3264, 'n_tokens_neox': 3170, 'n_words': 626}