diff --git a/files/assets/js/bottom.js b/files/assets/js/bottom.js index 21c557e15..a1a07d351 100644 --- a/files/assets/js/bottom.js +++ b/files/assets/js/bottom.js @@ -143,7 +143,7 @@ function register_new_elements(e) { }); } - const file_inputs = document.querySelectorAll('input[type="file"]:not(.not-handle-files)') + const file_inputs = document.querySelectorAll('input[multiple="multiple"]') for (const input of file_inputs) { input.onchange = () => {handle_files(input, input.files)}; } diff --git a/files/assets/js/chat.js b/files/assets/js/chat.js index 8109fbbcf..07322bc4e 100644 --- a/files/assets/js/chat.js +++ b/files/assets/js/chat.js @@ -166,9 +166,9 @@ function send() { autoExpand(ta); document.getElementById("quotes").classList.add("d-none") document.getElementById('quotes_id').value = null; - document.getElementById("filename").innerHTML = '' oldfiles[ta.id] = []; input.value = null; + input.previousElementSibling.innerHTML = '' input.parentElement.nextElementSibling.classList.add('d-none'); box.scrollTo(0, box.scrollHeight); @@ -298,6 +298,20 @@ document.addEventListener('click', function (e) { } }); + +const input = document.getElementById('file') +function handle_files() { + if (!input.files.length) return + input.previousElementSibling.textContent = input.files[0].name.substr(0, 50); +} + +input.onchange = handle_files + +document.onpaste = function(event) { + input.files = structuredClone(event.clipboardData.files); + handle_files() +} + box.scrollTo(0, box.scrollHeight) setTimeout(function () { box.scrollTo(0, box.scrollHeight) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 4eab8b1fa..343d1f7ac 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -525,7 +525,7 @@ if (file_upload) { if (file_upload.files) { const filename = file_upload.files[0].name - document.getElementById('filename-show').textContent = filename.substr(0, 50); + file_upload.previousElementSibling.textContent = filename.substr(0, 50); if (IMAGE_FORMATS.some(s => filename.toLowerCase().endsWith(s))) { const fileReader = new FileReader(); diff --git a/files/templates/admin/update_assets.html b/files/templates/admin/update_assets.html index 7f6f735df..bcba1d6ce 100644 --- a/files/templates/admin/update_assets.html +++ b/files/templates/admin/update_assets.html @@ -18,7 +18,7 @@ diff --git a/files/templates/chat.html b/files/templates/chat.html index e911c9966..ada99e044 100644 --- a/files/templates/chat.html +++ b/files/templates/chat.html @@ -115,7 +115,7 @@ diff --git a/files/templates/settings/personal.html b/files/templates/settings/personal.html index 68684c11c..6075667d7 100644 --- a/files/templates/settings/personal.html +++ b/files/templates/settings/personal.html @@ -190,7 +190,7 @@