summaryrefslogtreecommitdiffstats
path: root/public/media/js/user.js
blob: 15c3075d4eba6d120447994f2ce87223b18e9810 (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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
$(document).ready(function(){
	if($('.listelement .element').find('.dispnone').length >= 1){
		console.log($(this));
		$('.listelement .element').find('.dispnone').parent().find('.title')
				.css('cursor','pointer')
				.prepend("<span class='toggler'><img src='/media/img/right.png'></span> ")
				.data('toggle','0');
		
		$('.listelement .title').click(function(){
			$(this).siblings('.dispnone').toggle();
			if($(this).data('toggle') == '0'){
				$(this).data('toggle','1');
				$(this).find('.toggler img').attr('src','/media/img/down.png')
			}
			else{
				$(this).data('toggle','0');
				$(this).find('.toggler img').attr('src','/media/img/right.png')
			}
		});
	}
});

function checkAllCheckBoxes(exceptions) {
	var elements = document.getElementsByTagName('input');
	if(!elements) {
		return;
	}
	var countElements = elements.length;
	var countExceptions;
	if(exceptions) {
		countExceptions = exceptions.length;
	} else {
		countExceptions = 0;
	}
	var foundException = false;
	if(!countElements) {
		if(elements.getAttribute('type') == 'checkbox') {
			for(var j = 0; j < countExceptions; j++) {
				if(elements.getAttribute('name') == exceptions[j]) {
					foundException = true
					break;
				}
			}
			if(!foundException) {
				elements.checked = true;
			}
			foundException = false;
		}
	} else {
		for(var i = 0; i < countElements; i++) {
			if(elements[i].getAttribute('type') == 'checkbox') {
				for(var j = 0; j < countExceptions; j++) {
					if(elements[i].getAttribute('name') == exceptions[j]) {
						foundException = true
						break;
					}
				}
				if(!foundException) {
					elements[i].checked = true;
				}
				foundException = false;
			}
		}
	}
}

function uncheckAllCheckBoxes(exceptions) {
	var elements = document.getElementsByTagName('input');
	if(!elements) {
		return;
	}
	var countElements = elements.length;
	var countExceptions;
	if(exceptions) {
		countExceptions = exceptions.length;
	} else {
		countExceptions = 0;
	}
	var foundException = false;
	if(!countElements) {
		if(elements.getAttribute('type') == 'checkbox') {
			for(var j = 0; j < countExceptions; j++) {
				if(elements.getAttribute('name') == exceptions[j]) {
					foundException = true
					break;
				}
			}
			if(!foundException) {
				elements.checked = false;
			}
			foundException = false;
		}
	} else {
		for(var i = 0; i < countElements; i++) {
			if(elements[i].getAttribute('type') == 'checkbox') {
				for(var j = 0; j < countExceptions; j++) {
					if(elements[i].getAttribute('name') == exceptions[j]) {
						foundException = true
						break;
					}
				}
				if(!foundException) {
					elements[i].checked = false;
				}
				foundException = false;
			}
		}
	}
}