summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-06-07 11:13:55 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2020-06-07 11:13:55 +0200
commitf0bf8e339b31fde313c83ae9ee1045de5aefe510 (patch)
tree59d7323dad706bb143134430e74039184e4fb6b5 /src
parentdd19910ec18ec60633bf5b4fcda5bab220d0565f (diff)
Fix white-space in all javascript files. Use js2 emacs mode.
Diffstat (limited to 'src')
-rw-r--r--src/ws/handler.js124
-rw-r--r--src/ws/node.js197
-rw-r--r--src/ws/proto.js364
-rw-r--r--src/ws/view.js186
4 files changed, 477 insertions, 394 deletions
diff --git a/src/ws/handler.js b/src/ws/handler.js
index 906a03b..c0321a9 100644
--- a/src/ws/handler.js
+++ b/src/ws/handler.js
@@ -1,82 +1,92 @@
-/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: js2; 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("wsnode_status").style.backgroundColor = "#40ff40";
- document.getElementById("wsnode_status").textContent = "NodeProto websocket connection opened ";
+ document.getElementById("wsnode_status").style.backgroundColor = "#40ff40";
+ document.getElementById("wsnode_status").textContent = "NodeProto websocket connection opened ";
- //login("foobar", "hundemad");
- //subscribe(0);
+ //login("foobar", "hundemad");
+ //subscribe(0);
}
document.addEventListener("disconnectEvent", disconnectEventHandler, false);
function disconnectEventHandler(e)
{
- document.getElementById("wsnode_status").style.backgroundColor = "#ff4040";
- document.getElementById("wsnode_status").textContent = "NodeProto websocket connection CLOSED ";
+ document.getElementById("wsnode_status").style.backgroundColor = "#ff4040";
+ document.getElementById("wsnode_status").textContent = "NodeProto websocket connection CLOSED ";
}
document.addEventListener("removeEvent", removeEventHandler, false);
function removeEventHandler(e)
{
- var subscribeid = e.detail.subscribeid;
- var id = e.detail.id;
-
- var node = findNode(id, subscribeid);
- if(node.parent) node.parent.removeChild(node);
+ var subscribeid = e.detail.subscribeid;
+ var id = e.detail.id;
+
+ var node = findNode(id, subscribeid);
+ if(node.parent)
+ {
+ node.parent.removeChild(node);
+ }
}
document.addEventListener("moveEvent", moveEventHandler, false);
function moveEventHandler(e)
{
- var subscribeid = e.detail.subscribeid;
- var id = e.detail.id;
- var parentid = e.detail.parentid;
-
- var node = findNode(id, subscribeid);
- var new_parent = findNode(parentid, subscribeid);
- if(node != null && new_parent != null) new_parent.addChild(node);
+ var subscribeid = e.detail.subscribeid;
+ var id = e.detail.id;
+ var parentid = e.detail.parentid;
+
+ var node = findNode(id, subscribeid);
+ var new_parent = findNode(parentid, subscribeid);
+ if(node != null && new_parent != null)
+ {
+ new_parent.addChild(node);
+ }
}
document.addEventListener("createEvent", createEventHandler, false);
function createEventHandler(e)
{
- var subscribeid = e.detail.subscribeid;
- var id = e.detail.id;
- var parentid = e.detail.parentid;
-
- var node = new Node(id, subscribeid);
- node.create();
-
- if(parentid == -1) {
- nodes.push(node);
- var board = getBoard(subscribeid);
- board.appendChild(node.element);
- return;
- }
-
- var parent = findNode(parentid, subscribeid);
- if(parent != null) {
- parent.addChild(node);
- }
-
+ var subscribeid = e.detail.subscribeid;
+ var id = e.detail.id;
+ var parentid = e.detail.parentid;
+
+ var node = new Node(id, subscribeid);
+ node.create();
+
+ if(parentid == -1)
+ {
+ nodes.push(node);
+ var board = getBoard(subscribeid);
+ board.appendChild(node.element);
+ return;
+ }
+
+ var parent = findNode(parentid, subscribeid);
+ if(parent != null)
+ {
+ parent.addChild(node);
+ }
}
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 node = findNode(id, subscribeid);
- if(node == null) return;
-
- node.setAttribute(name, value);
+ var subscribeid = e.detail.subscribeid;
+ var id = e.detail.id;
+ var name = e.detail.name;
+ var value = e.detail.value;
+
+ var node = findNode(id, subscribeid);
+ if(node == null)
+ {
+ return;
+ }
+
+ node.setAttribute(name, value);
}
///////
@@ -87,15 +97,19 @@ function updateEventHandler(e)
//
document.addEventListener("messageEvent", messageEventHandler, false);
-function messageEventHandler(e) {
- LogEvent(e.detail.time.toString()+": "+e.detail.message
- );
+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;
+function LogEvent(msg)
+{
+ var log = document.getElementById("log");
+ log.textContent += msg + "\n";
+ var ot = log.scrollHeight - log.clientHeight;
+ if(ot > 0)
+ {
+ log.scrollTop = ot;
+ }
}
diff --git a/src/ws/node.js b/src/ws/node.js
index 3cb325c..f7deaf7 100644
--- a/src/ws/node.js
+++ b/src/ws/node.js
@@ -1,137 +1,156 @@
-/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set et sw=2 ts=2: */
function createId(boardid, nodeid)
{
- return "b" + boardid + "_t" + nodeid;
+ return "b" + boardid + "_t" + nodeid;
}
function idFromStr(str)
{
- return str.substring(str.search('t') + 1, str.length);
+ return str.substring(str.search('t') + 1, str.length);
}
var nodes = new Array();
function findNode(id, subscribeid)
{
- for(var i = 0; i < nodes.length; i++) {
- var node = nodes[i];
- var child = node.findNode(id, subscribeid);
- if(child != null) return child;
- }
+ for(var i = 0; i < nodes.length; i++)
+ {
+ var node = nodes[i];
+ var child = node.findNode(id, subscribeid);
+ if(child != null)
+ {
+ return child;
+ }
+ }
- return null;
+ return null;
}
function Node(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");
+ 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");
}
Node.prototype.dump = function()
{
- alert(this.id);
-}
+ alert(this.id);
+};
Node.prototype.findNode = function(id, subscribeid)
{
- if(this.subscribeid != subscribeid) return null;
+ if(this.subscribeid != subscribeid)
+ {
+ return null;
+ }
- if(this.id == id) return this;
+ if(this.id == id)
+ {
+ return this;
+ }
- for(var i = 0; i < this.children.length; i++) {
- var node = this.children[i];
- var child = node.findNode(id, subscribeid);
- if(child != null) return child;
- }
+ for(var i = 0; i < this.children.length; i++)
+ {
+ var node = this.children[i];
+ var child = node.findNode(id, subscribeid);
+ if(child != null)
+ {
+ return child;
+ }
+ }
- return null;
-}
+ return null;
+};
Node.prototype.addChild = function(node)
{
- if(node.parent != null) node.parent.removeChild(node);
- this.children.push(node);
- node.parent = this;
- this.element.appendChild(node.element);
-}
+ if(node.parent != null)
+ {
+ node.parent.removeChild(node);
+ }
+ this.children.push(node);
+ node.parent = this;
+ this.element.appendChild(node.element);
+};
Node.prototype.removeChild = function(node)
{
- this.children = this.children.filter(
- function(e) {
- return e.id != node.id;
- });
- node.parent = null;
- this.element.removeChild(node.element);
-}
+ this.children = this.children.filter(function(e)
+ {
+ return e.id != node.id;
+ });
+ node.parent = null;
+ this.element.removeChild(node.element);
+};
Node.prototype.create = function()
{
- var node = this.element;
-
- node.name = "node";
- node.setAttribute("class", "node");
- node.setAttribute("ondblclick", "editTitle(this, event)");
- //node.setAttribute("onclick", "showHideChildren(this, event)");
- node.setAttribute("ondrop", "drop(this, event)");
- node.setAttribute("ondragover", "return false");
- node.setAttribute("draggable", true);
- node.setAttribute("ondragstart", "drag(this, event)");
- node.setAttribute("title", this.id);
-
- // This is a hack to make it possible to identify the nodeid and
- // oberveid from the node id alone.
- node.id = createId(this.subscribeid, this.id);
+ var node = this.element;
+
+ node.name = "node";
+ node.setAttribute("class", "node");
+ node.setAttribute("ondblclick", "editTitle(this, event)");
+ //node.setAttribute("onclick", "showHideChildren(this, event)");
+ node.setAttribute("ondrop", "drop(this, event)");
+ node.setAttribute("ondragover", "return false");
+ node.setAttribute("draggable", true);
+ node.setAttribute("ondragstart", "drag(this, event)");
+ node.setAttribute("title", this.id);
+
+ // This is a hack to make it possible to identify the nodeid and
+ // oberveid from the node id alone.
+ node.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);
- node.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);
- node.appendChild(unsubscribe_button);
+ 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);
+ node.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);
+ node.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_id);
+ var id_txt = document.createTextNode(this.id);
+ this.div_id.appendChild(id_txt);
- this.element.appendChild(this.div_title);
+ this.element.appendChild(this.div_title);
- this.setAttribute("title", "(missing title)");
-}
+ this.setAttribute("title", "(missing title)");
+};
Node.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);
+ 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);
}
- var title_txt = document.createTextNode(value);
- this.div_title.appendChild(title_txt);
- }
-}
+};
diff --git a/src/ws/proto.js b/src/ws/proto.js
index 5a71157..035408f 100644
--- a/src/ws/proto.js
+++ b/src/ws/proto.js
@@ -1,211 +1,243 @@
-/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set et sw=2 ts=2: */
function get_appropriate_ws_url()
{
- // From: https://gist.github.com/2428561
- var parser = document.createElement('a');
- parser.href = document.URL;
-
- // We open the websocket encrypted if this page came on an
- // https:// url itself, otherwise unencrypted
- if(parser.protocol == "http:") parser.protocol = "ws:";
- if(parser.protocol == "https:") parser.protocol = "wss:";
-
- return parser.href;
+ // From: https://gist.github.com/2428561
+ var parser = document.createElement('a');
+ parser.href = document.URL;
+
+ // We open the websocket encrypted if this page came on an
+ // https:// url itself, otherwise unencrypted
+ if(parser.protocol == "http:")
+ {
+ parser.protocol = "ws:";
+ }
+ if(parser.protocol == "https:")
+ {
+ parser.protocol = "wss:";
+ }
+
+ return parser.href;
}
var socket_node = new WebSocket(get_appropriate_ws_url(), "lws-node-protocol");
-try {
- socket_node.onopen = function() {
- var connectEvent = new CustomEvent("connectEvent", {
- detail: {
- time: new Date(),
- },
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(connectEvent);
- }
-
- socket_node.onmessage = function got_packet(msg) {
- var messageEvent = new CustomEvent("messageEvent", {
- detail: {
- message: "recv [" + msg.data + "]",
- time: new Date(),
- },
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(messageEvent);
-
- var msgs = new Array();
- var idx = 0;
- msgs[idx] = '';
- var c = 0;
- var instring = false;
- for(c = 0; c < msg.data.length; c++) {
- if(msg.data[c] == '"' && c > 0 && msg.data[c - 1] != '\\') instring = !instring;
- if(msg.data[c] == ';' && instring == false) {
- idx++;
- msgs[idx] = '';
- }
- if(msg.data[c] != ';' || instring == true) msgs[idx] += msg.data[c];
- }
-
- f = 0;
- while (f < msgs.length - 1) {
- var msg = new Array();
- instring = false;
- idx = 0;
-
- // Strip padding and trailing whitespace.
- var msgstr = msgs[f].replace(/^\s+||\s+$/g,'');
-
- if(msgstr == ';') {
- f++;
- continue;
- }
-
- msg[idx] = '';
- for(c = 0; c < msgstr.length; c++) {
- if(msgstr[c] == '"' && c > 0 && msgstr[c - 1] != '\\') {
- instring = !instring;
- continue;
- }
- if(msgstr[c] == ' ' && instring == false) {
- msg[idx] = msg[idx].replace("\\\\","\\").replace("\\\"","\"");
- idx++;
- msg[idx] = '';
- }
- if(msgstr[c] != ' ' || instring == true) msg[idx] += msgstr[c];
- }
-
- var subscribeid = msg[0];
- var cmd = msg[1];
- var id = msg[2];
-
- if(cmd == "remove") {
- var removeEvent = new CustomEvent("removeEvent", {
- detail: {
- subscribeid: subscribeid,
- id: id,
- },
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(removeEvent);
- }
- else if(cmd == "move") {
- var moveEvent = new CustomEvent("moveEvent", {
- detail: {
- subscribeid: subscribeid,
- id: id,
- parentid: msg[3],
- },
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(moveEvent);
- }
- else if(cmd == "create") {
- var createEvent = new CustomEvent("createEvent", {
- detail: {
- subscribeid: subscribeid,
- id: id,
- parentid: msg[3],
- },
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(createEvent);
- }
- else if(cmd == "update") {
- var updateEvent = new CustomEvent("updateEvent", {
- detail: {
- subscribeid: subscribeid,
- id: id,
- name: msg[3],
- value: msg[4],
- },
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(updateEvent);
- }
- f++;
- }
- }
-
- socket_node.onclose = function(){
- var disconnectEvent = new CustomEvent("disconnectEvent", {
- detail: {
- time: new Date(),
- },
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(disconnectEvent);
- }
-} catch(exception) {
- alert('<p>Error' + exception + '</p>');
+try
+{
+ socket_node.onopen = function()
+ {
+ var connectEvent = new CustomEvent("connectEvent",
+ {
+ detail: {
+ time: new Date(),
+ },
+ bubbles: true,
+ cancelable: true
+ });
+ document.dispatchEvent(connectEvent);
+ };
+
+ socket_node.onmessage = function got_packet(msg)
+ {
+ var messageEvent = new CustomEvent("messageEvent",
+ {
+ detail: {
+ message: "recv [" + msg.data + "]",
+ time: new Date(),
+ },
+ bubbles: true,
+ cancelable: true
+ });
+ document.dispatchEvent(messageEvent);
+
+ var msgs = new Array();
+ var idx = 0;
+ msgs[idx] = '';
+ var c = 0;
+ var instring = false;
+ for(c = 0; c < msg.data.length; c++)
+ {
+ if(msg.data[c] == '"' && c > 0 && msg.data[c - 1] != '\\')
+ {
+ instring = !instring;
+ }
+ if(msg.data[c] == ';' && instring == false)
+ {
+ idx++;
+ msgs[idx] = '';
+ }
+ if(msg.data[c] != ';' || instring == true)
+ {
+ msgs[idx] += msg.data[c];
+ }
+ }
+
+ f = 0;
+ while (f < msgs.length - 1)
+ {
+ var msg = new Array();
+ instring = false;
+ idx = 0;
+
+ // Strip padding and trailing whitespace.
+ var msgstr = msgs[f].replace(/^\s+||\s+$/g,'');
+
+ if(msgstr == ';')
+ {
+ f++;
+ continue;
+ }
+
+ msg[idx] = '';
+ for(c = 0; c < msgstr.length; c++)
+ {
+ if(msgstr[c] == '"' && c > 0 && msgstr[c - 1] != '\\') {
+ instring = !instring;
+ continue;
+ }
+ if(msgstr[c] == ' ' && instring == false) {
+ msg[idx] = msg[idx].replace("\\\\","\\").replace("\\\"","\"");
+ idx++;
+ msg[idx] = '';
+ }
+ if(msgstr[c] != ' ' || instring == true) msg[idx] += msgstr[c];
+ }
+
+ var subscribeid = msg[0];
+ var cmd = msg[1];
+ var id = msg[2];
+
+ if(cmd == "remove")
+ {
+ var removeEvent = new CustomEvent("removeEvent",
+ {
+ detail: {
+ subscribeid: subscribeid,
+ id: id,
+ },
+ bubbles: true,
+ cancelable: true
+ });
+ document.dispatchEvent(removeEvent);
+ }
+ else if(cmd == "move")
+ {
+ var moveEvent = new CustomEvent("moveEvent",
+ {
+ detail: {
+ subscribeid: subscribeid,
+ id: id,
+ parentid: msg[3],
+ },
+ bubbles: true,
+ cancelable: true
+ });
+ document.dispatchEvent(moveEvent);
+ }
+ else if(cmd == "create")
+ {
+ var createEvent = new CustomEvent("createEvent",
+ {
+ detail: {
+ subscribeid: subscribeid,
+ id: id,
+ parentid: msg[3],
+ },
+ bubbles: true,
+ cancelable: true
+ });
+ document.dispatchEvent(createEvent);
+ }
+ else if(cmd == "update")
+ {
+ var updateEvent = new CustomEvent("updateEvent",
+ {
+ detail: {
+ subscribeid: subscribeid,
+ id: id,
+ name: msg[3],
+ value: msg[4],
+ },
+ bubbles: true,
+ cancelable: true
+ });
+ document.dispatchEvent(updateEvent);
+ }
+ f++;
+ }
+ };
+
+ socket_node.onclose = function(){
+ var disconnectEvent = new CustomEvent("disconnectEvent",
+ {
+ detail: {
+ time: new Date(),
+ },
+ bubbles: true,
+ cancelable: true
+ });
+ document.dispatchEvent(disconnectEvent);
+ };
+}
+catch(exception)
+{
+ alert('<p>Error' + exception + '</p>');
}
function transmit(msg)
{
- //LogEvent(msg);
- var messageEvent = new CustomEvent("messageEvent", {
- detail: {
- message: "send [" + msg + "]",
- time: new Date(),
- },
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(messageEvent);
-
- socket_node.send(msg);
+ //LogEvent(msg);
+ var messageEvent = new CustomEvent("messageEvent",
+ {
+ detail: {
+ message: "send [" + msg + "]",
+ time: new Date(),
+ },
+ bubbles: true,
+ cancelable: true
+ });
+ document.dispatchEvent(messageEvent);
+
+ socket_node.send(msg);
}
function login(user, password)
{
- transmit("login "+user+" "+password);
+ transmit("login "+user+" "+password);
}
function logout()
{
- transmit("logout");
+ transmit("logout");
}
function subscribe(id)
{
- transmit("subscribe "+id);
+ transmit("subscribe "+id);
}
function unsubscribe(id)
{
- transmit("unsubscribe "+id);
+ transmit("unsubscribe "+id);
}
function create(id, parent)
{
- transmit("create "+id+" "+parent);
+ transmit("create "+id+" "+parent);
}
function remove(id)
{
- transmit("remove "+id);
+ transmit("remove "+id);
}
function update(id, name, value)
{
- transmit("update "+id+" "+name+" "+value);
+ transmit("update "+id+" "+name+" "+value);
}
function move(id, parent)
{
- transmit("move "+id+" "+parent);
+ transmit("move "+id+" "+parent);
}
-
-
diff --git a/src/ws/view.js b/src/ws/view.js
index 5f98587..18dfb91 100644
--- a/src/ws/view.js
+++ b/src/ws/view.js
@@ -1,20 +1,20 @@
-/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set et sw=2 ts=2: */
/*
function createNode()
{
- var node = new Node();
- node.id = 42;
- node.dump = function() {
- alert(this.id);
- }
+ var node = new Node();
+ node.id = 42;
+ node.dump = function()
+ {
+ alert(this.id);
+ }
}
*/
function getNode(subscribeid, id)
{
-
}
function updateNode(subscribeid, id, name, value)
@@ -23,83 +23,95 @@ function updateNode(subscribeid, id, name, value)
function getBoard(subscribeid)
{
- var board = document.getElementById("board_" + subscribeid);
- if(!board) {
- board = document.createElement("div");
- board.name = "board";
- board.setAttribute("class", "board");
- board.id = "board_" + subscribeid;
- boards.appendChild(board);
- }
+ var board = document.getElementById("board_" + subscribeid);
+ if(!board)
+ {
+ board = document.createElement("div");
+ board.name = "board";
+ board.setAttribute("class", "board");
+ board.id = "board_" + subscribeid;
+ boards.appendChild(board);
+ }
- return board;
+ return board;
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
-function clear() {
- document.getElementById("input_data").value = "";
+function clear()
+{
+ document.getElementById("input_data").value = "";
}
-function deleteNode(id) {
- remove(id);
+function deleteNode(id)
+{
+ remove(id);
}
-function drag(target, e) {
- e.dataTransfer.setData('Text', target.id);
- e.stopPropagation(); // <--- this fixes the drag target problem
+function drag(target, e)
+{
+ e.dataTransfer.setData('Text', target.id);
+ e.stopPropagation(); // <--- this fixes the drag target problem
}
-function drop(target, e) {
- e.preventDefault();
- e.stopPropagation();
+function drop(target, e)
+{
+ e.preventDefault();
+ e.stopPropagation();
- var id = e.dataTransfer.getData('Text');
- var node = document.getElementById(id);
- move(idFromStr(id), idFromStr(target.id));
+ var id = e.dataTransfer.getData('Text');
+ var node = document.getElementById(id);
+ move(idFromStr(id), idFromStr(target.id));
}
function subscribeMe(target, e)
{
- e.stopPropagation();
- subscribe(target.title);
+ e.stopPropagation();
+ subscribe(target.title);
}
function unsubscribeMe(target, e)
{
- e.stopPropagation();
- unsubscribe(target.title);
+ e.stopPropagation();
+ unsubscribe(target.title);
}
function showHideChildren(target, e)
{
- e.stopPropagation();
- updateid = idFromStr(target.id);
- if(target.style.backgroundColor != "red") {
- target.style.backgroundColor = "red";
- for(var i = 1; i < target.childNodes.length; i++) {
- target.childNodes[i].style.display = "none";
- }
- } else {
- target.style.backgroundColor = "grey";
- for(var i = 1; i < target.childNodes.length; i++) {
- target.childNodes[i].style.display = "block";
- }
- }
-}
-
-function node_submit() {
- var data = document.getElementById("input_node_data");
- transmit(data.value);
- data.value = "";
+ e.stopPropagation();
+ updateid = idFromStr(target.id);
+ if(target.style.backgroundColor != "red")
+ {
+ target.style.backgroundColor = "red";
+ for(var i = 1; i < target.childNodes.length; i++)
+ {
+ target.childNodes[i].style.display = "none";
+ }
+ }
+ else
+ {
+ target.style.backgroundColor = "grey";
+ for(var i = 1; i < target.childNodes.length; i++)
+ {
+ target.childNodes[i].style.display = "block";
+ }
+ }
+}
+
+function node_submit()
+{
+ var data = document.getElementById("input_node_data");
+ transmit(data.value);
+ data.value = "";
}
function node_submit_KeyUpHandler(target, e)
{
- if(e.which == 13) { // enter
- node_submit();
- }
+ if(e.which == 13)
+ { // enter
+ node_submit();
+ }
}
//
@@ -111,41 +123,47 @@ var oldtxt;
var oldtitle;
function onKeyUpHandler(target, e)
{
- if(e.which == 13) { // enter
- divtxt.removeChild(target);
- oldtxt.nodeValue = 'updating...';
- update(updateid, "title", target.value);
- }
- if(e.which == 27) { // escape
- divtxt.removeChild(target);
- oldtxt.nodeValue = oldtitle;
- }
+ if(e.which == 13)
+ { // enter
+ divtxt.removeChild(target);
+ oldtxt.nodeValue = 'updating...';
+ update(updateid, "title", target.value);
+ }
+ if(e.which == 27)
+ { // escape
+ divtxt.removeChild(target);
+ oldtxt.nodeValue = oldtitle;
+ }
}
function onLostFocusHandler(target, e)
{
- if(target.value == oldtitle) {
- divtxt.removeChild(target);
- oldtxt.nodeValue = oldtitle;
- }
+ if(target.value == oldtitle)
+ {
+ divtxt.removeChild(target);
+ oldtxt.nodeValue = oldtitle;
+ }
}
function editTitle(target, e)
{
- e.stopPropagation();
- updateid = idFromStr(target.id);
- if(updateid < 10) return;
- var inp = document.createElement("input");
- var txtdiv = document.getElementById(target.id + "_txt");
- divtxt = txtdiv;
- oldtxt = txtdiv.firstChild;
- oldtitle = oldtxt.nodeValue;
- oldtxt.nodeValue = "";
- inp.setAttribute("onkeyup", "onKeyUpHandler(this, event)");
- inp.setAttribute("onblur", "onLostFocusHandler(this, event)");
- inp.setAttribute("style", "border: inherit; padding: inherit; margin: inherit; background: inherit;");
- inp.value = oldtitle;
- lineedit = inp;
- txtdiv.appendChild(inp);
- inp.focus();
+ e.stopPropagation();
+ updateid = idFromStr(target.id);
+ if(updateid < 10)
+ {
+ return;
+ }
+ var inp = document.createElement("input");
+ var txtdiv = document.getElementById(target.id + "_txt");
+ divtxt = txtdiv;
+ oldtxt = txtdiv.firstChild;
+ oldtitle = oldtxt.nodeValue;
+ oldtxt.nodeValue = "";
+ inp.setAttribute("onkeyup", "onKeyUpHandler(this, event)");
+ inp.setAttribute("onblur", "onLostFocusHandler(this, event)");
+ inp.setAttribute("style", "border: inherit; padding: inherit; margin: inherit; background: inherit;");
+ inp.value = oldtitle;
+ lineedit = inp;
+ txtdiv.appendChild(inp);
+ inp.focus();
}