<commit_before>$(function() {

    // Change train stops for each line
    $('#select-line').change(function() {
        var id = $(this).val();
        $(".convenient").addClass("hidden");
        $("#" + id).removeClass("hidden");
    });

    // Delete account and confirmation
    $("#delete-account-form").submit(function(event) {
        if ($("#delete-account").val() == "Are you sure?") {
            return true;
        } else {
            $("#delete-account").val("Are you sure?");
            return false;
        };
    });

    $(document).click(function(event) {
        if (!$(event.target).is('#delete-account')) {
            $("#delete-account").val("Delete account");
        };
    });

    // Delete a stop
    $(document).on("click", ".pure-button.delete.unique", function(event) {

        event.preventDefault();
        var id = $("#user").val();

        $.ajax({
            url: $(".delete-stop").attr("action"),
            method: 'POST',
            dataType: 'text',
            success: function(data) {
                $('#partials-div').load('/users/' + id + '/stops');
            },
            error: function(data) {
                $("#stop-table-header").text("An error occurred.");
                setTimeout(
                    function() {
                        $('#stop-table-header').text("Your stops");
                    }, 3500);
            }
        });
    });

    // Add a stop
    $("#new-stop").submit(function(event) {
        event.preventDefault();

        if (!$("#select-time").val() || $("input:checkbox:checked").length == 0) {
            $("#stop-header").text("Please enter a time and date.")
            setTimeout(
                function() {
                    $('#stop-header').text("Add a new stop");
                }, 3500);
        } else {
            var id = $("#user").val();

            $.ajax({
                url: '/users/' + id + '/trains/create',
                method: 'POST',
                type: 'json',
                data: {
                    time: $("#select-time").val(),
                    line: $("#select-line").val(),
                    stop: $("#select-stop-" + $("#select-line").val().toLowerCase()).val(),
                    days: {
                        monday: $("#monday:checked").val(),
                        tuesday: $("#tuesday:checked").val(),
                        wednesday: $("#wednesday:checked").val(),
                        thursday: $("#thursday:checked").val(),
                        friday: $("#friday:checked").val(),
                        saturday: $("#saturday:checked").val(),
                        sunday: $("#sunday:checked").val()
                    }
                },
                success: function(data) {
                    $("#stop-header").text(data);
                    $('#partials-div').load('/users/' + id + '/stops');
                    $("#new-stop").trigger('reset'); 
                    setTimeout(
                        function() {
                            $('#stop-header').text("Add a new stop");
                        }, 3500);
                },
                error: function(data) {
                    $("#stop-header").text(data['responseText']);

                    setTimeout(
                        function() {
                            $('#stop-header').text("Add a new stop");
                        }, 3500);

                }
            });
        };
    });

});<commit_msg>minor edit for heroku error handling<commit_after>$(function() {

    // Change train stops for each line
    $('#select-line').change(function() {
        var id = $(this).val();
        $(".convenient").addClass("hidden");
        $("#" + id).removeClass("hidden");
    });

    // Delete account and confirmation
    $("#delete-account-form").submit(function(event) {
        if ($("#delete-account").val() == "Are you sure?") {
            return true;
        } else {
            $("#delete-account").val("Are you sure?");
            return false;
        };
    });

    $(document).click(function(event) {
        if (!$(event.target).is('#delete-account')) {
            $("#delete-account").val("Delete account");
        };
    });

    // Delete a stop
    $(document).on("click", ".pure-button.delete.unique", function(event) {

        event.preventDefault();
        var id = $("#user").val();

        $.ajax({
            url: $(".delete-stop").attr("action"),
            method: 'POST',
            dataType: 'text',
            success: function(data) {
                $('#partials-div').load('/users/' + id + '/stops');
            },
            error: function(data) {
                $("#stop-table-header").text("An error occurred.");
                setTimeout(
                    function() {
                        $('#stop-table-header').text("Your stops");
                    }, 3500);
            }
        });
    });

    // Add a stop
    $("#new-stop").submit(function(event) {
        event.preventDefault();

        if (!$("#select-time").val() || $("input:checkbox:checked").length == 0) {
            $("#stop-header").text("Please enter a time and date.")
            setTimeout(
                function() {
                    $('#stop-header').text("Add a new stop");
                }, 3500);
        } else {
            var id = $("#user").val();

            $.ajax({
                url: '/users/' + id + '/trains/create',
                method: 'POST',
                type: 'json',
                data: {
                    time: $("#select-time").val(),
                    line: $("#select-line").val(),
                    stop: $("#select-stop-" + $("#select-line").val().toLowerCase()).val(),
                    days: {
                        monday: $("#monday:checked").val(),
                        tuesday: $("#tuesday:checked").val(),
                        wednesday: $("#wednesday:checked").val(),
                        thursday: $("#thursday:checked").val(),
                        friday: $("#friday:checked").val(),
                        saturday: $("#saturday:checked").val(),
                        sunday: $("#sunday:checked").val()
                    }
                },
                success: function(data) {
                    $("#stop-header").text(data);
                    $('#partials-div').load('/users/' + id + '/stops');
                    $("#new-stop").trigger('reset'); 
                    setTimeout(
                        function() {
                            $('#stop-header').text("Add a new stop");
                        }, 3500);
                },
                error: function(data) {
                    $("#stop-header").text("An error has occurred.");

                    setTimeout(
                        function() {
                            $('#stop-header').text("Add a new stop");
                        }, 3500);

                }
            });
        };
    });

});
{'fraction_non_alphanumeric': 0.19102728961280183, 'fraction_numerical': 0.004857836833833405, 'mean_word_length': 1.2537025112685125, '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': '4970531', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1682, 'n_words': 308}