<commit_before>$.fn.modal.prototype.constructor.Constructor.DEFAULTS.backdrop = 'static';
$.fn.modal.prototype.constructor.Constructor.DEFAULTS.keyboard = false;

function modalEvents(button, modal, page ) {
    switch (button.data('action')) {
        case "new_user":
            modal.find('.modal-title').text('Registrar usuario');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/user/new', { }, function(){
                $('#timepicker1, #timepicker2').datetimepicker({
                    format: 'LT'
                });

                modal.find('form').submit(function (e) {
                    $.post('/user/signup/', $(this).serializeArray()).done(function (data) {
                        alert(data.message);
                        if (data.status== 'Ok'){
                            modal.modal('hide');
                        }
                    });
                    e.preventDefault();
                });
            });
            break;
        case "user_profile":
            modal.find('.modal-title').text('Editar información del usuario');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/user/profile', { user_id: button.data('user_id')  }, function(){
                modal.find('form').submit(function(event){
                    $.post('/user/update', $(this).serialize()).done(function (data) {
                        alert(data.message);
                        if (data.status=='Ok'){
                            modal.modal('hide');
                            location.reload();
                        }
                    });
                    event.preventDefault();
                });
            });
            break;
        case "change_password":
            modal.find('.modal-title').text('Cambiar contraseña');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/user/change-password', { user_id: button.data('user_id')  }, function(){
                modal.find('form').submit(function (event) {
                    $.post('/user/update-password', $(this).serialize()).done(function (data) {
                        alert(data.message);
                        if(data.status=='Ok'){
                            modal.modal('hide');
                        }
                    });
                    event.preventDefault();
                });
            });
            break;
        case "new_item":
            modal.find('.modal-title').text('Registrar artículo');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/item/new', {}, function(){

                modal.find('form').submit(function (e) {
                    var formData = new FormData();

                    var arr = $(this).serializeArray();

                    for ( var i =0; i < arr.length ; i++){
                        formData.append(arr[i].name, arr[i].value);
                    }

                    var img = document.getElementById('imagen');
                    formData.append('imagen', img.files[0] );

                    if (confirm("¿Está seguro que quiere registrar " + $('#nArts').val() + " artículos?")) {
                        $.ajax({
                            url: '/item/register',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                            type: 'POST',
                            success: function (data) {
                                alert(data.message);
                                if (data)
                                if (data.status == 'Ok') {
                                    modal.modal('hide');
                                }
                            }
                        });
                    }
                    e.preventDefault();
                });
            });
            break;
        case "back_item":
            modal.find('.modal-title').text('Devolución de artículos');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/item/list/',{ page: page }, function(){
                $(this).find('.list-group-item').click(function(){
                    // alert("Funciona, item: "+ $(this).data('item_id'));
                    $("#modal_content").load('/item/return-item/',{ id: $(this).data('item_id') }, function () {
                        modal.find('form').submit(function (event) {
                            $.post('/item/return', $(this).serialize()).done(function (data) {
                                alert(data.message);
                                if(data.status=='Ok'){
                                    modal.modal('hide');
                                }
                            });
                            event.preventDefault();
                        });
                    });
                });
                $('.pagination').find('li').click(function () {
                    modalEvents(button, modal, $(this).data('pagenumber'));
                });
            });<commit_msg>list devolution<commit_after>$.fn.modal.prototype.constructor.Constructor.DEFAULTS.backdrop = 'static';
$.fn.modal.prototype.constructor.Constructor.DEFAULTS.keyboard = false;

function modalEvents(button, modal, page ) {
    switch (button.data('action')) {
        case "new_user":
            modal.find('.modal-title').text('Registrar usuario');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/user/new', { }, function(){
                $('#timepicker1, #timepicker2').datetimepicker({
                    format: 'LT'
                });

                modal.find('form').submit(function (e) {
                    $.post('/user/signup/', $(this).serializeArray()).done(function (data) {
                        alert(data.message);
                        if (data.status== 'Ok'){
                            modal.modal('hide');
                        }
                    });
                    e.preventDefault();
                });
            });
            break;
        case "user_profile":
            modal.find('.modal-title').text('Editar información del usuario');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/user/profile', { user_id: button.data('user_id')  }, function(){
                modal.find('form').submit(function(event){
                    $.post('/user/update', $(this).serialize()).done(function (data) {
                        alert(data.message);
                        if (data.status=='Ok'){
                            modal.modal('hide');
                            location.reload();
                        }
                    });
                    event.preventDefault();
                });
            });
            break;
        case "change_password":
            modal.find('.modal-title').text('Cambiar contraseña');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/user/change-password', { user_id: button.data('user_id')  }, function(){
                modal.find('form').submit(function (event) {
                    $.post('/user/update-password', $(this).serialize()).done(function (data) {
                        alert(data.message);
                        if(data.status=='Ok'){
                            modal.modal('hide');
                        }
                    });
                    event.preventDefault();
                });
            });
            break;
        case "new_item":
            modal.find('.modal-title').text('Registrar artículo');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/item/new', {}, function(){

                modal.find('form').submit(function (e) {
                    var formData = new FormData();

                    var arr = $(this).serializeArray();

                    for ( var i =0; i < arr.length ; i++){
                        formData.append(arr[i].name, arr[i].value);
                    }

                    var img = document.getElementById('imagen');
                    formData.append('imagen', img.files[0] );

                    if (confirm("¿Está seguro que quiere registrar " + $('#nArts').val() + " artículos?")) {
                        $.ajax({
                            url: '/item/register',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                            type: 'POST',
                            success: function (data) {
                                alert(data.message);
                                if (data)
                                if (data.status == 'Ok') {
                                    modal.modal('hide');
                                }
                            }
                        });
                    }
                    e.preventDefault();
                });
            });
            break;
        case "back_item":
            modal.find('.modal-title').text('Devolución de artículos');
            modal.find('#modal_content').html("");
            modal.find('#modal_content').load('/item/find-items-view',{ page: page }, function(){ // change /item/list
                // ------------------------------------------------------
                modal.find('form').submit(function (e) {
                    // Mostrar resultados
                    modal.find('#search_results').load('/search/items/results_inv', $(this).serializeArray()/*params*/, function () {//mod
                        $('#search_results').find('button[name=go_search]').click(function () {
                            modal.find('#modal_content').load('/item/return-item', {id:$(this).data('item_id')}, function() {
                                modal.find('form').submit(function(event){
                                  $.post('/item/return', $(this).serializeArray()).done(function(data){
                                    alert(data.message);
                                    if(data.status == 'Ok'){
                                        modal.modal('hide')
                                    }
                                  });
                                  event.preventDefault();
                                })
                            })
                        })
                    })
                    e.preventDefault();
                })
                                // ------------------------------------------------------
                $(this).find('.list-group-item').click(function(){
                    // alert("Funciona, item: "+ $(this).data('item_id'));
                    $("#modal_content").load('/item/return-item/',{ id: $(this).data('item_id') }, function () {
                        modal.find('form').submit(function (event) {
                            $.post('/item/return', $(this).serialize()).done(function (data) {
                                alert(data.message);
                                if(data.status=='Ok'){
                                    modal.modal('hide');
                                }
                            });
                            event.preventDefault();
                        });
                    });
                });
                $('.pagination').find('li').click(function () {
                    modalEvents(button, modal, $(this).data('pagenumber'));
                });
            });
{'fraction_non_alphanumeric': 0.16044681391216045, 'fraction_numerical': 0.000676990776000677, 'mean_word_length': 1.0707902575784125, 'pattern_counts': {'":': 10, '<': 5, '<?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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5187888', 'n_tokens_mistral': 2722, 'n_tokens_neox': 2600, 'n_words': 360}