PageSourceSearch

https://www.compeve.com/includes/templates/mozen_temp/jscript/jscript_instantSearch.js

js compeve.com collected 2026-09-29 21:55:11 UTC 4,039 bytes, 105 lines download raw bytes

1var runningRequest = false;
2var request;
3var autoPosition = false;
4var inputboxCurrent;
5$(document).ready(function () {
6    var inputBox = $('input[name="keyword"]');
7	inputBox.before('<div class="resultsContainer"></div>');
8	inputBox.attr('autocomplete', 'off');
9	if (autoPosition == true){
10		inputBox.each(function (index) {
11			var offset = $(this).offset();
12			$(this).prev().css("left", offset.left + "px");
13			$(this).prev().css("top", ($(this).outerHeight(true) + offset.top) + "px");
14		});
15	}
16    inputBox.blur(function () {
17        if (inputboxCurrent) {
18            var resultsContainer = inputboxCurrent.prev();
19            resultsContainer.delay(300).slideUp(200);
20        }
21    });
22    inputBox.focus(function () {
23        if (inputboxCurrent) {
24            var resultsContainer = inputboxCurrent.prev();
25            resultsContainer.delay(300).slideDown(200);
26        }
27    });
28	$(window).resize(function() {
29        if (inputboxCurrent) {
30            var resultsContainer = inputboxCurrent.prev();
31            resultsContainer.hide();
32        }
33	});
34    inputBox.keyup(function () {
35        inputboxCurrent = $(this);
36        var resultsContainer = $(this).prev();
37        var searchWord = $(this).val();
38		var replaceWord = searchWord;
39        searchWord = searchWord.replace(/^\s+/, "");
40        searchWord = searchWord.replace(/  +/g, ' ');
41        if (searchWord == "") {
42            resultsContainer.hide();
43        } else {
44            if (runningRequest) {request.abort();}
45            runningRequest = true;
46            request = $.getJSON('pzen_searches.php', {query: searchWord}, function (data) {
47                if (data.length > 0) {
48                    var resultHtml = '';
49                    $.each(data, function (i, item) {
50                        resultHtml += '<li><a href="' + generateLink(item.pc,item.l) + '">' + '<div class="image">' + item.img + '</div><div class="desc"><span class="product-name">' + highlightWord(replaceWord,item.q) + '</span>' + item.pm + '<span class="product-price price-box">' + formatNumber(item.c) + '</span></div></a></li>';
51                    });
52                    resultsContainer.html('<ul>'+resultHtml+'</ul>');
53                    if (!resultsContainer.is(':visible')) {
54						if (autoPosition == true){
55							autoPositionContainer(inputboxCurrent, resultsContainer);
56						}
57                        resultsContainer.slideDown(100);
58                    }
59                } else {
60                    resultsContainer.hide();
61                }
62
63                runningRequest = false;
64            });
65        }
66    });
67});
68function autoPositionContainer(inputBoxCurr, resltsContainer){
69	var offsetInput = inputBoxCurr.offset();
70	var overFlow = offsetInput.left + resltsContainer.outerWidth(true);
71	var winWidth = $(document).width();
72	
73	if (overFlow > winWidth){ // this checks to see if the container overflows on the right of the window
74		var dif = overFlow - winWidth;
75		
76		if ((offsetInput.left - dif) < 0){// this checks to see if the container overflows on the left of the window
77			resltsContainer.css("left", 0 + "px");
78		}else{
79			resltsContainer.css("left", (offsetInput.left - dif) + "px");
80		}
81	}else{
82		resltsContainer.css("left", offsetInput.left + "px");
83	}
84	resltsContainer.css("top", (inputBoxCurr.outerHeight(true) + offsetInput.top) + "px");
85}
86function generateLink(productORcategory, productCategoryID){
87	var l = "";
88	if (productORcategory == "p"){
89		l = "index.php?main_page=product_info&products_id=" + productCategoryID;
90	}else{
91		l = "index.php?main_page=index&cPath=" + productCategoryID;
92	}
93	return l;
94
95}
96function highlightWord(findTxt,replaceTxt){
97	var f = findTxt.toLowerCase();
98	var r = replaceTxt.toLowerCase();
99	var regex = new RegExp('(' + f + ')', 'i');
100	return r.replace(regex, '<span class="thinFont color">' + f + '</span>')
101	
102}
103function formatNumber(num){
104	return num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
105}

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.