<commit_before>/** @jsx React.DOM */

"use strict";

var _ = require("lodash");
var React = require("react");

var Category = require("./Category.jsx");
var Tags = require("./Tags.jsx");

var GITHUB_REGEX = new RegExp('github.com/(.*?)/([^/?#]+)');
var VIMORG_REGEX = new RegExp('vim.org/scripts/script.php\\?script_id=\\d+');

// TODO(david): Form validation on submit! Not done right now because we
//     currently just save this raw data to be manually reviewed.
var SubmitPage = React.createClass({
  getInitialState: function() {
    return {
      name: '',
      author: '',
      github: '',
      vimorg: '',
      tags: [],
      category: "uncategorized",
      submitting: false
    };
  },

  onTagsChange: function(tags) {
    this.setState({tags: _.uniq(tags)});
  },

  onCategoryChange: function(category) {
    this.setState({category: category});
  },

  nameIsValid: function() {
    return this.state.name !== '';
  },

  authorIsValid: function() {
    return this.state.author !== '';
  },

  githubIsValid: function() {
    return this.state.github === '' || GITHUB_REGEX.test(this.state.github);
  },

  vimorgIsValid: function() {
    return this.state.vimorg === '' || VIMORG_REGEX.test(this.state.vimorg);
  },

  onNameChange: function(e) {
    return this.setState({name: e.target.value});
  },

  onAuthorChange: function(e) {
    return this.setState({author: e.target.value});
  },

  onGithubChange: function(e) {
    return this.setState({github: e.target.value});
  },

  onVimorgChange: function(e) {
    return this.setState({vimorg: e.target.value});
  },

  formIsValid: function() {
    return _.every([
        this.nameIsValid(),
        this.authorIsValid(),
        this.githubIsValid(),
        this.vimorgIsValid()
    ]);
  },

  // TODO(captbaritone): Submit the form via API
  onSubmit: function() {
    // Enable validation errors
    this.setState({submitting: true});

    // Should the for actually submit?
    return this.formIsValid();
  },

  render: function() {
    var submitting = this.state.submitting;
    return <div className="submit-page"><commit_msg>Use `preventDefault()` to stop submission<commit_after>/** @jsx React.DOM */

"use strict";

var _ = require("lodash");
var React = require("react");

var Category = require("./Category.jsx");
var Tags = require("./Tags.jsx");

var GITHUB_REGEX = new RegExp('github.com/(.*?)/([^/?#]+)');
var VIMORG_REGEX = new RegExp('vim.org/scripts/script.php\\?script_id=\\d+');

// TODO(david): Form validation on submit! Not done right now because we
//     currently just save this raw data to be manually reviewed.
var SubmitPage = React.createClass({
  getInitialState: function() {
    return {
      name: '',
      author: '',
      github: '',
      vimorg: '',
      tags: [],
      category: "uncategorized",
      submitting: false
    };
  },

  onTagsChange: function(tags) {
    this.setState({tags: _.uniq(tags)});
  },

  onCategoryChange: function(category) {
    this.setState({category: category});
  },

  nameIsValid: function() {
    return this.state.name !== '';
  },

  authorIsValid: function() {
    return this.state.author !== '';
  },

  githubIsValid: function() {
    return this.state.github === '' || GITHUB_REGEX.test(this.state.github);
  },

  vimorgIsValid: function() {
    return this.state.vimorg === '' || VIMORG_REGEX.test(this.state.vimorg);
  },

  onNameChange: function(e) {
    return this.setState({name: e.target.value});
  },

  onAuthorChange: function(e) {
    return this.setState({author: e.target.value});
  },

  onGithubChange: function(e) {
    return this.setState({github: e.target.value});
  },

  onVimorgChange: function(e) {
    return this.setState({vimorg: e.target.value});
  },

  formIsValid: function() {
    return _.every([
        this.nameIsValid(),
        this.authorIsValid(),
        this.githubIsValid(),
        this.vimorgIsValid()
    ]);
  },

  // TODO(captbaritone): Submit the form via API
  onSubmit: function(e) {
    // Enable validation errors
    this.setState({submitting: true});

    // Should the form actually submit?
    if (!this.formIsValid()) {
        e.preventDefault();
    }
  },

  render: function() {
    var submitting = this.state.submitting;
    return <div className="submit-page">
{'fraction_non_alphanumeric': 0.16883720930232557, 'fraction_numerical': 0.0, 'mean_word_length': 3.1555555555555554, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2107819', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1380, 'n_words': 288}