aboutsummaryrefslogtreecommitdiff
path: root/src/static/script.js
blob: 8c1bf516f30f50b651352c81ff53e42d86906797 (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
"use strict";
"use warnings";

function checkAll(checked, scope) {
	let inputs = scope.getElementsByTagName('input');
	for (var i = 0; i < inputs.length; i++) {
		if (inputs[i].type.toLowerCase() == 'checkbox') {
			inputs[i].checked = checked;
		}
	}
}

function toggleAll(checkbox) {
	let scope = document.getElementById('file-list')
	if (checkbox.checked) {
		checkAll(true, scope);
	} else {
		checkAll(false, scope);
	}
}

function deleteAction(button) {
	let table = document.getElementById('file-list')
	let tbody = table.getElementsByClassName('tbody')[0]
	let inputs = tbody.getElementsByTagName('input')
	let msg = 0;
	for (var i = 0; i < inputs.length; i++) {
		inputs[i].type.toLowerCase() == 'checkbox' &&
			inputs[i].checked && msg++;
	}
	if (msg == 0) {
		msg = "Whole Folder will be deleted."
	} else {
		msg += " file(s) selected."
	}
	if (confirm(msg + " Confirm Deletion?")) {
		button.formAction = "?action=delete";
		button.onclick = "submit()";
		button.click();
	}
}