summaryrefslogtreecommitdiffhomepage
path: root/libs/cbi/htdocs/luci-static/resources/cbi.js
blob: 3abc3a9f521c58ef6aa94f2e571adbce52a272b9 (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
var cbi_d = {};

function cbi_d_add(field, target, value) {
	if (!cbi_d[target]) {
		cbi_d[target] = {};
	}
	if (!cbi_d[target][value]) {
		cbi_d[target][value] = [];
	}
	cbi_d[target][value].push(field);
}

function cbi_d_update(target) {
	if (!cbi_d[target]) {
		return;
	}
	
	for (var x in cbi_d[target]) {
		for (var i=0; i<cbi_d[target][x].length; i++) {	
			var y = document.getElementById(cbi_d[target][x][i])	
			y.style.display = "none";
		}
	}
	
	var t = document.getElementById(target);
	if (t && t.value && cbi_d[target][t.value]) {
		for (var i=0; i<cbi_d[target][t.value].length; i++) {			
			var y = document.getElementById(cbi_d[target][t.value][i])
			y.style.display = "block";
		}
	}
}

function cbi_d_init() {
	for (var x in cbi_d) {
		cbi_d_update(x);
	}
}