diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 6080d5ec9..fa97c2c7d 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -519,17 +519,16 @@ if (file_upload) { document.getElementById('image-preview').setAttribute('src', this.result); document.getElementById('image-preview').classList.remove('d-none'); document.getElementById('image-preview').classList.add('mr-2'); - document.getElementById('image-preview').nextElementSibling.classList.add('mt-3'); }; } else { document.getElementById('image-preview').classList.add('d-none'); document.getElementById('image-preview').classList.remove('mr-2'); - document.getElementById('image-preview').nextElementSibling.classList.remove('mt-3'); } if (typeof checkForRequired === "function") { document.getElementById('urlblock').classList.add('d-none'); + document.getElementById('remove-attachment').classList.remove('d-none'); checkForRequired(); } else { diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index 206e1e2eb..2c7585ab1 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -65,15 +65,11 @@ function checkForRequired() { } checkForRequired(); -function hide_image() { - x=document.getElementById('image-upload-block'); - url=document.getElementById('post-url').value; - if (url.length>=1){ - x.classList.add('d-none'); - } - else { - x.classList.remove('d-none'); - } +function remove_attachment() { + document.getElementById("file-upload").value = null; + document.getElementById('image-upload-block').classList.add('d-none'); + document.getElementById('urlblock').classList.remove('d-none'); + clear_files("attachment"); } function autoSuggestTitle() { @@ -197,7 +193,8 @@ function submit(form) { localStorage.setItem(id, value) } - clear_files() + clear_files("attachment") + clear_files("textarea") } location.href = "/post/" + post_id @@ -300,7 +297,7 @@ submit_restore_files("textarea", "file-upload-submit") //CLEAR FILES -function clear_files() { +function clear_files(kind) { const open = indexedDB.open("files", 1); open.onsuccess = () => { const db = open.result; @@ -311,6 +308,6 @@ function clear_files() { db.close(); }; - store.clear(); + store.delete(kind); } } diff --git a/files/templates/submit.html b/files/templates/submit.html index 5d151624f..84f5124c6 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -34,17 +34,19 @@