<commit_before>﻿neemo = neemo || {};

neemo.svc = (function ($, urls) {
    return {
        addOrUpdate: function (productId, qty, successFnc, noStockFnc, qtyTooLargeFnc) {
            $.ajax({
                url: urls.cart.addOrUpdate,
                type: 'POST',
                data: JSON.stringify({ productId: productId, qty: qty }),
                dataType: 'json',
                contentType: 'application/json',
                success: function (response) {
                    if (response.Added) {
                        successFnc();
                    }
                    if (response.NotAvailable) {
                        noStockFnc();
                    }
                    if (response.QuantityTooLarge) {
                        qtyTooLargeFnc();
                    }
                }
            });
        }
    }
})(jQuery, neemo.endpoints);

neemo.ui = (function ($, toastr, svc) {

    $('.btn-cart').on('click', function () {
        var me = $(this);
        var qty = 1;

        // Get the QTY from the UI (if any)
        var $qty = me.prev('input');
        if ($qty) {
            qty = $qty.val();
        }

        svc.addOrUpdate(me.data().productid, qty,
            function () {
                toastr.success('Item added to cart');
            },
            function () {
                toastr.error('Looks like we are out of stock!');
            },
            function() {
                toastr.error('The quantity requested is too large.');
            });
    });


    $.ajaxSetup({<commit_msg>Nicer msg when adding item to cart<commit_after>﻿neemo = neemo || {};

neemo.svc = (function ($, urls) {
    return {
        addOrUpdate: function (productId, qty, successFnc, noStockFnc, qtyTooLargeFnc) {
            $.ajax({
                url: urls.cart.addOrUpdate,
                type: 'POST',
                data: JSON.stringify({ productId: productId, qty: qty }),
                dataType: 'json',
                contentType: 'application/json',
                success: function (response) {
                    if (response.Added) {
                        successFnc();
                    }
                    if (response.NotAvailable) {
                        noStockFnc();
                    }
                    if (response.QuantityTooLarge) {
                        qtyTooLargeFnc();
                    }
                }
            });
        }
    }
})(jQuery, neemo.endpoints);

neemo.ui = (function ($, toastr, svc) {

    $('.btn-cart').on('click', function () {
        var me = $(this);
        var qty = 1;

        // Get the QTY from the UI (if any)
        var $qty = me.prev('input');
        if ($qty) {
            qty = $qty.val();
        }

        svc.addOrUpdate(me.data().productid, qty,
            function () {
                toastr.success(qty + ' item(s) added to cart');
            },
            function () {
                toastr.error('Looks like we are out of stock!');
            },
            function() {
                toastr.error('The quantity requested is too large.');
            });
    });


    $.ajaxSetup({
{'fraction_non_alphanumeric': 0.1306005719733079, 'fraction_numerical': 0.0006355258976803305, 'mean_word_length': 1.18005540166205, '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': '4817825', 'n_tokens_mistral': 913, 'n_tokens_neox': 852, 'n_words': 190}