<commit_before>/** @jsx React.DOM */
"use strict";
var React = require("react/addons");
var {Link} = require("react-router");
var QuestionActionCreators = require("../actions/QuestionActionCreators");
var UserStore = require("../stores/UserStore");
var QuestionStore = require("../stores/QuestionStore");
var Button = require("./Button");
var moment = require("moment");

module.exports = React.createClass({
  displayName: "Question",

  getInitialState () {
    // var {cid, pid } = this.props;
    return {
      loggedIn: this.props.loggedIn,
      count: this.props.question.signatures.length,
      // question: this.props.question,
      hideSignButton: false,
      hideContent: !this.props.selected
    };
  },

  shouldComponentUpdate (nextProps, nextState) {
    return (JSON.stringify(nextState) !== JSON.stringify(this.state));
  },

  componentDidMount () {
    QuestionStore.addChangeListener(this._onChange);
  },

  componentWillReceiveProps (nextProps) {
    var {selected, question} = nextProps;
    this.setState({
      hideContent: !selected,
    });
  },

  componentWillUnmount () {
    QuestionStore.removeChangeListener(this._onChange);
  },

  render () {
    return this._render(this.props, this.state);
  },

  _onChange () {
    var {cid, pid, qid} = this.props;
    var question = QuestionStore.get({
      cid: cid,
      pid: pid,
      qid: qid
    });
    this.setState({ count: question.signatures.length });
  },

  _handleSignClick (event) {
    // console.log(this.state.loggedIn);
    if (!this.state.loggedIn) {
      return;
    }
    var {cid, pid, qid} = this.props;
    // var {question} = this.state;
    var user = UserStore.get();
    QuestionActionCreators.signQuestion({
      cid: cid,
      pid: pid,
      id: qid,
      signer: user
    });
    this.setState({
      hideSignButton: true
    });
  },

  _handleShare () {
    var {cid, pid, qid, question} = this.props;
    var user = UserStore.get();
    var name = (user.name)? user.name : '我';

    if(FB) {
      var link = location.origin + '/candidates/' + cid + '/policies/' + pid + '?qid=' + qid;
      FB.ui({
        method: 'feed',
        name: question.title,<commit_msg>chore(fbshare): when name match English add a space<commit_after>/** @jsx React.DOM */
"use strict";
var React = require("react/addons");
var {Link} = require("react-router");
var QuestionActionCreators = require("../actions/QuestionActionCreators");
var UserStore = require("../stores/UserStore");
var QuestionStore = require("../stores/QuestionStore");
var Button = require("./Button");
var moment = require("moment");

module.exports = React.createClass({
  displayName: "Question",

  getInitialState () {
    // var {cid, pid } = this.props;
    return {
      loggedIn: this.props.loggedIn,
      count: this.props.question.signatures.length,
      // question: this.props.question,
      hideSignButton: false,
      hideContent: !this.props.selected
    };
  },

  shouldComponentUpdate (nextProps, nextState) {
    return (JSON.stringify(nextState) !== JSON.stringify(this.state));
  },

  componentDidMount () {
    QuestionStore.addChangeListener(this._onChange);
  },

  componentWillReceiveProps (nextProps) {
    var {selected, question} = nextProps;
    this.setState({
      hideContent: !selected,
    });
  },

  componentWillUnmount () {
    QuestionStore.removeChangeListener(this._onChange);
  },

  render () {
    return this._render(this.props, this.state);
  },

  _onChange () {
    var {cid, pid, qid} = this.props;
    var question = QuestionStore.get({
      cid: cid,
      pid: pid,
      qid: qid
    });
    this.setState({ count: question.signatures.length });
  },

  _handleSignClick (event) {
    // console.log(this.state.loggedIn);
    if (!this.state.loggedIn) {
      return;
    }
    var {cid, pid, qid} = this.props;
    // var {question} = this.state;
    var user = UserStore.get();
    QuestionActionCreators.signQuestion({
      cid: cid,
      pid: pid,
      id: qid,
      signer: user
    });
    this.setState({
      hideSignButton: true
    });
  },

  _handleShare () {
    var {cid, pid, qid, question} = this.props;
    var user = UserStore.get();
    var name = (user.name)? user.name : '我';

    if (name[name.length-1].match(/[a-zA-Z]/)) {
      name += ' ';
    }

    if(FB) {
      var link = location.origin + '/candidates/' + cid + '/policies/' + pid + '?qid=' + qid;
      FB.ui({
        method: 'feed',
        name: question.title,
{'fraction_non_alphanumeric': 0.15838716863443975, 'fraction_numerical': 0.00022276676319893073, 'mean_word_length': 2.844178082191781, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7629188', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1453, 'n_words': 301}