aboutsummaryrefslogtreecommitdiff
path: root/static/search.js
blob: 3ddd99bd17e713a870614cc8fc822dfe85877f58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function search() {

	var searchTerm = document.getElementById('searchfield').value;
	var searchableElements = document.getElementsByTagName('section');

	var regexMatch = new RegExp(searchTerm, "i");

	for(var i = 0; i < searchableElements.length; i++) {

		var textValue = searchableElements[i].getAttribute('data-ref');
		if(textValue != null) {

			if(textValue.match(regexMatch) == null && searchableElements[i].style.display != "none") {

				searchableElements[i].style.display = "none";

			} else if(textValue.match(regexMatch) != null) {

				searchableElements[i].style.display = "block";

			}

		}

	}

}