/* Functions driving the CherryPy backend */
-function new_tag(path) {
- alert('Adding tag: '+path.toString());
+function reload_rdf(e) {
/* https://developer.mozilla.org/en/RDF_in_Mozilla_FAQ */
+ if (e.readyState == 4) { /* 4: request finished and response is ready */
+ if(e.status != 200) {
+ alert("Error loading page\n\n"+e.responseText);
+ return;
+ }
+ // Get the RDF service
+ var RDF =
+ Components
+ .classes['@mozilla.org/rdf/rdf-service;1']
+ .getService(Components.interfaces.nsIRDFService);
+ // Get the datasources and refresh them
+ RDF.GetDataSource('raw.rdf').Refresh('non-blocking');
+ RDF.GetDataSource('tag.rdf').Refresh('non-blocking');
+ }
+}
+
+function push_data(url) {
+ /* https://developer.mozilla.org/en/using_xmlhttprequest */
+ xmlDoc = new XMLHttpRequest();
+ xmlDoc.open('GET', url, true);
+ xmlDoc.onreadystatechange = function() { reload_rdf(xmlDoc); };
+ xmlDoc.send(null);
+}
+
+function new_tag(tag) {
+ push_data('/new_tag?tag='+escape(tag.join('/')));
}
function add_tag(path, tag) {
- alert('Add tag '+tag+' to '+path.toString());
+ push_data('/add_tag?path='+escape(path.join('/'))
+ +'&tag='+escape(tag.join('/')));
}
function remove_tag(path, tag) {
- alert('Remove tag '+tag+' from '+path.toString());
+ push_data('/remove_tag?path='+escape(path.join('/'))
+ +'&tag='+escape(tag.join('/')));
}
/* The bindings themselves */
function set_selected_element(path) {
element = document.getElementById('element');
element.file_path = path;
- alert('Set selected element: '+path.toString());
}
function raw_tree_select() {
var path = document.getElementById('element').file_path;
var name = tree.columns.getPrimaryColumn();
id = tree_path(tree, row);
- if (value == true || value == "true") {
+ if (path == 'UNDEFINED') {
+ return;
+ } else if (value == true || value == 'true') {
add_tag(path, id);
} else {
remove_tag(path, id);