summaryrefslogtreecommitdiff
blob: 7c1b13e9753594fc8cfb52c4348fa533b36ab723 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var wlca_last_search;
var wlca_search_timeout;
var wlca_found_last;
function wlcat(id, set) { // Short for 'toggle'
	tag=document.getElementById(id);
	for (var i=1; i<tag.childNodes.length; i++) {
		if (tag.childNodes[i].className && tag.childNodes[i].className.indexOf('wlcae') != -1) {
			if (typeof(set) == 'undefined') {
				set=tag.childNodes[i].style.display=="none"?"":"none";
			}
			tag.childNodes[i].style.display=set;
		}
	}
}
function wlca_expand(id) {
	wlcat(id, "");
}
function wlca_collapse(id) {
	wlcat(id, "none");
}
function wlca_search(q, el, depth, maxdepth, t) {
	if (!t) {
		clearTimeout(wlca_search_timeout);
		wlca_search_timeout=setTimeout(function () {wlca_found_last=wlca_search(q, el, depth, maxdepth, true)}, 300);
		return;
	}
	if (depth == 0) {
		if (q == wlca_last_search) return wlca_found_last;
		if (wlca_found_last == 0 && q.indexOf(wlca_last_search) != -1) {
			debug('wlca', 'Already had no results, not searching "'+q+'"');
			return 0;
		}
		wlca_last_search=q;
		debug('wlca', 'Searching "'+q+'"');
	}
	var found=0;
	for (var i=0; i<el.childNodes.length; i++) {
		if (el.childNodes[i].nodeName == "LABEL" || (el.childNodes[i].className && el.childNodes[i].className.indexOf('wlcal') != -1)) {
			found+=(el.childNodes[i].innerHTML.indexOf(q) == -1?0:1);
			break;
		}
	}
	if (depth < maxdepth) {
		for (var i=0; i<el.childNodes.length; i++) {
			if (!(el.childNodes[i].className && el.childNodes[i].className.indexOf('wlcae') != -1)) continue;
			var lfound=wlca_search(q, el.childNodes[i], depth+1, maxdepth, true);
			found+=lfound;
			el.childNodes[i].style.display=(q.length == 0 || lfound > 0?"":"none");
		}
		if (q.length == 0 && el.className.indexOf('wlcac') != -1) {
			wlca_collapse(el.id);
		}
	}
	if (depth == 0) {
		el.childNodes[el.childNodes.length-1].style.display=found?"none":"";
	}
	return found;
}
function wlca_show_checked(el, depth, maxdepth) {
	if (depth == 0) {
		wlca_last_search=undefined;
	}
	var found=0;
	for (var i=0; i<el.childNodes.length; i++) {
		if (el.childNodes[i].nodeName == "INPUT" && el.childNodes[i].type == "checkbox" && el.childNodes[i].checked) {
			found++;
		}
		if (depth < maxdepth) {
			if (!(el.childNodes[i].className && el.childNodes[i].className.indexOf('wlcae') != -1)) continue;
			var lfound=wlca_show_checked(el.childNodes[i], depth+1, maxdepth);
			found+=lfound;
			el.childNodes[i].style.display=(lfound > 0?"":"none");
		}
	}
	if (depth == 0) {
		el.childNodes[el.childNodes.length-1].style.display=found?"none":"";
	}
	return found;
}