jQuery(document).ready(function (e) { jQuery('#search').on('keyup', function (e) { var productDesk = jQuery('#modulesDesk .modulesDeskContent'), catDesk = jQuery('#categoriesDesk'), word = jQuery(this).val(), desk = jQuery('.containerLiveSearchDesk'); if (word === '') { jQuery('#modulesDesk .modulesDeskContent').html(''); jQuery('#categoriesDesk').html(''); return; } productDesk.html(''); catDesk.html(''); //desk.addClass('hidden'); //desk.addClass('visuallyhidden'); if (word.length > 3) { addProducts(word); /* addCategories(word); */ // desk.removeClass('hidden'); // setTimeout(function () { // desk.removeClass('visuallyhidden'); // }, 20); } }); jQuery(document).on({ mouseenter: function () { jQuery(this).find('.mini-search-info').css('color', '#FF6600'); }, mouseleave: function () { jQuery(this).find('.mini-search-info').css('color', '#666'); } }, "#modulesDesk .modulesDeskContent .mini-search-product"); }); function addProducts(word) { /*var images = 'https://download.truper.com/imgTel/ch/';*/ var images = 'https://www.truper.com/admin/images/ch/'; var dataSheet = 'https://www.truper.com/ficha_jasp/index.php?codigo='; var modules = 'https://www.truper.com/CatVigente/img/modulos/'; var output = ''; var i = 0; jQuery.ajax({ type: "POST", cache: false, url: "https://www.truper.com/restLiveSearch/api-fix/products/searchByWord.php", //url: "https://www.truper.com/restLiveSearchCatalog/api/products/searchByWordFix.php", dataType: "json", data: {'word': word}, ContentType: "application/json", success: function (response) { /* PRODUCTS*/ jQuery.each(response.data, function (key, val) { if (i >= 10) { return false; } var lengthWord = word.length; var match = val.pn.substring(0, lengthWord); var leftOver = val.pn.substring(lengthWord); var url = images + val.codigo + '.jpg'; var product_link = val.url; var replace = ''; var is_new = (val.is_new == 1) ? '