<commit_before>(function ($) {

    // TODO: We're going to need data-* attributes to prevent expanding/collapsing/etc all of
    // the buttons at once
    $('div').on('click', '.save-button', function (e) {
        var id = $(this).attr('data-id');
        $('#save-button-div-' + id).collapse('hide');
        $('#watched-buttons-' + id).collapse('show');
    });

    $('div').on('click', '.watched-btn', function (e) {
        var id = $(this).attr('data-id');
        var state = $(this).attr('data-state');

        var request = {
            url: "/api/user/watchMovie/" + id.substring(0, id.indexOf('_')),
            method: "POST",
            contentType: "application/json",
            data: JSON.stringify({
                state: state
            })
        };

        $.ajax(request).then(function (response) {
            if (!response.err) {
                $('#watched-buttons-' + id).collapse('hide');

                if (state == 2) {
                    $("#movie-panel-" + id).unbind('mouseleave mouseenter');
                    $('#rate-' + id).collapse('show');
                } else {
                    $('.save-button[data-id="' + id + '"]').attr('disabled', 'disabled');
                    $('#save-button-div-' + id).collapse('show');
                }
            } else {
                console.log(response.err);
            }
        });
    });

    $('.save-rating-btn').click(function (e) {
        var id = $(this).attr('data-id');
        var rating = parseInt($('#rating-' + id).val());

        if (rating) {
            var request = {
                url: "/api/movies/" + id.substring(0, id.indexOf('_')) + "/vote",
                method: "POST",
                contentType: "application/json",
                data: JSON.stringify({
                    rating: rating
                })
            };

            $.ajax(request).then(function (response) {
                resetButtons(id);
            });
        }
    });

    $('.cancel-rating-btn').click(function (e) {
        var id = $(this).attr('data-id');
        resetButtons(id);
    });

    function resetButtons (id) {
        // Reset buttons and re-attach event handler
        $('#rate-' + id).collapse('hide');
        $('.save-button[data-id="' + id + '"]').attr('disabled', 'disabled');
        $('#save-button-div-' + id).collapse('show');
        $("#movie-panel-" + id).bind('mouseenter', function () {
            $(this).find('.movie-panel-overlay').finish();
            $(this).find('.movie-panel-overlay').fadeIn(150);
        }).bind('mouseleave', function () {
            $(this).find('.movie-panel-overlay').fadeOut(150);
        });
    };

    $('h2').on('click', '.btn-collapse', function (e) {
        if (this.dataset.expanded === 'true') {
            $(this).animate({ rotateAmount: -90 }, {
                step: function (now, fx) {
                    console.log(now);
                    $(this).css('transform', 'rotate(' + now + 'deg)');
                },
                duration: 150
            });
            this.dataset.expanded = false;
        } else {
            $(this).animate({ rotateAmount: 0 }, {
                step: function (now, fx) {
                    console.log(now);
                    $(this).css('transform', 'rotate(' + now + 'deg)');
                },
                duration: 150
            });
            this.dataset.expanded = true;
        }
    });

    // For every <li><a href=[path]></a></li>, if the path is equal to the current
    // browser location, give the anchor the 'active' class so it is properly<commit_msg>Made button changes propagate to all duplicates<commit_after>(function ($) {

    // TODO: We're going to need data-* attributes to prevent expanding/collapsing/etc all of
    // the buttons at once
    $('div').on('click', '.save-button', function (e) {
        var id = $(this).attr('data-id');

        //trim genre off the end of id (it was there for uniqueness on the page)
        id = id.substring(0, id.indexOf('_'));
        $('[id^=save-button-div-' + id + ']').collapse('hide');
        $('[id^=watched-buttons-' + id + ']').collapse('show');
    });

    $('div').on('click', '.watched-btn', function (e) {
        var id = $(this).attr('data-id');
        var state = $(this).attr('data-state');

        //trim genre off the end of id (it was there for uniqueness on the page)
        id = id.substring(0, id.indexOf('_'));
        var request = {
            url: "/api/user/watchMovie/" + id,
            method: "POST",
            contentType: "application/json",
            data: JSON.stringify({
                state: state
            })
        };

        $.ajax(request).then(function (response) {
            if (!response.err) {
                $('[id^=watched-buttons-' + id + ']').collapse('hide');

                if (state == 2) {
                    $('[id^=movie-panel-' + id + ']').unbind('mouseleave mouseenter');
                    $('[id^=rate-' + id + ']').collapse('show');
                } else {
                    $('.save-button[data-id^="' + id + '"]').attr('disabled', 'disabled');
                    $('[id^=save-button-div-' + id + ']').collapse('show');
                }
            } else {
                console.log(response.err);
            }
        });
    });

    $('.save-rating-btn').click(function (e) {
        var id = $(this).attr('data-id');
        var rating = parseInt($('#rating-' + id).val());

        //trim genre off the end of id (it was there for uniqueness on the page)
        id = id.substring(0, id.indexOf('_'));
        if (rating) {
            var request = {
                url: "/api/movies/" + id + "/vote",
                method: "POST",
                contentType: "application/json",
                data: JSON.stringify({
                    rating: rating
                })
            };

            $.ajax(request).then(function (response) {
                resetButtons(id);
            });
        }
    });

    $('.cancel-rating-btn').click(function (e) {
        var id = $(this).attr('data-id');
        resetButtons(id);
    });

    function resetButtons (id) {
        // Reset buttons and re-attach event handler
        $('[id^=rate-' + id + ']').collapse('hide');
        $('.save-button[data-id^="' + id + '"]').attr('disabled', 'disabled');
        $('[id^=save-button-div-' + id + ']').collapse('show');
        $('[id^=movie-panel-' + id + ']').bind('mouseenter', function () {
            $(this).find('.movie-panel-overlay').finish();
            $(this).find('.movie-panel-overlay').fadeIn(150);
        }).bind('mouseleave', function () {
            $(this).find('.movie-panel-overlay').fadeOut(150);
        });
    };

    $('h2').on('click', '.btn-collapse', function (e) {
        if (this.dataset.expanded === 'true') {
            $(this).animate({ rotateAmount: -90 }, {
                step: function (now, fx) {
                    console.log(now);
                    $(this).css('transform', 'rotate(' + now + 'deg)');
                },
                duration: 150
            });
            this.dataset.expanded = false;
        } else {
            $(this).animate({ rotateAmount: 0 }, {
                step: function (now, fx) {
                    console.log(now);
                    $(this).css('transform', 'rotate(' + now + 'deg)');
                },
                duration: 150
            });
            this.dataset.expanded = true;
        }
    });

    // For every <li><a href=[path]></a></li>, if the path is equal to the current
    // browser location, give the anchor the 'active' class so it is properly
{'fraction_non_alphanumeric': 0.19329260366567008, 'fraction_numerical': 0.005069543741063305, 'mean_word_length': 1.587958291288261, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2599404', 'n_tokens_mistral': 2271, 'n_tokens_neox': 2121, 'n_words': 464}