From 9fa00515500c1a7d5d2452be69dd33ff0e62c0c6 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 18 May 2012 13:20:02 +0200 Subject: Ugly implementation of inline-title edit on double click. --- proto.js | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 20 deletions(-) diff --git a/proto.js b/proto.js index f3cece5..92f90fc 100644 --- a/proto.js +++ b/proto.js @@ -57,6 +57,30 @@ var BrowserDetect = { BrowserDetect.init(); +function createId(boardid, taskid) +{ + return "b" + boardid + "_t" + taskid; +} + +function idFromStr(str) +{ + return str.substring(str.search('t') + 1, str.length); +} + +function getElementsByClass(searchClass, domNode, tagName) { + if (domNode == null) domNode = document; + if (tagName == null) tagName = '*'; + var el = new Array(); + var tags = domNode.getElementsByTagName(tagName); + var tcl = " "+searchClass+" "; + for(i=0,j=0; i Date: Fri, 18 May 2012 13:20:38 +0200 Subject: Change some board styling. --- munia.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/munia.html b/munia.html index 0989b49..1ca63c5 100644 --- a/munia.html +++ b/munia.html @@ -36,8 +36,9 @@ body { .board { width: *; - min-height: 300px; - padding: 20px;\ + min-height: 100px; + padding: 2px; + margin: 2px; background: -moz-linear-gradient(left center, rgb(0,0,0), rgb(79,79,79), rgb(21,21,21)); background: -webkit-gradient(linear, left top, right top, -- cgit v1.2.3 From 8faeeeebf08bd9fdef16c44da0b150c9285024f8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 18 May 2012 13:47:37 +0200 Subject: Ugly hack to feed filename from cli. --- src/muniad.cc | 15 ++++++++++++--- src/taskmanager.cc | 15 ++++++++++----- src/taskmanager.h | 4 +++- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/muniad.cc b/src/muniad.cc index 741241a..b9651dd 100644 --- a/src/muniad.cc +++ b/src/muniad.cc @@ -38,6 +38,8 @@ #include "http.h" #include "munia_proto.h" #include "debug.h" +#include "taskmanager.h" +extern TaskManager task_manager; static struct libwebsocket_protocols protocols[] = { // first protocol must always be HTTP handler @@ -51,6 +53,7 @@ static struct libwebsocket_protocols protocols[] = { static struct option options[] = { { "help", no_argument, NULL, 'h' }, { "port", required_argument, NULL, 'p' }, + { "file", required_argument, NULL, 'f' }, { "ssl", no_argument, NULL, 's' }, { "killmask", no_argument, NULL, 'k' }, { "interface", required_argument, NULL, 'i' }, @@ -60,6 +63,7 @@ static struct option options[] = { int main(int argc, char **argv) { + const char *db_filename = "/tmp/munia.xml"; int n = 0; const char *cert_path = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem"; @@ -84,7 +88,7 @@ int main(int argc, char **argv) "There is NO WARRANTY, to the extent permitted by law.\n"); while(n >= 0) { - n = getopt_long(argc, argv, "ci:khsp:", options, NULL); + n = getopt_long(argc, argv, "ci:khsp:f:", options, NULL); if(n < 0) continue; switch(n) { case 's': @@ -98,19 +102,24 @@ int main(int argc, char **argv) case 'p': port = atoi(optarg); break; - case 'i': + case 'f': + db_filename = strdup(optarg); + break; + case 'i': strncpy(interface_name, optarg, sizeof interface_name); interface_name[(sizeof interface_name) - 1] = '\0'; interface = interface_name; break; case 'h': - fprintf(stderr, "Usage: muniad [--port=

] [--ssl]\n"); + fprintf(stderr, "Usage: muniad [--port=

] [--ssl] [--file=]\n"); exit(1); } } debug_parse("+all"); + task_manager.init(db_filename); + if(!use_ssl) cert_path = key_path = NULL; context = libwebsocket_create_context(port, interface, protocols, diff --git a/src/taskmanager.cc b/src/taskmanager.cc index 0d15eb6..c7cdb6d 100644 --- a/src/taskmanager.cc +++ b/src/taskmanager.cc @@ -44,10 +44,18 @@ static bool isProtected(taskid_t id) return id < FIRST_TASK_ID; } -TaskManager::TaskManager(std::string file) { +TaskManager::TaskManager() { idCount = FIRST_TASK_ID; - this->file = file; +} + +TaskManager::~TaskManager() { +} + +void TaskManager::init(std::string filename) +{ + printf("Reading tasks from file: %s\n", filename.c_str()); + file = filename; FILE *fp = fopen(file.c_str(), "r"); if(fp) { @@ -87,9 +95,6 @@ TaskManager::TaskManager(std::string file) { tree.toStdOut(); } -TaskManager::~TaskManager() { -} - task_t TaskManager::task(taskid_t t) { return tree.data(t); } diff --git a/src/taskmanager.h b/src/taskmanager.h index 52daa05..e11736b 100644 --- a/src/taskmanager.h +++ b/src/taskmanager.h @@ -40,9 +40,11 @@ typedef std::pair TaskIdListPair; class TaskManager { public: - TaskManager(std::string file = "/tmp/munia.xml"); + TaskManager(); ~TaskManager(); + void init(std::string filename); + TaskIdList createTask(taskid_t parentid, taskid_t *id) throw (std::exception); TaskIdList updateTask(taskid_t id, task_t task) throw (std::exception); TaskIdList removeTask(taskid_t id) throw (std::exception); -- cgit v1.2.3 From f3612d1e091f856523f8cdfc933f31c0fad8f8cb Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 18 May 2012 13:48:09 +0200 Subject: Remove annoying and broken opacity. --- proto.js | 1 - 1 file changed, 1 deletion(-) diff --git a/proto.js b/proto.js index 92f90fc..b6ecf25 100644 --- a/proto.js +++ b/proto.js @@ -253,7 +253,6 @@ function deleteTask(id) { } function drag(target, e) { - e.target.style.opacity = '0.4'; e.dataTransfer.setData('Text', target.id); e.stopPropagation(); // <--- this fixes the drag target problem } -- cgit v1.2.3 From a0875731dc7b8bded86d6816925bdfdeff87805c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 18 May 2012 14:39:08 +0200 Subject: Reorder layout --- munia.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/munia.html b/munia.html index 1ca63c5..a5e0f14 100644 --- a/munia.html +++ b/munia.html @@ -51,12 +51,12 @@ body { +

TaskProto not initialized
TaskProto:
TaskMessages:
-
!
-- cgit v1.2.3 From 7b669ca2dd286de7875fd208b6e6047c8bfd4a1e Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 18 May 2012 14:39:37 +0200 Subject: Close title editor when leaving focus if title was not yet changed. --- proto.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/proto.js b/proto.js index b6ecf25..5c7a1d5 100644 --- a/proto.js +++ b/proto.js @@ -67,20 +67,6 @@ function idFromStr(str) return str.substring(str.search('t') + 1, str.length); } -function getElementsByClass(searchClass, domNode, tagName) { - if (domNode == null) domNode = document; - if (tagName == null) tagName = '*'; - var el = new Array(); - var tags = domNode.getElementsByTagName(tagName); - var tcl = " "+searchClass+" "; - for(i=0,j=0; i Date: Fri, 18 May 2012 14:52:20 +0200 Subject: Simple but messy hide/show functionality on child nodes. --- proto.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/proto.js b/proto.js index 5c7a1d5..b8873fe 100644 --- a/proto.js +++ b/proto.js @@ -183,6 +183,7 @@ try { 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); @@ -254,6 +255,23 @@ function drop(target, e) { socket_task.send("move " + idFromStr(id) + " " + idFromStr(target.id) + ";"); } +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"; + } + } +} + // // Butt ugly.. but hey! it works... // @@ -285,8 +303,8 @@ function onLostFocusHandler(target, e) function editTitle(target, e) { e.stopPropagation(); - updateid = idFromStr(target.id) - if(updateid < 10) return; + updateid = idFromStr(target.id); + if(updateid < 10) return; var inp = document.createElement("input"); var txtdiv = document.getElementById(target.id + "_txt"); divtxt = txtdiv; @@ -300,4 +318,4 @@ function editTitle(target, e) lineedit = inp; txtdiv.appendChild(inp); inp.focus(); -} \ No newline at end of file +} -- cgit v1.2.3