1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set et sw=2 ts=2: */
document.addEventListener("connectEvent", connectEventHandler, false);
function connectEventHandler(e)
{
document.getElementById("wstask_status").style.backgroundColor = "#40ff40";
document.getElementById("wstask_status").textContent = "TaskProto websocket connection opened ";
// login("foobar", "hundemad");
// observe(0);
}
document.addEventListener("disconnectEvent", disconnectEventHandler, false);
function disconnectEventHandler(e)
{
document.getElementById("wstask_status").style.backgroundColor = "#ff4040";
document.getElementById("wstask_status").textContent = "TaskProto websocket connection CLOSED ";
}
document.addEventListener("removeEvent", removeEventHandler, false);
function removeEventHandler(e)
{
var observeid = e.detail.observeid;
var id = e.detail.id;
var task = findTask(id, observeid);
if(task.parent) task.parent.removeChild(task);
}
document.addEventListener("moveEvent", moveEventHandler, false);
function moveEventHandler(e)
{
var observeid = e.detail.observeid;
var id = e.detail.id;
var parentid = e.detail.parentid;
var task = findTask(id, observeid);
var new_parent = findTask(parentid, observeid);
if(task != null && new_parent != null) new_parent.addChild(task);
}
document.addEventListener("createEvent", createEventHandler, false);
function createEventHandler(e)
{
var observeid = e.detail.observeid;
var id = e.detail.id;
var parentid = e.detail.parentid;
var task = new Task(id, observeid);
task.create();
if(parentid == -1) {
tasks.push(task);
var board = getBoard(observeid);
board.appendChild(task.element);
return;
}
var parent = findTask(parentid, observeid);
if(parent != null) {
parent.addChild(task);
}
}
document.addEventListener("updateEvent", updateEventHandler, false);
function updateEventHandler(e)
{
var observeid = e.detail.observeid;
var id = e.detail.id;
var name = e.detail.name;
var value = e.detail.value;
var task = findTask(id, observeid);
if(task == null) return;
task.setAttribute(name, value);
}
///////
//////
/////
////
///
//
document.addEventListener("messageEvent", messageEventHandler, false);
function messageEventHandler(e) {
LogEvent(e.detail.time.toString()+": "+e.detail.message
);
}
// log event in console
function LogEvent(msg) {
var log = document.getElementById("log");
log.textContent += msg + "\n";
var ot = log.scrollHeight - log.clientHeight;
if (ot > 0) log.scrollTop = ot;
}
|