// Copyright (c) 2016-2023 by the citadel.org team
//
// This program is open source software. Use, duplication, or
-// disclosure are subject to the GNU General Public License v3.
+// disclosure is subject to the GNU General Public License v3.
// Display the mail folder list in the specified div
}
+// Something has been dropped onto a folder.
function mail_folder_drop(event, destination_room) {
event.preventDefault();
- console.log("mail_folder_drop(" + destination_room + ")");
event.target.classList.toggle("ctdl_mail_folder_droppable", false);
+ var msgs = event.dataTransfer.getData("text").split(",");
+ for (var i=0; i<msgs.length; ++i) {
+ mail_move(msgs[i], destination_room);
+ }
+}
+
+
+// mail_folder_drop() calls this function for each message being moved
+mail_move = async(msgdivid, destination_room) => {
+ let msgdiv = document.getElementById(msgdivid);
+ let m = parseInt(msgdivid.substring(12)); // derive msgnum from row id
+ let source = "/ctdl/r/" + escapeHTMLURI(current_room) + "/" + m;
+ let destination = "/ctdl/r/" + escapeHTMLURI(destination_room);
+
+ let response = await fetch(
+ source, {
+ method: "MOVE",
+ headers: {
+ "Destination" : destination
+ }
+ }
+ );
+
+ // If the server accepted the MOVE operation, delete the row from our screen.
+ if (response.ok) {
+ var table = document.getElementById("ctdl-onscreen-mailbox");
+ for (var i = 0, row; row = table.rows[i]; i++) {
+ if (row.id == msgdivid) {
+ table.deleteRow(i);
+ }
+ }
+ }
}