1 /* Useful helper functions */
3 function tree_path(tree, row) {
4 var name = tree.columns.getPrimaryColumn();
5 var path = new Array();
7 path.splice(0, 0, tree.view.getCellText(row, name));
8 row = tree.view.getParentIndex(row);
13 function tree_selection(id) {
14 var tree = document.getElementById(id);
15 return tree_path(tree, tree.currentIndex);
18 /* Functions driving the CherryPy backend */
20 function new_tag(path) {
21 alert('Adding tag: '+path.toString());
22 /* https://developer.mozilla.org/en/RDF_in_Mozilla_FAQ */
25 function add_tag(path, tag) {
26 alert('Add tag '+tag+' to '+path.toString());
29 function remove_tag(path, tag) {
30 alert('Remove tag '+tag+' from '+path.toString());
33 /* The bindings themselves */
35 function initialize() {
36 element = document.getElementById('element').file_path = 'UNDEFINED';
37 var tree = document.getElementById('checkbox-tree');
38 tree.view.origSetCellValue = tree.view.setCellValue;
39 tree.view.setCellValue = function (row, col, value) {
40 tree.view.origSetCellValue(row, col, value);
41 checkbox_activity(tree, row, col, value);
45 function new_tag_button() {
46 var text = document.getElementById('new-tag-text').value;
47 new_tag(text.split('/'));
50 function set_selected_element(path) {
51 element = document.getElementById('element');
52 element.file_path = path;
53 alert('Set selected element: '+path.toString());
56 function raw_tree_select() {
57 set_selected_element(tree_selection('raw-tree'));
60 function tag_tree_select() {
61 set_selected_element(tree_selection('tag-tree'));
64 function checkbox_activity(tree, row, col, value) {
65 var path = document.getElementById('element').file_path;
66 var name = tree.columns.getPrimaryColumn();
67 id = tree_path(tree, row);
68 if (value == true || value == "true") {