-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_line.js
30 lines (27 loc) · 990 Bytes
/
upload_line.js
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
//Adds File Name to Line Next to Upload Button
var fileInputTextDiv = document.getElementById('file_input_text_div');
var fileInput = document.getElementById('file_input_file');
var fileInputText = document.getElementById('file_input_text');
fileInput.addEventListener('change', changeInputText);
fileInput.addEventListener('change', changeState);
function changeInputText() {
var str = fileInput.value;
var i;
if (str.lastIndexOf('\\')) {
i = str.lastIndexOf('\\') + 1;
} else if (str.lastIndexOf('/')) {
i = str.lastIndexOf('/') + 1;
}
fileInputText.value = str.slice(i, str.length);
}
function changeState() {
if (fileInputText.value.length != 0) {
if (!fileInputTextDiv.classList.contains("is-focused")) {
fileInputTextDiv.classList.add('is-focused');
}
} else {
if (fileInputTextDiv.classList.contains("is-focused")) {
fileInputTextDiv.classList.remove('is-focused');
}
}
}