From: Art Cancro Date: Tue, 26 Sep 2023 03:47:52 +0000 (-0400) Subject: view_mail.js: make the function names more consistent with webcit X-Git-Tag: v995~5 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=418942c462f6ad11cf7b0a1d3943e234a696a59e;p=citadel.git view_mail.js: make the function names more consistent with webcit (They were previously the same names used in the example, natch) Also we're incrementing num_attachments --- diff --git a/webcit-ng/static/js/view_mail.js b/webcit-ng/static/js/view_mail.js index 91180d9e6..e63fff6d0 100644 --- a/webcit-ng/static/js/view_mail.js +++ b/webcit-ng/static/js/view_mail.js @@ -548,7 +548,7 @@ function activate_uploads(parent_div) {

${_("Drop files here to upload")}

- +
@@ -558,15 +558,15 @@ function activate_uploads(parent_div) { //let dropArea = document.getElementById("ctdl-upload"); let dropArea = document.getElementById(parent_div); ;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { - dropArea.addEventListener(eventName, preventDefaults, false) + dropArea.addEventListener(eventName, upload_prevent_defaults, false) }) ;["dragenter", "dragover"].forEach(eventName => { - dropArea.addEventListener(eventName, highlight, false) + dropArea.addEventListener(eventName, upload_highlight, false) }) ;['dragleave', 'drop'].forEach(eventName => { - dropArea.addEventListener(eventName, unhighlight, false) + dropArea.addEventListener(eventName, upload_unhighlight, false) }) - dropArea.addEventListener('drop', handleDrop, false); + dropArea.addEventListener('drop', upload_handle_drop, false); // make the modal smaller than the containing window but pretty big //document.getElementById("ctdl-upload").style.width = @@ -577,25 +577,25 @@ function activate_uploads(parent_div) { // prevent drag and drop events from propagating up through the DOM -function preventDefaults(e) { +function upload_prevent_defaults(e) { e.preventDefault(); e.stopPropagation(); } -function handleDrop(e) { +function upload_handle_drop(e) { let dt = e.dataTransfer; let files = dt.files; - handleFiles(files); + handle_upload_files(files); } -function handleFiles(files) { - ([...files]).forEach(uploadFile) +function handle_upload_files(files) { + ([...files]).forEach(upload_file) } -function uploadFile(file) { +function upload_file(file) { var url = '/ctdl/a/upload'; var xhr = new XMLHttpRequest(); var formData = new FormData(); @@ -605,6 +605,7 @@ function uploadFile(file) { if (xhr.readyState == 4 && xhr.status == 200) { document.getElementById("ctdl-upload_list").innerHTML += "
  • succeeeeed
  • "; console.log("upload succeeded"); + num_attachments += 1; } else if (xhr.readyState == 4 && xhr.status != 200) { document.getElementById("ctdl-upload_list").innerHTML += "
  • EPIC FAIL
  • "; @@ -614,17 +615,18 @@ function uploadFile(file) { formData.append('file', file); xhr.send(formData); + console.log("uploading..."); } -function highlight(e) { +function upload_highlight(e) { let dropArea = document.getElementById("ctdl-upload"); dropArea.classList.add('highlight') document.getElementById("ctdl-upload").style.display = "block"; /* also make it appear */ } -function unhighlight(e) { +function upload_unhighlight(e) { let dropArea = document.getElementById("ctdl-upload"); dropArea.classList.remove('highlight') }