PageSourceSearch

https://nagt.org/scripts/local/search.js

js nagt.org collected 2026-10-01 10:33:39 UTC 2,616 bytes, 56 lines download raw bytes

1window.addEventListener('DOMContentLoaded', (event) => {
2	Array.from( document.querySelectorAll(".searchbox")).map(function (form_node){
3		let node_data= [];
4		node_data["formNode"] = form_node;
5		node_data["selectNode"] = node_data["formNode"].querySelectorAll("select")[0];
6		let hidden_selects_elements = node_data.formNode.querySelectorAll("select.hidden-select")[0];
7		let search_radio_button_elements =  Array.from(node_data.formNode.querySelectorAll(".search-radio-buttons input[type=radio]"));
8		hidden_selects_elements.addEventListener("change", function(e){
9			node_data = on_change_select(node_data);
10		});
11		search_radio_button_elements.map( function(button_element){
12			button_element.addEventListener("click", function(e){
13				let input = e.target;
14				let value = input.getAttribute("value");
15				// Find & select the parallel menu option
16				let menuOption = node_data.formNode.querySelectorAll("select.hidden-select option[value='" + value + "']")[0];
17				menuOption.selected = 'selected';
18				node_data = on_change_select(node_data);
19			});
20		});
21	});
22});
23
24function on_change_select(node_data){
25	let selected_option = node_data.selectNode.options[node_data.selectNode.selectedIndex];
26	let current_source_text = selected_option.text;
27	let search_nav_container = node_data.formNode.querySelectorAll(".search-nav")[0];
28	// Update visible select node's text
29	//let text_target = search_nav_container.querySelectorAll(".visible-text .text")[0];
30	//text_target.innerHTML = current_source_text;
31	// Update form node's action url
32	let full_url = selected_option.getAttribute("value");
33	//remove any hidden fields related to GET string from pre-existing selections (with class search-get-string )
34	Array.from(node_data.formNode.querySelectorAll(".search-get-string")).map(function(element){
35		element.remove();
36	});
37	if (full_url.indexOf('?') !== -1) {
38		//if we have a GET string we need to move that into hidden fields
39		let get_string = full_url.substring(full_url.indexOf("?") + 1, full_url.length);
40		let query_object  = new URLSearchParams(get_string);
41		for (const p of query_object) {
42			let key = p[0];
43			let vals = p[1];
44			let input_element = document.createElement("INPUT");
45			input_element.setAttribute("type", "hidden");
46			input_element.setAttribute("class", 'search-get-string');
47			input_element.setAttribute("name", key);
48			input_element.setAttribute("value", vals);
49			node_data.formNode.appendChild(input_element);
50		}
51		full_url = full_url.substring(0, full_url.indexOf("?"));
52	}
53	node_data.formNode.setAttribute('action',full_url );
54	// return updated node data
55	return node_data;
56}

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.