+ return [tree_path(tree, tree.currentIndex),
+ tree_tags(tree, tree.currentIndex),];
+}
+
+function tag_in_tags(tag, tags) {
+ /* Convert a regular array into an associative array for 'in' comparisons
+ http://snook.ca/archives/javascript/testing_for_a_v
+ */
+ var o = {};
+ for(var i=0; i<tags.length; i++) {
+ o[tags[i].join('/')] = ''; // .join('/') b/c indexes must be strings
+ }
+ return tag.join('/') in o;
+}
+
+function setup_checkboxes(tags) {
+ var tree = document.getElementById('checkbox-tree');
+ var ctags = tree.columns.getLastColumn();
+ for (var row=0; row<tree.view.rowCount; row++) {
+ p = tree_path(tree, row);
+ tree.view.origSetCellValue(row, ctags, tag_in_tags(p, tags));
+ }
+ tree.treeBoxObject.invalidateColumn(ctags);