From 6b877339ee9ff46380d23a14cad152a7c3ae266e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 18 Jul 2010 03:20:30 -0400 Subject: [PATCH] Broken implementation (multiple hits on some clicks) --- static/dirtag.js | 84 ++++++++++++++++++++++++++++++++++++--------- template/dirtag.xul | 13 +++---- 2 files changed, 71 insertions(+), 26 deletions(-) diff --git a/static/dirtag.js b/static/dirtag.js index b6f5373..30626a3 100644 --- a/static/dirtag.js +++ b/static/dirtag.js @@ -13,7 +13,7 @@ function tree_path(tree, row) { var name = tree.columns.getPrimaryColumn(); var path = new Array(); while (row >= 0) { - path.splice(0, 0, tree.view.getCellText(row, name)); + path.splice(0, 0, split_checkbox_value(tree.view.getCellText(row, name))[1]); row = tree.view.getParentIndex(row); } return path; @@ -36,14 +36,41 @@ function tag_in_tags(tag, tags) { return tag.join('/') in o; } +function join_checkbox_value(name, value) { + var v = ' '; + if (value == true) + v = '+'; + return '('+v+') ' + name; +} + +function split_checkbox_value(text) { + if (text.length > 3 && text[0] == '(' && text[2] == ')') { + return [text[1] == '+', text.slice(4)]; + } + return [false, text]; // No checkbox set yet. +} + +function get_checkbox_value(tree, row) { + var name = tree.columns.getPrimaryColumn(); + var text = tree.view.getCellText(row, name); + return split_checkbox_value(text)[0]; +} + +function set_checkbox_value(tree, row, value) { + var name = tree.columns.getPrimaryColumn(); + var text = tree.view.getCellText(row, name); + text = split_checkbox_value(text)[1]; + tree.view.setCellText(row, name, join_checkbox_value(text, value)); +} + function setup_checkboxes(tags) { + //alert(tags); var tree = document.getElementById('checkbox-tree'); - var ctags = tree.columns.getLastColumn(); for (var row=0; row - - + - @@ -129,7 +125,6 @@ - -- 2.26.2