/* -*- 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"); //subscribe(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 subscribeid = e.detail.subscribeid; var id = e.detail.id; var task = findTask(id, subscribeid); if(task.parent) task.parent.removeChild(task); } document.addEventListener("moveEvent", moveEventHandler, false); function moveEventHandler(e) { var subscribeid = e.detail.subscribeid; var id = e.detail.id; var parentid = e.detail.parentid; var task = findTask(id, subscribeid); var new_parent = findTask(parentid, subscribeid); if(task != null && new_parent != null) new_parent.addChild(task); } document.addEventListener("createEvent", createEventHandler, false); function createEventHandler(e) { var subscribeid = e.detail.subscribeid; var id = e.detail.id; var parentid = e.detail.parentid; var task = new Task(id, subscribeid); task.create(); if(parentid == -1) { tasks.push(task); var board = getBoard(subscribeid); board.appendChild(task.element); return; } var parent = findTask(parentid, subscribeid); if(parent != null) { parent.addChild(task); } } document.addEventListener("updateEvent", updateEventHandler, false); function updateEventHandler(e) { var subscribeid = e.detail.subscribeid; var id = e.detail.id; var name = e.detail.name; var value = e.detail.value; var task = findTask(id, subscribeid); 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; }