From fa5985ed620c3cd4c7b9712b6b80a2e2c1a8ba31 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 6 Jun 2020 18:32:11 +0200 Subject: Rename task to node everywhere. --- task.js | 137 ---------------------------------------------------------------- 1 file changed, 137 deletions(-) delete mode 100644 task.js (limited to 'task.js') diff --git a/task.js b/task.js deleted file mode 100644 index 64d95ff..0000000 --- a/task.js +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ - -function createId(boardid, taskid) -{ - return "b" + boardid + "_t" + taskid; -} - -function idFromStr(str) -{ - return str.substring(str.search('t') + 1, str.length); -} - -var tasks = new Array(); - -function findTask(id, subscribeid) -{ - for(var i = 0; i < tasks.length; i++) { - var task = tasks[i]; - var child = task.findTask(id, subscribeid); - if(child != null) return child; - } - - return null; -} - -function Task(id, subscribeid) -{ - this.id = id; - this.subscribeid = subscribeid; - this.children = new Array(); - this.attributes = {}; - this.parent = null; - - // Elements: - this.element = document.createElement("div"); - this.div_id = document.createElement("span"); - this.div_title = document.createElement("span"); -} - -Task.prototype.dump = function() -{ - alert(this.id); -} - -Task.prototype.findTask = function(id, subscribeid) -{ - if(this.subscribeid != subscribeid) return null; - - if(this.id == id) return this; - - for(var i = 0; i < this.children.length; i++) { - var task = this.children[i]; - var child = task.findTask(id, subscribeid); - if(child != null) return child; - } - - return null; -} - -Task.prototype.addChild = function(task) -{ - if(task.parent != null) task.parent.removeChild(task); - this.children.push(task); - task.parent = this; - this.element.appendChild(task.element); -} - -Task.prototype.removeChild = function(task) -{ - this.children = this.children.filter( - function(e) { - return e.id != task.id; - }); - task.parent = null; - this.element.removeChild(task.element); -} - -Task.prototype.create = function() -{ - var task = this.element; - - task.name = "task"; - task.setAttribute("class", "task"); - task.setAttribute("ondblclick", "editTitle(this, event)"); - //task.setAttribute("onclick", "showHideChildren(this, event)"); - task.setAttribute("ondrop", "drop(this, event)"); - task.setAttribute("ondragover", "return false"); - task.setAttribute("draggable", true); - task.setAttribute("ondragstart", "drag(this, event)"); - task.setAttribute("title", this.id); - - // This is a hack to make it possible to identify the taskid and - // oberveid from the node id alone. - task.id = createId(this.subscribeid, this.id); - -/* - var subscribe_button = document.createElement("div"); - subscribe_button.name = "subscribe_button"; - subscribe_button.setAttribute("onclick", "subscribeMe(this, event)"); - subscribe_button.setAttribute("title", this.id); - subscribe_button.setAttribute("style", "float: left; display: inline-box; width:14px; height: 14px; border: solid green 2px; cursor: pointer;"); - var txt_plus = document.createTextNode("+"); - subscribe_button.appendChild(txt_plus); - task.appendChild(subscribe_button); - - var unsubscribe_button = document.createElement("div"); - unsubscribe_button.name = "unsubscribe_button"; - unsubscribe_button.setAttribute("onclick", "unsubscribeMe(this, event)"); - unsubscribe_button.setAttribute("title", this.id); - unsubscribe_button.setAttribute("style", "float: left; display: inline-box; width:14px; height: 14px; border: solid red 2px; cursor: pointer;"); - var txt_minus = document.createTextNode("-"); - unsubscribe_button.appendChild(txt_minus); - task.appendChild(unsubscribe_button); -*/ - - this.element.appendChild(this.div_id); - var id_txt = document.createTextNode(this.id); - this.div_id.appendChild(id_txt); - - this.element.appendChild(this.div_title); - - this.setAttribute("title", "(missing title)"); -} - -Task.prototype.setAttribute = function(name, value) -{ - this.attributes[name] = value; - - if(name == "title") { - if(this.div_title.firstChild != null) { - this.div_title.removeChild(this.div_title.firstChild); - } - var title_txt = document.createTextNode(value); - this.div_title.appendChild(title_txt); - } -} -- cgit v1.2.3