PageSourceSearch

http://nutsery.com/themes/PRS040092/js/modules/blocksearch/blocksearch.js

js nutsery.com collected 2026-10-07 17:00:18 UTC 3,726 bytes, 122 lines download raw bytes

1/*
2* 2007-2015 PrestaShop
3*
4* NOTICE OF LICENSE
5*
6* This source file is subject to the Academic Free License (AFL 3.0)
7* that is bundled with this package in the file LICENSE.txt.
8* It is also available through the world-wide-web at this URL:
9* http://opensource.org/licenses/afl-3.0.php
10* If you did not receive a copy of the license and are unable to
11* obtain it through the world-wide-web, please send an email
12* to [email protected] so we can send you a copy immediately.
13*
14* DISCLAIMER
15*
16* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
17* versions in the future. If you wish to customize PrestaShop for your
18* needs please refer to http://www.prestashop.com for more information.
19*
20*  @author PrestaShop SA <[email protected]>
21*  @copyright  2007-2015 PrestaShop SA
22*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
23*  International Registered Trademark & Property of PrestaShop SA
24*/
25
26var instantSearchQueries = [];
27$(document).ready(function()
28{
29	if (typeof blocksearch_type == 'undefined')
30		return;
31	if (typeof instantsearch != 'undefined' && instantsearch)		
32		$("#search_query_" + blocksearch_type).keyup(function(){
33			if($(this).val().length > 4)
34			{
35				stopInstantSearchQueries();
36				instantSearchQuery = $.ajax({
37					url: search_url + '?rand=' + new Date().getTime(),
38					data: {
39						instantSearch: 1,
40						id_lang: id_lang,
41						q: $(this).val()
42					},
43					dataType: 'html',
44					type: 'POST',
45					headers: { "cache-control": "no-cache" },
46					async: true,
47					cache: false,
48					success: function(data){
49						if($("#search_query_" + blocksearch_type).val().length > 0)
50						{
51							tryToCloseInstantSearch();
52							$('#center_column').attr('id', 'old_center_column');
53							$('#old_center_column').after('<div id="center_column" class="' + $('#old_center_column').attr('class') + '">'+data+'</div>');
54							$('#old_center_column').hide();
55							// Button override
56							ajaxCart.overrideButtonsInThePage();
57							$("#instant_search_results a.close").click(function() {
58								$("#search_query_" + blocksearch_type).val('');
59								return tryToCloseInstantSearch();
60							});
61							return false;
62						}
63						else
64							tryToCloseInstantSearch();
65					}
66				});
67				instantSearchQueries.push(instantSearchQuery);
68			}
69			else
70				tryToCloseInstantSearch();
71		});
72
73	/* TODO Ids aa blocksearch_type need to be removed*/
74	var width_ac_results = 	$("#search_query_" + blocksearch_type).parent('form').width();
75	if (typeof ajaxsearch != 'undefined' && ajaxsearch)
76		$("#search_query_" + blocksearch_type).autocomplete(
77			search_url,
78			{
79				minChars: 3,
80				max: 10,
81				width: (width_ac_results > 0 ? width_ac_results : 500),
82				selectFirst: false,
83				scroll: false,
84				dataType: "json",
85				formatItem: function(data, i, max, value, term) {
86					return value;
87				},
88				parse: function(data) {
89					var mytab = new Array();
90					for (var i = 0; i < data.length; i++)
91						mytab[mytab.length] = { data: data[i], value: data[i].cname + ' > ' + data[i].pname };
92					return mytab;
93				},
94				extraParams: {
95					ajaxSearch: 1,
96					id_lang: id_lang
97				}
98			}
99		)
100		.result(function(event, data, formatted) {
101			$('#search_query_' + blocksearch_type).val(data.pname);
102			document.location.href = data.product_link;
103		});
104});
105
106function tryToCloseInstantSearch()
107{
108	if ($('#old_center_column').length > 0)
109	{
110		$('#center_column').remove();
111		$('#old_center_column').attr('id', 'center_column');
112		$('#center_column').show();
113		return false;
114	}
115}
116
117function stopInstantSearchQueries()
118{
119	for(i=0;i<instantSearchQueries.length;i++)
120		instantSearchQueries[i].abort();
121	instantSearchQueries = new Array();
122}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.