diff options
-rw-r--r-- | proto.js | 29 |
1 files changed, 26 insertions, 3 deletions
@@ -96,6 +96,11 @@ var socket_lm; var color = "#000000"; var dragged = ""; +document.body.setAttribute("ondrop", "dropInBody(event)"); +document.body.setAttribute("ondragenter", "return false"); +document.body.setAttribute("ondragover", "return false"); + + if (BrowserDetect.browser == "Firefox") { socket_lm = new MozWebSocket(get_appropriate_ws_url(), "lws-task-protocol"); } else { @@ -155,13 +160,18 @@ try { } else if(cmd == "move") { var id = msg[1]; - var parent_id = msg[2]; + var parent_id = msg[2]; // var left = msg[2]; // var top = msg[3]; var task = document.getElementById("task_" + id); - var parent_task = document.getElementById("task_" + parent_id); + if(parent_id != -1) { + var parent_task = document.getElementById("task_" + parent_id); + parent_task.appendChild(task); + } + else { + document.body.appendChild(task); + } // task.parentNode.removeChild(task); - parent_task.appendChild(task); // document.body.removeChild(task); // parent_task.appendChild(task); // task.style.left = left + "px"; @@ -307,3 +317,16 @@ function drop(target, e) { // target.appendChild(task); } +function dropInBody(e) { + e.preventDefault(); + e.stopPropagation(); + + var id = e.dataTransfer.getData('Text'); + var task = document.getElementById(id); +// task.parentNode.removeChild(task); +// alert("move " + id.substring(5, id.length) + " " + target.id.substring(5,target.id.length) + ";"); + socket_lm.send("move " + id.substring(5, id.length) + " -1;"); + +// target.appendChild(task); +} + |