summaryrefslogtreecommitdiff
path: root/public/static/scripts/form.js
blob: 6e4f608f9bfdcf56073d71dd6040a30d1151da50 (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
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 {
        fileUploadWrapper.innerHTML = `<h1>File: ${file.name}</h1>`;
        
        if (fileURLWrapper) {
            fileURLWrapper.style.display = 'none';
        }
    }
}