PageSourceSearch

https://joycelong.com/en/js/a.whir.search.js

js joycelong.com collected 2026-10-04 18:20:29 UTC 6,739 bytes, 172 lines download raw bytes

1;(function($){
2$.fn.jqSearch = function (options) {	
3    var defaults = {
4        TxtVal: "输入关键词搜索!",
5        KeyTxt1: "输入关键词搜索!",
6        KeyTxt2: "输入的关键词字数不要过多!",
7        KeyTxt3: "您输入的内容存在特殊字符!",
8        KeyId: "topkey",
9        KeyUrl: "#",
10        OtherUrl: "",
11        OtherParams: "",
12        OtherTxtVal: "请选中筛选或输入关键词搜索!",
13        KeyHref: "key",
14        Static: false
15    };
16    var opts = $.extend(defaults, options);
17
18    return this.each(function () {
19        _this = $(this);
20        if ($("#" + opts.KeyId).val() == "") {
21            $("#" + opts.KeyId).val(opts.TxtVal);
22        }
23        $("#" + opts.KeyId).focus(function () {
24        	_this.addClass("focus");
25        	$(this).addClass("focus");
26            if ($(this).val() == opts.TxtVal) {
27                $(this).val("");
28            }
29        });
30        $("#" + opts.KeyId).blur(function () {
31        	_this.removeClass("focus");
32        	$(this).removeClass("focus");
33            if ($(this).val() == "") {
34                $(this).val(opts.TxtVal);
35            }
36        });
37        function GoSearchUrl() {
38            var searchinput = document.getElementById(opts.KeyId);
39            var isNull = true;
40            //静态
41            var Staticlinks = opts.KeyUrl;
42            if (typeof (opts.OtherParams) == "function") {
43                var params = opts.OtherParams();
44                for (var property in params) {
45                    isNull = false;
46                    if (opts.Static) {
47                        Staticurl += "_" + property + "_" + params[property];
48                    } else {
49                        if (opts.OtherUrl != "") {
50                            opts.OtherUrl = appendUrlParmFun(opts.OtherUrl, property, params[property]);
51                        } else {
52                            opts.KeyUrl = appendUrlParmFun(opts.KeyUrl, property, params[property]);
53                        }
54                    }
55                }
56            }
57            if (typeof (opts.OtherParams) == "function" && isNull && (searchinput.value == "" || searchinput.value == opts.TxtVal)) {
58                alert(opts.OtherTxtVal);
59                return false;
60            }
61            if (!isNull && opts.OtherUrl != "") {
62                window.location = opts.OtherUrl;
63                return false;
64            }
65            if (isNull && (searchinput.value == "" || searchinput.value == opts.TxtVal)) {
66                alert(opts.KeyTxt1);
67                searchinput.focus();
68                return false;
69            }
70            if (isNull && (searchinput.value == "" || searchinput.value == opts.TxtVal)) {
71                alert(opts.KeyTxt1);
72                searchinput.focus();
73                return false;
74            }
75            if (searchinput.value.length > 50) {
76                alert(opts.KeyTxt2);
77                searchinput.focus();
78                return false;
79            }
80            var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()—|{}【】‘;:”“'。,、?]");
81            if (pattern.test(searchinput.value)) {
82                alert(opts.KeyTxt3);
83                searchinput.focus();
84                return false;
85            }
86            if (!(searchinput.value == "" || searchinput.value == opts.TxtVal)) {
87                if (opts.Static) {
88                    //静态
89                    Staticlinks = opts.KeyUrl;
90                    Staticurl = "_" + opts.KeyHref + "_" + searchinput.value + ".html"
91                    Staticlinks = Staticlinks.replace(".html", Staticurl);
92                    window.location = Staticlinks;
93                } else {
94                    //动态
95                    if (opts.KeyUrl.indexOf("?") == -1) {
96                        window.location = opts.KeyUrl + "?" + opts.KeyHref + "=" + escape(searchinput.value);
97
98                    } else {
99                        window.location = opts.KeyUrl + "&" + opts.KeyHref + "=" + escape(searchinput.value);
100                    }
101                }
102            } else {
103                if (opts.Static) {
104                    window.location = Staticlinks;
105                }
106                else {
107                    window.location = opts.KeyUrl;
108                }
109            }
110
111            return true;
112        }
113
114        function entersearch() {
115            var event = window.event || arguments.callee.caller.arguments[0];
116            if (event.keyCode == 13) {
117                GoSearchUrl();
118            }
119        }
120
121        function checkComments() {
122            var event = window.event || arguments.callee.caller.arguments[0];
123            if ((event.keyCode > 32 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97)) {
124                event.returnValue = false;
125            }
126        }
127
128        function stripscript(s) {
129            var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()&mdash;—|{}【】‘;:”“'。,、?]");
130            var rs = "";
131            for (var i = 0; i < s.length; i++) {
132                rs = rs + s.substr(i, 1).replace(pattern, '');
133            }
134            return rs;
135        }
136
137        function appendUrlParmFun(url, key, value) {
138            var arrayParams = url.split("?");
139            var result = arrayParams[0] + "?";
140            if (url.indexOf("?") > 0) {
141                var parms = arrayParams[1].split("&");
142                var exsit = false;
143                for (var i = 0; i < parms.length; i++) {
144                    var param = parms[i].split("=");
145                    if (param[0] == key) {
146                        exsit = true;
147                        result += param[0] + "=" + value + "&"; //修改参数
148                    } else {
149                        result += param[0] + "=" + param[1] + "&"; //保持原样
150                    }
151                }
152                if (exsit == false) {
153                    result += key + "=" + value + "&"; //不存在时,附加参数
154                }
155
156            } else {
157                result += key + "=" + value;
158            }
159            result = result.substring(result.length - 1, result.length) == "&" ? result.substring(0, result.length - 1) : result;
160            return result;
161        }
162
163        _this.click(function () {
164            GoSearchUrl()
165        });
166
167        $("#" + opts.KeyId).keydown(function () {
168            entersearch()
169        });
170    })
171}
172})(jQuery);

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.