From 6bbda5aaa2714750ec21fc9dc1c13a16cc1f4cc1 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 17 May 2012 16:18:26 +0200 Subject: Multi board/observes in the client. --- munia.html | 5 +++-- proto.js | 30 +++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/munia.html b/munia.html index cddf8da..0989b49 100644 --- a/munia.html +++ b/munia.html @@ -1,4 +1,5 @@ - + Munia @@ -54,7 +55,7 @@ TaskProto:
TaskMessages:
-
+
!
diff --git a/proto.js b/proto.js index 74eeabd..e81083b 100644 --- a/proto.js +++ b/proto.js @@ -83,7 +83,7 @@ function get_appropriate_ws_url() var socket_task; -var board = document.getElementById("board"); +var boards = document.getElementById("boards"); if (BrowserDetect.browser == "Firefox") { socket_task = new MozWebSocket(get_appropriate_ws_url(), "lws-task-protocol"); @@ -141,15 +141,31 @@ try { var cmd = msg[1]; var id = msg[2]; + var board = document.getElementById("board_" + observeid); + if(!board) { + //alert('missing board') + board = document.createElement("div"); + + board.name = "board"; + board.setAttribute("class", "board"); + board.setAttribute("style", "background-color: black; fixed-width: 100px; min-height: 200px; margin: 4px;"); + //board.setAttribute("ondrop", "drop(this, event)"); + //board.setAttribute("ondragover", "return false"); + //board.setAttribute("draggable", true); + //board.setAttribute("ondragstart", "drag(this, event)"); + board.id = "board_" + observeid; + boards.appendChild(board); + } + if(cmd == "remove") { - var task = document.getElementById("task_" + id); + var task = document.getElementById("board_" + observeid + "task_" + id); task.parentNode.removeChild(task); } else if(cmd == "move") { var parent_id = msg[3]; - var task = document.getElementById("task_" + id); + var task = document.getElementById("board_" + observeid + "task_" + id); if(parent_id != -1) { - var parent_task = document.getElementById("task_" + parent_id); + var parent_task = document.getElementById("board_" + observeid + "task_" + parent_id); parent_task.appendChild(task); } else { @@ -167,13 +183,13 @@ try { task.setAttribute("draggable", true); task.setAttribute("ondragstart", "drag(this, event)"); - task.id = "task_" + id; + task.id = "board_" + observeid + "task_" + id; var taskText = document.createTextNode('[' + task.id + ']'); taskText.id = "txt"; task.appendChild(taskText); - var parent_task = document.getElementById("task_" + parent_id); + var parent_task = document.getElementById("board_" + observeid + "task_" + parent_id); if(parent_task) { parent_task.appendChild(task); @@ -184,7 +200,7 @@ try { } else if(cmd == "update") { var title = msg[3]; - var task = document.getElementById("task_" + id); + var task = document.getElementById("board_" + observeid + "task_" + id); var taskText = document.createTextNode(title); task.appendChild(taskText); } -- cgit v1.2.3