var browserType;
+var room_is_trash = 0;
if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
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\')');
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', {} );
}
+
+// Toggle the icon bar between menu/roomlist...
+var which_div_expanded = null;
+var num_drop_targets = 0;
+var drop_targets_elements = new Array();
+var drop_targets_roomnames = new Array();
+
+function switch_to_room_list() {
+ $('iconbar').innerHTML = $('iconbar').innerHTML.substr(0, $('iconbar').innerHTML.indexOf('switch'));
+ new Ajax.Updater('iconbar', 'iconbar_ajax_rooms', { method: 'get' } );
+}
+
+function expand_floor(floor_div) {
+ if (which_div_expanded != null) {
+ if ($(which_div_expanded) != null) {
+ $(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 which floor is expanded
+ new Ajax.Request(
+ 'set_floordiv_expanded/'+floor_div, {
+ method: 'post'
+ }
+ );
+}
+
+function switch_to_menu_buttons() {
+ which_div_expanded = null;
+ num_drop_targets = 0;
+ new Ajax.Updater('iconbar', 'iconbar_ajax_menu', { method: 'get' } );
+}
+
+
// Static variables for mailbox view...
//
var CtdlNumMsgsSelected = 0;
// Delete selected messages.
function CtdlDeleteSelectedMessages(evt) {
+ if (CtdlNumMsgsSelected < 1) {
+ // Nothing to delete, so exit silently.
+ return false;
+ }
+ for (i=0; i<CtdlNumMsgsSelected; ++i) {
+ if (parseInt(room_is_trash) > 0) {
+ new Ajax.Request(
+ 'ajax_servcmd', {
+ method: 'post',
+ parameters: 'g_cmd=DELE ' + CtdlMsgsSelected[i],
+ onComplete: CtdlClearDeletedMsg(CtdlMsgsSelected[i])
+ }
+ );
+ }
+ else {
+ new Ajax.Request(
+ 'ajax_servcmd', {
+ method: 'post',
+ parameters: 'g_cmd=MOVE ' + CtdlMsgsSelected[i] + '|_TRASH_|0',
+ onComplete: CtdlClearDeletedMsg(CtdlMsgsSelected[i])
+ }
+ );
+ }
+ }
+ CtdlNumMsgsSelected = 0;
+
+ // Clear the preview pane too.
+ $('preview_pane').innerHTML = '';
+}
+
+
+// Move selected messages.
+function CtdlMoveSelectedMessages(evt, target_roomname) {
+
if (CtdlNumMsgsSelected < 1) {
// Nothing to delete, so exit silently.
return false;
for (i=0; i<CtdlNumMsgsSelected; ++i) {
new Ajax.Request(
'ajax_servcmd', {
- method: 'post',
- parameters: 'g_cmd=MOVE ' + CtdlMsgsSelected[i] + '|_TRASH_|0',
- onComplete: CtdlClearDeletedMsg(CtdlMsgsSelected[i])
+ method:'post',
+ parameters:'g_cmd=MOVE ' + CtdlMsgsSelected[i] + '|' + target_roomname + '|0',
+ onComplete:CtdlClearDeletedMsg(CtdlMsgsSelected[i])
}
);
}
$('preview_pane').innerHTML = '';
}
+
+
// This gets called when the user touches the keyboard after selecting messages...
function CtdlMsgListKeyPress(evt) {
if(document.all) { // aIEeee
mm_div = null;
}
+ if (num_drop_targets < 1) { // nowhere to drop
+ return true;
+ }
+
// Did we release the mouse button while hovering over a drop target?
// NOTE: this only works cross-browser because the iconbar div is always
// positioned at 0,0. Browsers differ in whether the 'offset'
// functions return pos relative to the document or parent.
- x = (ns6 ? evt.clientX : event.clientX);
- y = (ns6 ? evt.clientY : event.clientY);
+ for (i=0; i<num_drop_targets; ++i) {
- l = parseInt($('dropstuff').offsetLeft);
- t = parseInt($('dropstuff').offsetTop);
- r = parseInt($('dropstuff').offsetLeft) + parseInt($('dropstuff').offsetWidth);
- b = parseInt($('dropstuff').offsetTop) + parseInt($('dropstuff').offsetHeight);
+ x = (ns6 ? evt.clientX : event.clientX);
+ y = (ns6 ? evt.clientY : event.clientY);
- if ( (x >= l) && (x <= r) && (y >= t) && (y <= b) ) {
- // Yes, we dropped it on a hotspot. Just delete for now... FIXME
- CtdlDeleteSelectedMessages(evt);
+ l = parseInt(drop_targets_elements[i].offsetLeft);
+ t = parseInt(drop_targets_elements[i].offsetTop);
+ r = parseInt(drop_targets_elements[i].offsetLeft)
+ + parseInt(drop_targets_elements[i].offsetWidth);
+ b = parseInt(drop_targets_elements[i].offsetTop)
+ + parseInt(drop_targets_elements[i].offsetHeight);
+
+ /* alert('Offsets are: ' + l + ' ' + t + ' ' + r + ' ' + b + '.'); */
+
+ if ( (x >= l) && (x <= r) && (y >= t) && (y <= b) ) {
+ // Yes, we dropped it on a hotspot.
+ CtdlMoveSelectedMessages(evt, drop_targets_roomnames[i]);
+ return true;
+ }
}
return true;
}
return str;
}
+
+
+
+// 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});
+}