summaryrefslogtreecommitdiff
path: root/munia.html
diff options
context:
space:
mode:
Diffstat (limited to 'munia.html')
-rw-r--r--munia.html65
1 files changed, 22 insertions, 43 deletions
diff --git a/munia.html b/munia.html
index 74f5e75..dfe59e7 100644
--- a/munia.html
+++ b/munia.html
@@ -108,7 +108,7 @@ var last_x = 0, last_y = 0;
var ctx;
var socket_lm;
var color = "#000000";
-var dragged = 0;
+var dragged = "";
// alert(BrowserDetect.browser);
if (BrowserDetect.browser == "Firefox") {
@@ -126,7 +126,7 @@ try {
socket_lm.onmessage = function got_packet(msg) {
// alert(msg.data);
- document.getElementById("wslm_lastmsg").textContent = msg.data;
+// document.getElementById("wslm_lastmsg").textContent = msg.data;
j = msg.data.split(';');
f = 0;
@@ -151,11 +151,17 @@ try {
// task.style.display = "none";
document.body.removeChild(task);
}
+ else if (i[0] == "move") {
+// alert("Moving task");
+ var task = document.getElementById("task_" + i[1]);
+ task.style.left = i[2] + "px";
+ task.style.top = i[3] + "px";
+ }
else if (i[0] == "add") {
var task = document.createElement("div");
task.name = "task";
task.id = "task_" + i[1];
-
+
var taskText = document.createTextNode(i[2] + ": " + i[3] + " :" + task.id);
task.appendChild(taskText);
@@ -167,6 +173,7 @@ try {
task.style.borderWidth= "medium";
task.style.borderRadius= "15px";
task.style.padding = "4px";
+ task.setAttribute("onMouseDown", "dragged = '" + i[1] + "';");
var dlButton = document.createElement("input");
dlButton.type = "button";
@@ -199,10 +206,12 @@ ctx = canvas.getContext("2d");
document.getElementById('wslm_drawing').appendChild(canvas);
-canvas.addEventListener('mousemove', ev_mousemove, false);
+document.addEventListener('mousemove', ev_mousemove, false);
+document.addEventListener('mouseup', ev_mouseup, false);
+/*
canvas.addEventListener('mousedown', ev_mousedown, false);
-canvas.addEventListener('mouseup', ev_mouseup, false);
//cancas.addEventListener('dragend', ev_mousemove, false);
+*/
offsetX = offsetY = 0;
element = canvas;
@@ -217,49 +226,19 @@ function update_color() {
color = document.getElementById("color").value;
}
-function ev_mousedown (ev) {
- down = 1;
-
- var x, y;
-
- if (ev.offsetX) {
- x = ev.offsetX;
- y = ev.offsetY;
- } else {
- x = ev.layerX - offsetX;
- y = ev.layerY - offsetY;
- }
-}
-
function ev_mouseup(ev) {
- down = 0;
- no_last = 1;
+ dragged = '';
}
-function ev_mousemove (ev) {
- var x, y;
-
- if (ev.offsetX) {
- x = ev.offsetX;
- y = ev.offsetY;
- } else {
- x = ev.layerX - offsetX;
- y = ev.layerY - offsetY;
-
- }
+function ev_mousemove (ev)
+{
+ if(dragged == '') return;
- if (!down)
- return;
- if (no_last) {
- no_last = 0;
- last_x = x;
- last_y = y;
- return;
- }
- socket_lm.send("d " + color + " " + last_x + " " + last_y + " " + x + ' ' + y + ';');
+ var x, y;
+ x = ev.clientX;
+ y = ev.clientY;
- last_x = x;
- last_y = y;
+ socket_lm.send("move " + dragged + " " + x + " " + y);
}
function submit() {