forked from rDrama/rDrama
make oldfiles contain DataTransfer objects instead of lists
parent
39b8064748
commit
4f2cba6af7
|
@ -172,7 +172,7 @@ function send() {
|
||||||
autoExpand(ta);
|
autoExpand(ta);
|
||||||
document.getElementById("quotes").classList.add("d-none")
|
document.getElementById("quotes").classList.add("d-none")
|
||||||
document.getElementById('quotes_id').value = null;
|
document.getElementById('quotes_id').value = null;
|
||||||
oldfiles[ta.id] = [];
|
oldfiles[ta.id] = new DataTransfer();
|
||||||
input.value = null;
|
input.value = null;
|
||||||
input.previousElementSibling.innerHTML = '<i class="fas fa-image" style="font-size:1.3rem!important"></i>'
|
input.previousElementSibling.innerHTML = '<i class="fas fa-image" style="font-size:1.3rem!important"></i>'
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ function post_reply(id) {
|
||||||
const input = ta.parentElement.querySelector('input[type="file"]')
|
const input = ta.parentElement.querySelector('input[type="file"]')
|
||||||
input.previousElementSibling.innerHTML = '';
|
input.previousElementSibling.innerHTML = '';
|
||||||
input.value = null;
|
input.value = null;
|
||||||
oldfiles[ta.id] = []
|
oldfiles[ta.id] = new DataTransfer();
|
||||||
|
|
||||||
remove_dialog();
|
remove_dialog();
|
||||||
restore_reply_buttons(`c_${id}`)
|
restore_reply_buttons(`c_${id}`)
|
||||||
|
@ -221,7 +221,7 @@ function comment_edit(id){
|
||||||
const input = ta.parentElement.querySelector('input[type="file"]')
|
const input = ta.parentElement.querySelector('input[type="file"]')
|
||||||
input.previousElementSibling.innerHTML = '';
|
input.previousElementSibling.innerHTML = '';
|
||||||
input.value = null;
|
input.value = null;
|
||||||
oldfiles[ta.id] = []
|
oldfiles[ta.id] = new DataTransfer();
|
||||||
|
|
||||||
remove_dialog();
|
remove_dialog();
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ function post_comment(fullname, hide){
|
||||||
const input = ta.parentElement.querySelector('input[type="file"]')
|
const input = ta.parentElement.querySelector('input[type="file"]')
|
||||||
input.previousElementSibling.innerHTML = '';
|
input.previousElementSibling.innerHTML = '';
|
||||||
input.value = null;
|
input.value = null;
|
||||||
oldfiles[ta.id] = []
|
oldfiles[ta.id] = new DataTransfer();
|
||||||
|
|
||||||
const ghost_town_box = document.getElementById('ghost-town-box')
|
const ghost_town_box = document.getElementById('ghost-town-box')
|
||||||
if (ghost_town_box) ghost_town_box.remove()
|
if (ghost_town_box) ghost_town_box.remove()
|
||||||
|
|
|
@ -483,33 +483,28 @@ function handle_files(input, newfiles) {
|
||||||
const ta = input.parentElement.parentElement.parentElement.parentElement.querySelector('textarea.file-ta');
|
const ta = input.parentElement.parentElement.parentElement.parentElement.querySelector('textarea.file-ta');
|
||||||
|
|
||||||
if (oldfiles[ta.id]) {
|
if (oldfiles[ta.id]) {
|
||||||
let list = new DataTransfer();
|
|
||||||
for (const file of oldfiles[ta.id]) {
|
|
||||||
list.items.add(file);
|
|
||||||
}
|
|
||||||
for (const file of newfiles) {
|
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 {
|
else {
|
||||||
input.files = newfiles;
|
oldfiles[ta.id] = new DataTransfer();
|
||||||
oldfiles[ta.id] = []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.files.length > 20)
|
if (input.files.length > 20)
|
||||||
{
|
{
|
||||||
alert("You can't upload more than 20 files at one time!")
|
alert("You can't upload more than 20 files at one time!")
|
||||||
input.value = null
|
input.value = null
|
||||||
oldfiles[ta.id] = []
|
oldfiles[ta.id] = new DataTransfer();
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const file of newfiles) {
|
if (location.pathname != '/chat' && location.pathname != '/old_chat') {
|
||||||
oldfiles[ta.id].push(file)
|
for (const file of newfiles) {
|
||||||
if (location.pathname != '/chat' && location.pathname != '/old_chat')
|
|
||||||
insertText(ta, `[${file.name}]`);
|
insertText(ta, `[${file.name}]`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
autoExpand(ta)
|
autoExpand(ta)
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ function sendMessage(form) {
|
||||||
const input = ta.parentElement.querySelector('input[type="file"]');
|
const input = ta.parentElement.querySelector('input[type="file"]');
|
||||||
input.previousElementSibling.innerHTML = '';
|
input.previousElementSibling.innerHTML = '';
|
||||||
input.value = null;
|
input.value = null;
|
||||||
oldfiles[ta.id] = [];
|
oldfiles[ta.id] = new DataTransfer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue