]> code.citadel.org Git - citadel.git/blobdiff - webcit/static/wclib.js
Complete overhaul of "Notes" view. Now features AJAX create and edit operations.
[citadel.git] / webcit / static / wclib.js
index 8eedfcde19ca5a1167992cc7ad64d924031deb73..bf4ae9aa9876ff4e202b32aef0f34b3bf7704e84 100644 (file)
@@ -18,22 +18,32 @@ if (window.navigator.userAgent.toLowerCase().match("gecko")) {
 var ns6=document.getElementById&&!document.all;
 
 
-//
-// This code handles the popups for instant messages.
-//
 
+// We love string tokenizers.
+function extract_token(source_string, token_num, delimiter) {
+       var i = 0;
+       var extracted_string = source_string;
 
-function hide_page_popup() {
-       if (browserType == "gecko" )
-               document.poppedLayer = eval('document.getElementById(\'page_popup\')');
-       else if (browserType == "ie")
-               document.poppedLayer = eval('document.all[\'page_popup\']');
-       else
-               document.poppedLayer = eval('document.layers[\'`page_popup\']');
+       if (token_num > 0) {
+               for (i=0; i<token_num; ++i) {
+                       var j = extracted_string.indexOf(delimiter);
+                       if (j >= 0) {
+                               extracted_string = extracted_string.substring(j+1);
+                       }
+               }
+       }
 
-       document.poppedLayer.style.visibility = "hidden";
+       j = extracted_string.indexOf(delimiter);
+       if (j >= 0) {
+               extracted_string = extracted_string.substring(0, j);
+       }
+
+       return extracted_string;
 }
 
+
+
+// This code handles the popups for important-messages.
 function hide_imsg_popup() {
        if (browserType == "gecko" )
                document.poppedLayer = eval('document.getElementById(\'important_message\')');
@@ -45,6 +55,7 @@ function hide_imsg_popup() {
        document.poppedLayer.style.visibility = "hidden";
 }
 
+
 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
 function activate_entmsg_autocompleters() {
        new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
@@ -71,14 +82,25 @@ function expand_floor(floor_div) {
                        $(which_div_expanded).style.display = 'none' ;
                }
        }
+
+       // clicking on the already-expanded floor causes the whole list to collapse
        if (which_div_expanded == floor_div) {
                which_div_expanded = null;
+
+               // notify the server that no floors are expanded
+               new Ajax.Request(
+                       'set_floordiv_expanded/-1', {
+                               method: 'post'
+                       }
+               );
                return true;
        }
+
+       // expand the requested floor
        $(floor_div).style.display = 'block';
        which_div_expanded = floor_div;
 
-       // notify the server of what we did
+       // notify the server of which floor is expanded
        new Ajax.Request(
                'set_floordiv_expanded/'+floor_div, {
                        method: 'post'
@@ -443,3 +465,19 @@ function ctdl_ts_getInnerText(el) {
 }
 
 
+
+// This function handles the creation of new notes in the "Notes" view.
+//
+function add_new_note() {
+
+       new_eid = Math.random() + '';
+       new_eid = new_eid.substr(3);
+
+       $('new_notes_here').innerHTML = $('new_notes_here').innerHTML
+               + '<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\">'
+               + '<span id=\"note' + new_eid + '\">' + Date() + '</span><br />'
+       ;
+
+       new Ajax.InPlaceEditor('note' + new_eid,
+               'updatenote?eid=' + new_eid , {rows:5,cols:72});
+}