make oldfiles contain DataTransfer objects instead of lists

master
Aevann 2023-08-08 13:52:07 +03:00
parent 39b8064748
commit 4f2cba6af7
4 changed files with 12 additions and 17 deletions

View File

@ -172,7 +172,7 @@ function send() {
autoExpand(ta);
document.getElementById("quotes").classList.add("d-none")
document.getElementById('quotes_id').value = null;
oldfiles[ta.id] = [];
oldfiles[ta.id] = new DataTransfer();
input.value = null;
input.previousElementSibling.innerHTML = '<i class="fas fa-image" style="font-size:1.3rem!important"></i>'

View File

@ -169,7 +169,7 @@ function post_reply(id) {
const input = ta.parentElement.querySelector('input[type="file"]')
input.previousElementSibling.innerHTML = '';
input.value = null;
oldfiles[ta.id] = []
oldfiles[ta.id] = new DataTransfer();
remove_dialog();
restore_reply_buttons(`c_${id}`)
@ -221,7 +221,7 @@ function comment_edit(id){
const input = ta.parentElement.querySelector('input[type="file"]')
input.previousElementSibling.innerHTML = '';
input.value = null;
oldfiles[ta.id] = []
oldfiles[ta.id] = new DataTransfer();
remove_dialog();
}
@ -294,7 +294,7 @@ function post_comment(fullname, hide){
const input = ta.parentElement.querySelector('input[type="file"]')
input.previousElementSibling.innerHTML = '';
input.value = null;
oldfiles[ta.id] = []
oldfiles[ta.id] = new DataTransfer();
const ghost_town_box = document.getElementById('ghost-town-box')
if (ghost_town_box) ghost_town_box.remove()

View File

@ -483,33 +483,28 @@ function handle_files(input, newfiles) {
const ta = input.parentElement.parentElement.parentElement.parentElement.querySelector('textarea.file-ta');
if (oldfiles[ta.id]) {
let list = new DataTransfer();
for (const file of oldfiles[ta.id]) {
list.items.add(file);
}
for (const file of newfiles) {
list.items.add(file);
oldfiles[ta.id].items.add(file);
}
input.files = list.files;
input.files = oldfiles[ta.id].files;
}
else {
input.files = newfiles;
oldfiles[ta.id] = []
oldfiles[ta.id] = new DataTransfer();
}
if (input.files.length > 20)
{
alert("You can't upload more than 20 files at one time!")
input.value = null
oldfiles[ta.id] = []
oldfiles[ta.id] = new DataTransfer();
return
}
for (const file of newfiles) {
oldfiles[ta.id].push(file)
if (location.pathname != '/chat' && location.pathname != '/old_chat')
if (location.pathname != '/chat' && location.pathname != '/old_chat') {
for (const file of newfiles) {
insertText(ta, `[${file.name}]`);
}
}
autoExpand(ta)

View File

@ -80,7 +80,7 @@ function sendMessage(form) {
const input = ta.parentElement.querySelector('input[type="file"]');
input.previousElementSibling.innerHTML = '';
input.value = null;
oldfiles[ta.id] = [];
oldfiles[ta.id] = new DataTransfer();
}
}
)