Fix root directory uploads

This commit is contained in:
amcmanu3 2023-01-28 20:35:58 -05:00
parent e0541b1ec0
commit d31a0a0512

View File

@ -720,21 +720,32 @@
xmlHttpRequest.addEventListener('load', (event) => { xmlHttpRequest.addEventListener('load', (event) => {
if (event.target.responseText == 'success') { if (event.target.responseText == 'success') {
console.log('Upload for file', file.name, 'was successful!'); console.log('Upload for file', file.name, 'was successful!');
par_el = document.getElementById(path + "ul"); let caught = false;
try {
var par_el = document.getElementById(path + "ul");
var items = par_el.children;
} catch {
caught = true;
var par_el = document.getElementById("files-tree");
var items = par_el.children;
}
let name = file.name; let name = file.name;
console.log(par_el) console.log(par_el)
let full_path = path + '/' + name let full_path = path + '/' + name
var items = par_el.getElementsByTagName("li");
let flag = false; let flag = false;
for (var k = 0; k < items.length; ++k) { for (var k = 0; k < items.length; ++k) {
if ($(items[k]).attr("data-name") == name) { if ($(items[k]).attr("data-name") == name) {
console.log("FLAGGED")
flag = true; flag = true;
} }
} }
if (!flag) { if (!flag) {
if (caught) {
$(par_el).append('<li id=' + '"' + full_path.toString() + 'li' + '"' + 'class="d-block tree-ctx-item tree-file tree-item" data-path=' + '"' + full_path.toString() + '"' + ' data-name=' + '"' + name.toString() + '"' + ' onclick="clickOnFile(event)" ><span style="margin-right: 6px;"><i class="far fa-file"></i></span>' + name + '</li>');
} else {
$(par_el).append('<li id=' + '"' + full_path.toString() + 'li' + '"' + 'class="tree-ctx-item tree-file tree-item" data-path=' + '"' + full_path.toString() + '"' + ' data-name=' + '"' + name.toString() + '"' + ' onclick="clickOnFile(event)" ><span style="margin-right: 6px;"><i class="far fa-file"></i></span>' + name + '</li>'); $(par_el).append('<li id=' + '"' + full_path.toString() + 'li' + '"' + 'class="tree-ctx-item tree-file tree-item" data-path=' + '"' + full_path.toString() + '"' + ' data-name=' + '"' + name.toString() + '"' + ' onclick="clickOnFile(event)" ><span style="margin-right: 6px;"><i class="far fa-file"></i></span>' + name + '</li>');
} }
setTreeViewContext();
}
return true; return true;
} }
else { else {