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
|
<script type="text/javascript">
function row_head_click_event(event) {
check = false;
current = event.target;
while (current != null) {
if (current.nodeName == 'TABLE') {
break;
}
if (current.nodeName == 'TR') {
check = !current.children[0].children[0].checked;
current.children[0].children[0].checked = check;
}
current = current.parentNode;
}
lines = current.children[1].children
for (i = 0; i < lines.length; i++) {
select_row(event, lines[i], lines[i].children[0].children[0], check);
}
}
function row_click_event(event) {
if (event.target.nodeName == 'INPUT') {
return;
}
current = event.target;
while (current = current.parentNode) {
if (current.nodeName == 'BODY') {
break;
}
if (current.nodeName != 'TR') {
continue;
}
e = current.children[0].children[0];
check = !e.checked;
select_row(event, current, e, check);
break;
}
}
function select_row(event, row, input, check) {
if (input != event.target) {
input.checked = check;
}
if (input.checked) {
row.classList.add("selected");
} else {
row.classList.remove("selected");
}
input.focus();
}
for (selector of ['thead > tr', 'thead input']) {
els = document.querySelectorAll(selector);
for (i = 0; i < els.length; i++) {
els[i].addEventListener('click', {handleEvent: row_head_click_event});
}
}
for (selector of ['tbody > tr', 'tbody input']) {
els = document.querySelectorAll(selector);
for (i = 0; i < els.length; i++) {
els[i].addEventListener('click', {handleEvent: row_click_event});
}
}
butt = document.querySelectorAll('button[type=button][name=create_check]');
for (i = 0; i < butt.length; i++) {
butt[i].addEventListener('click', {handleEvent: function(event){
cur = document.querySelector('#create_check').style.display;
console.log("meh: " + cur);
if (cur == 'block') {
document.querySelector('#create_check').style.display = 'none';
} else {
document.querySelector('#create_check').style.display = 'block';
}
}});
}
</script>
</body>
</html>
|