blob: 3823af03291a6982d1a2b67942c90705263517f8 (
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
|
document.onpaste = () => {
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
for (index in items) {
var item = items[index];
if (item.kind === 'file') {
file = item.getAsFile();
showFile(file);
}
}
};
function showFile(file) {
setFormDetailsVisiblity(file != null);
if (file == null) {
fileUploadWrapper.innerHTML = '<h1>Click, drop, or paste files here</h1>';
if (fileURLWrapper) {
fileURLWrapper.style.display = 'flex';
}
} else {
if (file.length == 1) {
fileUploadWrapper.innerHTML = `<h1>File: ${file[0].name}</h1>`;
} else {
fileUploadWrapper.innerHTML = `<h1>Selected ${file.length} files</h1>`;
}
if (fileURLWrapper) {
fileURLWrapper.style.display = 'none';
}
}
}
function setFormDetailsVisiblity(show) {
formDetails.style.display = show ? 'flex' : 'none';
formSubmitButton.style.display = show ? 'block' : 'none';
}
function showUploadType(type) {
if (formTabs.hasAttribute('disabled')) {
return;
}
document.getElementById('form-upload-wrapper').style.display = type == 'file' ? 'flex' : 'none';
document.getElementById('form-text-upload').style.display = type == 'text' ? 'flex' : 'none';
document.getElementById('form-record-upload').style.display = type === 'audio' ? 'flex' : 'none';
const tabs = document.querySelectorAll('.form-upload-tab');
for (const tab of tabs) {
if (tab.getAttribute('id') == `form-tab-${type}`) {
tab.classList.remove('disabled');
} else {
tab.classList.add('disabled');
}
}
}
|