PageSourceSearch

https://www.hanbi-hotelsupplies.com/assets/js/unit/global-search.js

js hanbi-hotelsupplies.com collected 2026-10-08 16:22:18 UTC 953 bytes, 37 lines download raw bytes

1class ScriptGlobalSearch extends Script {
2	constructor(params) {
3		super(params)
4		this.attrId = params.attrId
5		this.sortList = JSON.parse(params.sortList || '[]')
6		this.kwinput = null
7	}
8
9	async init() {
10		let attrId = this.attrId
11		let searchBtn = document.querySelector(`#${attrId} .btnSearch`)
12		let sortType = this.sortList.reduce((acc, item) => {
13			if (item.show) {
14				acc.push(item.type_id)
15			}
16			return acc
17		}, [])
18		this.kwinput = document.querySelector(`#${attrId} .form-control`);
19		let toSearch = () => {
20			let keyword = this.kwinput.value
21			if (keyword) {
22				window.location.href = `/search.html?keyword=${encodeURIComponent(keyword)}${sortType.length ? `&sortType=${sortType.join()}` : ''}`
23			}
24		}
25		if (searchBtn) {
26			searchBtn.onclick = function () {
27				toSearch()
28			}
29		}
30		// 监听按键事件
31		this.kwinput.addEventListener('keydown', function (event) {
32			if (event.key === 'Enter') {
33				toSearch()
34			}
35		});
36	}
37}

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.