PageSourceSearch

https://static-www.echemi.com/static_v3/js/common/defaultSearch_v2ef651.js

js echemi.com collected 2026-10-02 04:33:41 UTC 3,384 bytes, 90 lines download raw bytes

1// var defaultKeywords = ["Phosphoric Acid", "Caustic Soda", "Sodium Tripolyphosphate", "Xanthan Gum", "Sodium Benzoate", "Benzoic acid", "Adipic Acid", "Sodium Nitrite", "Citric Acid Monohydrate", "Pentaerythritol"];
2
3//Enter13 Shift16 Ctrl17 Alt18 CapsLock20 左37 上38 右39 下40
4var keyCodes = [13,16,17,18,20,37,38,39,40];
5
6//按键按下
7function searchKeywordsOnKeypress(keyCode, associativeKeywordsDivId, callBack) {
8	if (keyCodes.indexOf(keyCode)==-1){
9		$("#" + associativeKeywordsDivId + ">ul").empty();
10	}else if (keyCode == 13){
11		//回车键按下,搜索
12		if (typeof(callBack) != "undefined" && callBack != null && callBack != ""){
13			callBack();
14		}
15	}
16}
17
18//按键松开
19function searchKeywordsOnKeyup(keyCode, associativeKeywordsDivId, searchKeywordsId, searchItemId) {
20	if (keyCodes.indexOf(keyCode)==-1){
21		$("#" + associativeKeywordsDivId + ">ul").empty();
22		//获取搜索联想词
23		var searchItem = $("#" + searchItemId).val();
24		getAssociativeKeywords(associativeKeywordsDivId, searchKeywordsId, searchItem);
25	}
26}
27
28//搜索框获得焦点
29function searchKeywordsOnFocus(associativeKeywordsDivId, searchKeywordsId, searchItemId) {
30	var associativeKeywordsCount = $("#" + associativeKeywordsDivId + ">ul li").length;
31	if (associativeKeywordsCount > 0) {
32		//联想词展示
33		$("#" + associativeKeywordsDivId).show();
34	}else{
35		//获取搜索联想词
36		var searchItem = $("#" + searchItemId).val();
37		getAssociativeKeywords(associativeKeywordsDivId, searchKeywordsId, searchItem);
38	}
39}
40
41//搜索框失去焦点
42function searchKeywordsOnBlur(associativeKeywordsDivId) {
43	setTimeout(function(){
44		$("#" + associativeKeywordsDivId).hide();
45	},200)
46}
47
48//获取搜索联想词
49function getAssociativeKeywords(associativeKeywordsDivId, searchKeywordsId, searchItem) {
50	var searchKeywords = $("#" + searchKeywordsId).val();
51	if (searchKeywords!=null && searchKeywords!=""){
52		$.ajax({
53			url: webRootAjax + "/common/getAssociativeKeywords.do",
54			type: "post",
55			data: {
56				searchKeywords : searchKeywords,
57				searchItem : searchItem
58			},
59			dataType: "json",
60			success: function (json) {
61				if(json.success){
62					$("#" + associativeKeywordsDivId + ">ul").empty();
63					var result = json.map;
64					var keywordsArray =result.associativeKeywordsList;
65					for (var i=0;i<keywordsArray.length;i++){
66						$("#" + associativeKeywordsDivId + ">ul").append("<li onclick='doTopSearch(\""+searchItem+"\", \""+keywordsArray[i]+"\");'>" + keywordsArray[i] + "</li>");
67					}
68					//联想词展示
69					$("#" + associativeKeywordsDivId).show();
70
71					//创建联想词点击事件
72					$("#" + associativeKeywordsDivId + ">ul>li").on("click",function(){
73						var content = $(this).text();
74						$("#" + searchKeywordsId).val(content);
75						$("#" + associativeKeywordsDivId + ">ul").empty();
76						$("#" + associativeKeywordsDivId + ">ul").append("<li onclick='doTopSearch(\""+searchItem+"\", \""+keywordsArray[i]+"\");'>" + content + "</li>");
77					})
78				}
79			}
80		});
81	}
82}
83
84//通用查询功能(页面的词直接发起搜索使用)
85function thisSearch(thisObj, searchItem) {
86	var searchKeywords = $(thisObj).text();
87	searchKeywords = searchKeywords.replace("<span>", "");
88	searchKeywords = searchKeywords.replace("</span>", "");
89	doTopSearch(searchItem, searchKeywords);
90}

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.