--- /dev/null
+/* Useful helper functions */
+
+function tree_selection(id) {
+ var tree = document.getElementById(id);
+ var name = tree.columns.getPrimaryColumn();
+ var i = tree.currentIndex;
+ var path = new Array();
+ while (i >= 0) {
+ path.splice(0, 0, tree.view.getCellText(i, name));
+ i = tree.view.getParentIndex(i);
+ }
+ return path;
+}
+
+/* Functions driving the CherryPy backend */
+
+function new_tag(path) {
+ alert('Adding tag: '+path.toString());
+ /* https://developer.mozilla.org/en/RDF_in_Mozilla_FAQ */
+}
+
+function add_tag(path, tag) {
+ alert('Add tag '+path.toString()+' to '+tag);
+}
+
+function remove_tag(path, tag) {
+ alert('Remove tag '+path.toString()+' from '+tag);
+}
+
+/* The bindings themselves */
+
+function initialize() {
+ element = document.getElementById('element').file_path = 'UNDEFINED';
+}
+
+function new_tag_button() {
+ var text = document.getElementById('new-tag-text').value;
+ new_tag(text.split('/'));
+}
+
+function set_selected_element(path) {
+ element = document.getElementById('element');
+ element.file_path = path;
+ alert(path.toString());
+}
+
+function raw_tree_select() {
+ set_selected_element(tree_selection('raw-tree'));
+}
+
+function tag_tree_select() {
+ set_selected_element(tree_selection('tag-tree'));
+}
+
+function tag_check(event) {
+ var path = document.getElementById('element').file_path;
+ if (event.target.checked) {
+ add_tag(path, event.target.id);
+ } else {
+ remove_tag(path, event.target.id);
+ }
+}