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) ? '
' : ''; /* loop through the codes associated to the module */ if (val.replace != "") { replace = '
'; jQuery.each(val.replace, function (key, item) { replace += '
SUSTITUYE A
' + item.old_code + ' | ' + item.old_sku + '
'; }); replace += '
'; } is_new = (replace == '') ? is_new : ''; output += '
'; output += '
'; output += '
'; output += '

' + match + '' + leftOver + '

'; output += '

' + val.codigo + '

'; output += '

' + val.clave + '

'; if (localStorage.getItem('fixil') != null && localStorage.getItem('fixil') === true) { if (localStorage.getItem('fixcg') != null && localStorage.getItem('fixcg') != '' && localStorage.getItem('fixcg') != '0') { switch (localStorage.getItem('fixcg')) { case '1': default: output += '

' + '$' + addCommas(val.precio_may_calculado) + '

'; break; case '4': case '5': output += '

' + '$' + addCommas(val.precio_dis_calculado) + '

'; break; } } else { output += '

' + '$' + addCommas(val.precio_may_calculado) + '

'; } } else { output += '

' + '$' + addCommas(val.precio_may_calculado) + '

'; } /* if (val.stock && val.stock == 0) { output += 'Agotado'; } */ output += '
' + is_new + '
'; output += '' + replace + ''; output += '
'; output += '
'; /* loop through the codes associated to the module */ ul = '