'; } html = html +'
' if(categories_html) { html = html + '
category
'; html = html + category_html; } if (html_hint) { html = html + '
search suggestion
'; html = html + hint_html; } if (html_parts) { html = html + '
Product number
'; html = html + 部分 html; } if (pages_html) { html = html + '
number of pages
'; html = html + páginas_html; } if(documentos_html) { html = html + '
product documentation
'; html = html + documentos_html; } html = html + '
'; html = html + '
'; return html; }/*, standard: function (response) { // return html result of standard result}*/ } }); $('.ui.two-column') .search({ type : 'category ', fields: { categories : 'results', // category array (category view) categoryName : 'name', // category name category (category view) categoryResults: 'results', // result array (category view) description: 'description', // result description image: 'image', // result image price: 'price', // result price results : 'results', // result array (standard) title : 'title', // result title action : 'action', // object name "see more" actionText : 'text', // text "see more" actionURL : 'url' // "see more" url }, onSearchQuery:function(query ){ console.debug(query); return query+'ordered_product='+document.getElementById( "ordered_product").checked; }, minCharacters : 2, apiSettings: { onResponse: function(search_results) { console.log(search_results); return search_results; }, url: 'searchsuggest_responsive.php?q={query}' }, templates: { /*escape: function(string) { // Return the escaped string for injected results}, message: function (message, type) { // returns html for given message and type },*/ category: function ( response) { // returns html for category results // console.log(response.results.products.results); // alert('here'); // console log(response); var products_html = get_products_html(answer.results.products.results, true); var ordered_products_html = get_ordered_products_html(response.results.products_ordered.results, true); var suggestion_html = get_suggestion_html(response.results.search_suggestions.results, true); var html_categories = get_html_categories(response.results.categories.results, true); var parts_html = get_parts_model_html(response.results.products_parts.results, true); var html_documents = get_html_documents (response.results.products_documents.results, true); var pages_html = get_pages_html(response.results.cms_pages.results, true); var html = ''; html = html + '
'; html = html + '
' si (productos_html) { html = html + '
product
'; html = html + 产品_html; } if(products_orders_html&&guest===0) { html = html + '
bought before
'; html = html + products_orders_html; } html = html + '
'; html = html +'
' if(categories_html) { html = html + '
category
'; html = html + category_html; } if (html_hint) { html = html + '
search suggestion
'; html = html + hint_html; } if (html_parts) { html = html + '
Product number
'; html = html + 部分 html; } if (pages_html) { html = html + '
number of pages
'; html = html + páginas_html; } if(documentos_html) { html = html + '
product documentation
'; html = html + documentos_html; } html = html + '
'; html = html + '
'; return html; }/*, standard: function (response) { // return html result of standard result}*/ } }); $('.ui.three-columns') .search({ type : 'category ', cache:false, fields: { categories : 'results', // category array (category view) categoryName : 'name', // category name (category view) categoryResults : 'results', // result array (category view ) description : 'description', // result description image : 'image', // image price of result : 'price', // result price results: 'results', // result array (standard) title: 'title' , // result title action: 'action', // "View More" object name textAction: 'text', // "View More" text actionURL : 'url' // "View More" url }, minCharacters : 2, apiSettings : { onResponse: function(search_results) { if(document.getElementById("ordered_product" ).checked){ search_results.results.products.results = [];search_results.results.search_suggestions.results = [];search_results .results.categories.results = [];search_results.results.products_parts.results = []; search_results.results.products_documents.results = [];search_results.results.cms_pages.results = []; } /*console.log( search_results.results.products.results); $.each(search_results.results.products.results, function(index, item) { console.log(index); console.log(item); });*/ return search_results; }, url: 'searchsuggest_responsive.php?q={query}' }, templates : { /*escape: function(string) { // returns the escaped string of the injected result}, message: function(message, type) { // return the html of the message with the given message and write to },*/category: function(response) { // return the html result of the category result //console.log(response.results.products.results);/ /alert('here'); //console log(response); var products_html = get_products_html(response.results.products.results, !document.getElementById("ordered_product").checked); var ordered_products_html = get_ordered_products_html(response. results.products_ordered.results, true); var suggestion_html = get_suggestion_html(response.results.search_suggestions.results, !document.getElementById("ordered_product").checked); var categories_html = get_categories_html(response.results.cat egories.results, !document. getElementById("ordered_product").checked); var parts_html = get_parts_model_html(response.results.products_parts.results, !document.getElementById("ordered_product").checked); var documents_html = get_documents_html(response.result s.products_documents.results, ! document.getElementById("ordered_product").checked); var pages_html = get_pages_html(response.results.cms_pages.results, !document.getElementById("ordered_product").checked); var html = ''; html = html + '
'; html = html + '
' si (productos_html) { html = html + '
product
'; html = html + 产品_html; } if(products_orders_html&&guest===0) { html = html + '
bought before
'; html = html + products_orders_html; } html = html + '
'; html = html +'
' if(categories_html) { html = html + '
category
'; html = html + category_html; } if (html_hint) { html = html + '
search suggestion
'; html = html + suggestion_html; } if (pages_html) { html = html + '
number of pages
'; html = html + páginas_html; } if(documentos_html) { html = html + '
product documentation
'; html = html + documentos_html; } html = html + '
'; html = html +'
' si (partes_html) { html = html + '
Product number
'; html = html + partes_html; } html = html + '
'; html = html + '
'; return html; }/*, standard: function (response) { // return html result of standard result}*/ } }); // find function function get_products_html(products, return_empty=false){ var products_html = '' ; if(products.length && Array.isArray(products)){ $.each(products, function(index, item) { if(index >= 10) { console.log(index); return false; } products_html = products_html + '
'; /*product_html = product_html + '
';product_html = product_html + ''+image.item+'';product_html = product_html + '
';*/ products_html = products_html + '
';product_html = product_html + '
'+element.title+'';product_html = product_html + '
'+item.description+'
';product_html = product_html + '
';product_html = product_html + '
'; }); }else if(return_empty){ products_html = products_html + '
There are no products matching your search criteria
'; } devolver productos_html; } function get_ordered_products_html(products, return_empty=false){ var products_html = ''; if(products.length && Array.isArray(products)){ $.each(products, function(index, item) { if(index >= 10) { console.log(index); return false; } products_html = products_html + '
'; /*product_html = product_html + '
';product_html = product_html + ''+image.item+'';product_html = product_html + '
';*/ products_html = products_html + '
';product_html = product_html + '
'+element.title+'';product_html = product_html + '
'+item.description+'
';product_html = product_html + '
';product_html = product_html + '
'; }); }else if(return_empty){ products_html = products_html + '
There are no products matching your search criteria
'; } 返回 products_html; } function get_suggestion_html(suggestions, return_empty=false){ var suggestions_html = ''; if(hints.length && Array.isArray(hints)){ $.each(hints, function(index, item) { if(index >= 10) { console.log(index); 返回 false; } html_hints = html_hints + '
'; suggestions_html = suggestions_html + '
'; suggestions_html = suggestions_html + '
'+element.title+''; suggestions_html = suggestions_html + '
'; suggestions_html = suggestions_html + '
'; }); }else if(return_empty){ hints_html = hints_html + '
No search suggestions matching your search criteria
'; } devuelve sugerencias_html; } function get_categories_html(categories, return_empty=false){ varcategories_html = ''; if(categories.length && Array.isArray(categories)) { $.each(categories, function (index, item) { console.log(item.image); categorias_html = categorias_html + '
'; html_category = html_category + '
'; html_category = html_category + '
' + element.title + ''; html_category = html_category + '
'; html_category = html_category + '
'; }); }else if(return_empty){ categories_html = categories_html + '
No categories matched your search criteria
'; } 返回 categories_html; } function get_parts_model_html(hints, return_empty=false){ var hints_html = ''; if(hints.length && Array.isArray(hints)){ $.each(hints, function(index, item) { if(index >= 10) { console.log(index); 返回 false; } html_hints = html_hints + '
'; suggestions_html = suggestions_html + '
'; suggestions_html = suggestions_html + '
'; suggestions_html = suggestions_html + '
'; suggestions_html = suggestions_html + '
'; }); }else if(return_empty){ hints_html = hints_html + '
There are no products matching your search criteria
'; } 返回 hints_html; } function get_documents_html(hints, return_empty=false){ var hints_html = ''; if(hints.length && Array.isArray(hints)){ $.each(hints, function(index, item) { if(index >= 10) { console.log(index); 返回 false; } html_hints = html_hints + '
'; suggestions_html = suggestions_html + '
'; suggestions_html = suggestions_html + '
'+element.title+''; suggestions_html = suggestions_html + '
'; suggestions_html = suggestions_html + '
'; }); }else if(return_empty){ hints_html = hints_html + '
No product documents matching your search criteria
'; } 返回 hints_html; } function get_pages_html(hints, return_empty=false){ var hints_html = ''; if(hints.length && Array.isArray(hints)){ $.each(hints, function(index, item) { if(index >= 10) { console.log(index); 返回 false; } html_hints = html_hints + '
'; suggestions_html = suggestions_html + '
'; suggestions_html = suggestions_html + '
'+element.title+''; suggestions_html = suggestions_html + '
'; suggestions_html = suggestions_html + '
'; }); }else if(return_empty){ hints_html = hints_html + '
No pages matching your search criteria
'; } return hints_html; } });