<commit_before>var oscar = oscar || {};
oscar.basket = {
    is_form_being_submitted: false,
    init: function() {
        $('#basket_formset a[data-behaviours~="remove"]').click(function() {
            oscar.basket.checkAndSubmit($(this), 'DELETE');
        });
        $('#basket_formset a[data-behaviours~="save"]').click(function() {
            oscar.basket.checkAndSubmit($(this), 'save_for_later');
        });
        $('#saved_basket_formset a[data-behaviours~="move"]').click(function() {
            oscar.basket.checkAndSubmit($(this), 'move_to_basket');
        });
        $('#voucher_form_link a').click(function(e) {
            oscar.basket.showVoucherForm();
            e.preventDefault();
        });
        $('#voucher_form_cancel').click(function(e) {
            oscar.basket.hideVoucherForm();
            e.preventDefault();
        });
        if (window.location.hash == '#voucher') {
            oscar.basket.showVoucherForm();
        }
    },
    showVoucherForm: function() {
        $('#voucher_form_container').show(); 
        $('#voucher_form_link').hide();
    },
    hideVoucherForm: function() {
        $('#voucher_form_container').hide(); 
        $('#voucher_form_link').show();
    },
    checkAndSubmit: function($ele, idSuffix) {
        if (oscar.basket.is_form_being_submitted) {
            return;
        }
        var formID = $ele.attr('data-id');
        var inputID = '#id_form-' + formID + '-' + idSuffix;
        $(inputID).attr('checked', 'checked');
        $ele.closest('form').submit();
        oscar.basket.is_form_being_submitted = true;
    }
};
oscar.checkout = {
    init: function() {
        // Disable 'place order' button when it is clicked.
        $('#place-order').click(function(e) {
            var $btn = $(this);
            $btn.attr('value', 'Submitting')
                .removeClass('btn-primary')
                .addClass('btn-success');
        });
    },
    gateway: {
        init: function() {
            var radioWidgets = $('form input[name=options]');
            oscar.checkout.gateway.handleRadioSelection(radioWidgets.val());
            radioWidgets.change(oscar.checkout.gateway.handleRadioChange);
        },
        handleRadioChange: function() {
            oscar.checkout.gateway.handleRadioSelection($(this).val());
        },
        handleRadioSelection: function(value) {
            var pwInput = $('#id_password');
            if (value == 'new') {
                pwInput.attr('disabled', 'disabled');
            } else {
                pwInput.removeAttr('disabled');
            }
        }
    }
};
<commit_msg>Fixed JS error with removing items from saved basket<commit_after>var oscar = oscar || {};
oscar.basket = {
    is_form_being_submitted: false,
    init: function() {
        $('#basket_formset a[data-behaviours~="remove"]').click(function() {
            oscar.basket.checkAndSubmit($(this), 'DELETE');
        });
        $('#basket_formset a[data-behaviours~="save"]').click(function() {
            oscar.basket.checkAndSubmit($(this), 'save_for_later');
        });
        $('#saved_basket_formset a[data-behaviours~="move"]').click(function() {
            oscar.basket.checkAndSubmit($(this), 'move_to_basket');
        });
        $('#saved_basket_formset a[data-behaviours~="remove"]').click(function() {
            oscar.basket.checkAndSubmit($(this), 'DELETE');
        });
        $('#voucher_form_link a').click(function(e) {
            oscar.basket.showVoucherForm();
            e.preventDefault();
        });
        $('#voucher_form_cancel').click(function(e) {
            oscar.basket.hideVoucherForm();
            e.preventDefault();
        });
        if (window.location.hash == '#voucher') {
            oscar.basket.showVoucherForm();
        }
    },
    showVoucherForm: function() {
        $('#voucher_form_container').show(); 
        $('#voucher_form_link').hide();
    },
    hideVoucherForm: function() {
        $('#voucher_form_container').hide(); 
        $('#voucher_form_link').show();
    },
    checkAndSubmit: function($ele, idSuffix) {
        if (oscar.basket.is_form_being_submitted) {
            return;
        }
        var formID = $ele.attr('data-id');
        var inputID = '#id_form-' + formID + '-' + idSuffix;
        $(inputID).attr('checked', 'checked');
        $ele.closest('form').submit();
        oscar.basket.is_form_being_submitted = true;
    }
};
oscar.checkout = {
    init: function() {
        // Disable 'place order' button when it is clicked.
        $('#place-order').click(function(e) {
            var $btn = $(this);
            $btn.attr('value', 'Submitting')
                .removeClass('btn-primary')
                .addClass('btn-success');
        });
    },
    gateway: {
        init: function() {
            var radioWidgets = $('form input[name=options]');
            oscar.checkout.gateway.handleRadioSelection(radioWidgets.val());
            radioWidgets.change(oscar.checkout.gateway.handleRadioChange);
        },
        handleRadioChange: function() {
            oscar.checkout.gateway.handleRadioSelection($(this).val());
        },
        handleRadioSelection: function(value) {
            var pwInput = $('#id_password');
            if (value == 'new') {
                pwInput.attr('disabled', 'disabled');
            } else {
                pwInput.removeAttr('disabled');
            }
        }
    }
};

{'fraction_non_alphanumeric': 0.16856408373117884, 'fraction_numerical': 0.0, 'mean_word_length': 2.198473282442748, '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': '6069254', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1666, 'n_words': 214}