{"size": 1845, "ext": "js", "max_stars_repo_path": "web/js/main.js", "max_stars_repo_name": "DioNiR/comments_yii", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "web/js/main.js", "max_issues_repo_name": "DioNiR/comments_yii", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "web/js/main.js", "max_forks_repo_name": "DioNiR/comments_yii", "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": 31.8103448276, "max_line_length": 110, "alphanum_fraction": 0.4699186992}
$(document).ready(function () {
    $(document).on("click", '[data-toggle="collapse"]', function() {
        let $this = $(this),
            $parent = typeof $this.data('parent') !== 'undefined' ? $($this.data('parent')) : undefined;
        if ($parent === undefined) {
            $this.find('.glyphicon').toggleClass('glyphicon-plus glyphicon-minus');
            return true;
        }

        let currentIcon = $this.find('.glyphicon');
        currentIcon.toggleClass('glyphicon-plus glyphicon-minus');
        $parent.find('.glyphicon').not(currentIcon).removeClass('glyphicon-minus').addClass('glyphicon-plus');

    });

    $(document).on('click', '.show_comments', function() {
        let id = $(this).data('id');
        $(this).remove();
        $('#comments_' + id).find('.hide_comments').show();
    });

    $(document).on('click', '.delete_comment', function() {
        let id = $(this).data('id');
        console.log(id);
        $.ajax({
            type: "POST",
            url: '/comments/delete',
            data: {'id': id},
            success: function (data) {
                console.log(data);
                $('#comment_' + id).remove();
            },
            dataType: 'json'
        });

        return false;
    });

    $(document).on("submit", 'form', function() {
        let parentId = $(this).find('[name="CommentForm[parentId]"]').val();

        $.ajax({
            type: "POST",
            url: '/comments/create',
            data: $(this).serialize(),
            success: function (data) {
                if (0 == parentId) {
                    $('#comments').append(data['html']);
                } else {
                    $('#comments_' + parentId).append(data['html']);
                }
            },
            dataType: 'json'
        });

        return false;
    });
});