{"size": 1075, "ext": "js", "max_stars_repo_path": "web/src/browserify/comment.js", "max_stars_repo_name": "JiangJie/cap-pas-cap", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "web/src/browserify/comment.js", "max_issues_repo_name": "JiangJie/cap-pas-cap", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "web/src/browserify/comment.js", "max_forks_repo_name": "JiangJie/cap-pas-cap", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.4318181818, "max_line_length": 76, "alphanum_fraction": 0.4911627907}
'use strict';

var $ = window.$ || window.Zepto;

function bindEvent() {
    var $submit = $('#submit');
    $('#commentForm').on('submit', function(e) {
        if($submit.hasClass('disabled')) return;

        e.preventDefault();

        var cid = this.dataset.cid;
        var desc = $('#desc').val().trim();
        if(!desc) return alert('Please fill comment.');

        var data = {
            desc: desc
        };

        var url = this.action;
        var method = this.method.toUpperCase();

        $submit.addClass('disabled');
        $.ajax({
            url: url,
            type: method,
            data: data
        }).done(function(res) {
            console.log('success', res);
            window.location.href = '/page/challenge/' + cid + '?tab=review';
            // window.location.reload();
        }).fail(function(err) {
            console.log('fail', arguments);

            alert('Submit fail.');
        }).always(function() {
            $submit.removeClass('disabled');
        });
    });
}

(function init() {
    bindEvent();
})();