- which_div_expanded = null;
- num_drop_targets = 0;
- CtdlLoadScreen('iconbar');
- new Ajax.Updater('iconbar', 'iconbar_ajax_menu', { method: 'get' } );
-}
-
-
-// Static variables for mailbox view...
-//
-var CtdlNumMsgsSelected = 0;
-var CtdlMsgsSelected = new Array();
-var CtdlLastMsgnumSelected = 0;
-
-// This gets called when you single click on a message in the mailbox view.
-// We know that the element id of the table row will be the letter 'm' plus the message number.
-//
-function CtdlSingleClickMsg(evt, msgnum) {
-
- // Clear the preview pane until we load the new message
- $('preview_pane').innerHTML = '';
-
- // De-select any messages that were already selected, *unless* the Ctrl or
- // Shift key is being pressed, in which case the user wants multi select
- // or group select.
- if ( (!evt.ctrlKey) && (!evt.shiftKey) ) {
- if (CtdlNumMsgsSelected > 0) {
- for (i=0; i<CtdlNumMsgsSelected; ++i) {
- $('m'+CtdlMsgsSelected[i]).style.backgroundColor = '#fff';
- $('m'+CtdlMsgsSelected[i]).style.color = '#000';
- }
- CtdlNumMsgsSelected = 0;
- }
- }
-
- // For multi select ... is the message being clicked already selected?
- already_selected = 0;
- if ( (evt.ctrlKey) && (CtdlNumMsgsSelected > 0) ) {
- for (i=0; i<CtdlNumMsgsSelected; ++i) {
- if (CtdlMsgsSelected[i] == msgnum) {
- already_selected = 1;
- already_selected_pos = i;
- }
- }
- }
-
- // Now select (or de-select) the message
- if ( (evt.ctrlKey) && (already_selected == 1) ) {
-
- // Deselect: first un-highlight it...
- $('m'+msgnum).style.backgroundColor = '#fff';
- $('m'+msgnum).style.color = '#000';
-
- // Then remove it from the selected messages list.
- for (i=already_selected_pos; i<(CtdlNumMsgsSelected-1); ++i) {
- CtdlMsgsSelected[i] = CtdlMsgsSelected[i+1];
- }
- CtdlNumMsgsSelected = CtdlNumMsgsSelected - 1;
-
- }
-
- else if (evt.shiftKey) {
-
- // Group select: first clear everything out...
- if (CtdlNumMsgsSelected > 0) {
- for (i=0; i<CtdlNumMsgsSelected; ++i) {
- $('m'+CtdlMsgsSelected[i]).style.backgroundColor = '#fff';
- $('m'+CtdlMsgsSelected[i]).style.color = '#000';
- }
- }
- CtdlNumMsgsSelected = 0;
-
- // Then highlight and select the group.
- // Traverse the table looking for a row whose ID contains the desired msgnum
-
- var in_the_group = 0;
- var is_edge = 0;
- var table = $('summary_headers');
- if (table) {
- for (var r = 0; r < table.rows.length; r++) {
- var thename = table.rows[r].id;
- if ( (thename.substr(1) == msgnum) || (thename.substr(1) == CtdlLastMsgnumSelected) ) {
- in_the_group = 1 - in_the_group;
- is_edge = 1;
- }
- else {
- is_edge = 0;
- }
- if ( (in_the_group == 1) || (is_edge == 1) ) {
- // Highlight it...
- table.rows[r].style.backgroundColor='#69aaff';
- table.rows[r].style.color='#fff';
-
- // And add it to the selected messages list.
- CtdlNumMsgsSelected = CtdlNumMsgsSelected + 1;
- CtdlMsgsSelected[CtdlNumMsgsSelected-1] = thename.substr(1);
- }
- }
- }
- }
-
- else {
- // Select: first highlight it...
- $('m'+msgnum).style.backgroundColor='#69aaff';
- $('m'+msgnum).style.color='#fff';
-
- // Then add it to the selected messages list.
- CtdlNumMsgsSelected = CtdlNumMsgsSelected + 1;
- CtdlMsgsSelected[CtdlNumMsgsSelected-1] = msgnum;
-
- // Gradient
- CtdlLoadScreen('preview_pane');
- // Update the preview pane
- new Ajax.Updater('preview_pane', 'msg/'+msgnum, { method: 'get' } );
-
- // Mark the message as read
- new Ajax.Request(
- 'ajax_servcmd', {
- method: 'post',
- parameters: 'g_cmd=SEEN '+msgnum+'|1',
- onComplete: CtdlRemoveTheUnseenBold(msgnum)
- }
- );
- }
-
- // Save the selected position in case the user does a group select next time.
- CtdlLastMsgnumSelected = msgnum;
-
- return false; // try to defeat the default click behavior
+ if (roomlist != null) {
+ roomlist.className += "hidden";
+ }
+ var iconbar = document.getElementById("iconbar_menu");
+ iconbar.className = iconbar.className.replace("hidden","");
+ var roomlist = document.getElementById("roomlist");
+ roomlist.className += " hidden";
+}
+
+function GenericTreeRoomList(roomlist) {
+ var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
+ var curRoomName = "";
+ if (document.getElementById("rmname")) {
+ curRoomName = getTextContent(document.getElementById("rmname"));
+ }
+ currentDropTargets = new Array();
+ var iconbar = document.getElementById("iconbar");
+ var ul = document.createElement("ul");
+ roomlist.appendChild(ul);
+ // Add mailbox, because they are special
+ var mailboxLI = document.createElement("li");
+ ul.appendChild(mailboxLI);
+ var mailboxSPAN = document.createElement("span");
+ var _mailbox = getTextContent(document.getElementById("mbox_template"));
+ mailboxSPAN.appendChild(document.createTextNode(_mailbox));
+ $(mailboxSPAN).observe('click', expandFloorEvent);
+ mailboxLI.appendChild(mailboxSPAN);
+ mailboxLI.className = "floor";
+ var mailboxUL = document.createElement("ul");
+ mailboxLI.appendChild(mailboxUL);
+ var mailboxRooms = GetMailboxRooms();
+ for(var i=0; i<mailboxRooms.length; i++) {
+ var room = mailboxRooms[i];
+ currentDropTargets.push(addRoomToList(mailboxUL, room, curRoomName));
+ }
+ if (currentExpanded != null && currentExpanded == _mailbox ) {
+ expandFloor(mailboxSPAN);
+ }
+ for(var a=0; a<floors.length; a++) {
+ var floor = floors[a];
+ var floornum = floor[0];
+
+ if (floornum != -1)
+ {
+
+ var name = floor[1];
+ var floorLI = document.createElement("li");
+ ul.appendChild(floorLI);
+ var floorSPAN = document.createElement("span");
+ floorSPAN.appendChild(document.createTextNode(name));
+ $(floorSPAN).observe('click', expandFloorEvent);
+ floorLI.appendChild(floorSPAN);
+ floorLI.className = "floor";
+ var floorUL = document.createElement("ul");
+ floorLI.appendChild(floorUL);
+ var roomsForFloor = GetRoomsByFloorNum(floornum);
+ for(var b=0; b<roomsForFloor.length; b++) {
+ var room = roomsForFloor[b];
+ currentDropTargets.push(addRoomToList(floorUL, room, curRoomName));
+ }
+ if (currentExpanded != null && currentExpanded == name) {
+ expandFloor(floorSPAN);
+ }
+ }
+ }
+}
+function IconBarRoomList() {
+ roomlist = document.getElementById("roomlist");
+ GenericTreeRoomList(roomlist);
+}
+function KNRoomsRoomList() {
+ roomlist = document.getElementById("roomlist_knrooms");
+ GenericTreeRoomList(roomlist);
+}
+
+function addRoomToList(floorUL,room, roomToEmphasize) {
+ var roomName = room[RN_ROOM_NAME];
+ var flag = room[RN_ROOM_FLAG];
+ var curView = room[RN_CUR_VIEW];
+ var view = room[RN_DEF_VIEW];
+ var raflags = room[RN_RAFLAGS];
+ var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
+ var hasNewMsgs = ((raflags & UA_HASNEWMSGS) == UA_HASNEWMSGS);
+ var roomLI = document.createElement("li");
+ var roomA = document.createElement("a");
+ roomA.setAttribute("href","dotgoto?room="+roomName);
+ roomA.appendChild(document.createTextNode(roomName));
+ roomLI.appendChild(roomA);
+ floorUL.appendChild(roomLI);
+ var className = "room ";
+ if (view == VIEW_MAILBOX) {
+ className += "room-private"
+ } else if (view == VIEW_ADDRESSBOOK) {
+ className += "room-addr";
+ } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
+ className += "room-cal";
+ } else if (view == VIEW_TASKS) {
+ className += "room-tasks";
+ } else if (view == VIEW_NOTES) {
+ className += "room-notes";
+ } else {
+ className += "room-chat";
+ }
+ if (hasNewMsgs) {
+ className += " room-newmsgs";
+ }
+ if (roomName == roomToEmphasize) {
+ className += " room-emphasized";
+ }
+ roomLI.setAttribute("class", className);
+ roomA.dropTarget = true;
+ roomA.dropHandler = roomListDropHandler;
+ return roomLI;
+}
+
+function roomListDropHandler(target, dropped) {
+ if (dropped.getAttribute("citadel:msgid")) {
+ var room = getTextContent(target);
+ var msgIds = "";
+ for(msgId in currentlyMarkedRows) { //defined in summaryview.js
+ msgIds += ","+msgId;
+ }
+ var mvCommand = "g_cmd=MOVE " + msgIds + "|"+room+"|0";
+ new Ajax.Request('ajax_servcmd', {
+ method: 'post',
+ parameters: mvCommand,
+ onComplete: deleteAllMarkedRows()});
+ }
+}
+function expandFloorEvent(event) {
+ expandFloor(event.target);
+}
+function expandFloor(target) {
+ if (target.nodeName.toLowerCase() != "span") {
+ return; // ignore clicks on child UL
+ }
+ ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
+ var parentUL = target.parentNode;
+ if (currentlyExpandedFloor != null) {
+ currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
+ }
+ parentUL.className = parentUL.className + " floor-expanded";
+ currentlyExpandedFloor = parentUL;