2 * JavaScript function library for WebCit.
4 * Copyright (c) 2005-2011 by the citadel.org team
6 * This program is open source software. You can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 var room_is_trash = 0;
25 var currentlyExpandedFloor = null;
27 var currentDropTarget = null;
29 var supportsAddEventListener = (!!document.addEventListener);
30 var today = new Date();
33 if (document.all) {browserType = "ie"}
34 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
37 var ns6=document.getElementById&&!document.all;
38 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
39 Event.observe(window, 'load', taskViewActivate);
40 //document.observe("dom:loaded", setupPrefEngine);
41 document.observe("dom:loaded", setupIconBar);
42 function CtdlRandomString() {
43 return((Math.random()+'').substr(3));
45 function strcmp ( str1, str2 ) {
46 // http://kevin.vanzonneveld.net
47 // + original by: Waldo Malqui Silva
48 // + input by: Steve Hilder
49 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
50 // + revised by: gorthaur
51 // * example 1: strcmp( 'waldo', 'owald' );
53 // * example 2: strcmp( 'owald', 'waldo' );
56 return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) );
61 function ToggleVisibility ($Which)
63 if (document.getElementById)
65 if (document.getElementById($Which).style.display == "none")
66 document.getElementById($Which).style.display = "inline";
68 document.getElementById($Which).style.display = "none";
72 function emptyElement(element) {
73 childNodes = element.childNodes;
74 for(var i=0; i<childNodes.length; i++) {
76 element.removeChild(childNodes[i]);
78 WCLog(e+"|"+e.description);
82 /** Implements superior internet explorer 'extract all child text from element' feature'. Falls back on buggy, patent violating standardized method */
83 function getTextContent(element) {
84 if (element.textContent == undefined) {
85 return element.innerText;
87 return element.textContent;
89 /** Same reasons as above */
90 function setTextContent(element, textContent) {
91 if(element.textContent == undefined) {
92 element.innerText = textContent;
94 element.textContent = textContent;
98 // We love string tokenizers.
99 function extract_token(source_string, token_num, delimiter) {
101 var extracted_string = source_string;
104 for (i=0; i<token_num; ++i) {
105 var j = extracted_string.indexOf(delimiter);
107 extracted_string = extracted_string.substr(j+1);
112 j = extracted_string.indexOf(delimiter);
114 extracted_string = extracted_string.substr(0, j);
117 return extracted_string;
120 function CtdlSpawnContextMenu(event, source) {
121 // remove any existing menus
122 disintergrateContextMenus(null);
123 var x = event.clientX-10; // cut a few pixels out so our mouseout works right
124 var y = event.clientY-10;
125 var contextDIV = document.createElement("div");
126 contextDIV.setAttribute("id", "ctdlContextMenu");
127 document.body.appendChild(contextDIV);
128 var sourceChildren = source.childNodes;
129 for(var j=0; j<sourceChildren.length; j++) {
130 contextDIV.appendChild(sourceChildren[j].cloneNode(true));
132 var leftRule = "left: "+x+"px;";
133 contextDIV.setAttribute("style", leftRule);
134 contextDIV.setAttribute("actual", leftRule);
135 contextDIV.style.top = y+"px";
136 contextDIV.style.display = "block";
137 $(contextDIV).observe('mouseout',disintergrateContextMenus);
139 function disintergrateContextMenus(event) {
140 var contextMenu = document.getElementById("ctdlContextMenu");
142 contextMenu.parentNode.removeChild(contextMenu);
144 Event.stopObserving(document,'click',disintergrateContextMenus);
146 // This code handles the popups for important-messages.
147 function hide_imsg_popup() {
148 if (browserType == "gecko") {
149 document.poppedLayer = eval('document.getElementById(\'important_message\')');
151 else if (browserType == "ie") {
152 document.poppedLayer = eval('document.all[\'important_message\']');
155 document.poppedLayer = eval('document.layers[\'`important_message\']');
158 document.poppedLayer.style.visibility = "hidden";
162 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
163 function activate_entmsg_autocompleters() {
164 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
165 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
166 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
169 function activate_iconbar_wholist_populat0r()
171 new Ajax.PeriodicalUpdater('online_users', 'do_template?template=who_iconbar', {method: 'get', frequency: 30});
174 function setupIconBar() {
176 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
177 if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) {
178 $('roomlist').style.display = 'block';
179 $('roomlist').innerHTML = '';
180 FillRooms(IconBarRoomList);
183 $('roomlist').style.display = 'none';
186 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
187 if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
188 $('online_users').style.display = 'block';
189 activate_iconbar_wholist_populat0r();
192 $('online_users').style.display = 'none';
197 function GenericTreeRoomList(roomlist) {
198 var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
199 var curRoomName = "";
200 if (document.getElementById("rmname")) {
201 curRoomName = getTextContent(document.getElementById("rmname"));
203 currentDropTargets = new Array();
204 var iconbar = document.getElementById("iconbar");
205 var ul = document.createElement("ul");
206 roomlist.appendChild(ul);
207 // Add mailbox, because they are special
208 var mailboxLI = document.createElement("li");
209 ul.appendChild(mailboxLI);
210 var mailboxSPAN = document.createElement("span");
211 var _mailbox = getTextContent(document.getElementById("mbox_template"));
212 mailboxSPAN.appendChild(document.createTextNode(_mailbox));
213 $(mailboxSPAN).observe('click', expandFloorEvent);
214 mailboxLI.appendChild(mailboxSPAN);
215 mailboxLI.className = "floor";
216 var mailboxUL = document.createElement("ul");
217 mailboxLI.appendChild(mailboxUL);
218 var mailboxRooms = GetMailboxRooms();
219 for(var i=0; i<mailboxRooms.length; i++) {
220 var room = mailboxRooms[i];
221 currentDropTargets.push(addRoomToList(mailboxUL, room, curRoomName));
223 if (currentExpanded != null && currentExpanded == _mailbox ) {
224 expandFloor(mailboxSPAN);
226 for(var a=0; a<floors.length; a++) {
227 var floor = floors[a];
228 var floornum = floor[0];
234 var floorLI = document.createElement("li");
235 ul.appendChild(floorLI);
236 var floorSPAN = document.createElement("span");
237 floorSPAN.appendChild(document.createTextNode(name));
238 $(floorSPAN).observe('click', expandFloorEvent);
239 floorLI.appendChild(floorSPAN);
240 floorLI.className = "floor";
241 var floorUL = document.createElement("ul");
242 floorLI.appendChild(floorUL);
243 var roomsForFloor = GetRoomsByFloorNum(floornum);
244 for(var b=0; b<roomsForFloor.length; b++) {
245 var room = roomsForFloor[b];
246 currentDropTargets.push(addRoomToList(floorUL, room, curRoomName));
248 if (currentExpanded != null && currentExpanded == name) {
249 expandFloor(floorSPAN);
254 function IconBarRoomList() {
255 roomlist = document.getElementById("roomlist");
256 GenericTreeRoomList(roomlist);
258 function KNRoomsRoomList() {
259 roomlist = document.getElementById("roomlist_knrooms");
260 GenericTreeRoomList(roomlist);
263 function addRoomToList(floorUL,room, roomToEmphasize) {
264 var roomName = room[RN_ROOM_NAME];
265 var flag = room[RN_ROOM_FLAG];
266 var curView = room[RN_CUR_VIEW];
267 var view = room[RN_DEF_VIEW];
268 var raflags = room[RN_RAFLAGS];
269 var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
270 var hasNewMsgs = ((raflags & UA_HASNEWMSGS) == UA_HASNEWMSGS);
271 var roomLI = document.createElement("li");
272 var roomA = document.createElement("a");
273 roomA.setAttribute("href","dotgoto?room="+encodeURIComponent(roomName));
274 roomA.appendChild(document.createTextNode(roomName));
275 roomLI.appendChild(roomA);
276 floorUL.appendChild(roomLI);
277 var className = "room ";
278 if (view == VIEW_MAILBOX) {
279 className += "room-private"
280 } else if (view == VIEW_ADDRESSBOOK) {
281 className += "room-addr";
282 } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
283 className += "room-cal";
284 } else if (view == VIEW_TASKS) {
285 className += "room-tasks";
286 } else if (view == VIEW_NOTES) {
287 className += "room-notes";
289 className += "room-chat";
292 className += " room-newmsgs";
294 if (roomName == roomToEmphasize) {
295 className += " room-emphasized";
297 roomLI.setAttribute("class", className);
298 roomA.dropTarget = true;
299 roomA.dropHandler = roomListDropHandler;
303 function roomListDropHandler(target, dropped) {
304 if (dropped.getAttribute("citadel:msgid")) {
305 var room = getTextContent(target);
307 for(msgId in currentlyMarkedRows) { //defined in summaryview.js
309 if (msgIds.length > 800) {
310 var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
311 new Ajax.Request("ajax_servcmd", {
312 parameters: mvCommand,
319 var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
320 new Ajax.Request('ajax_servcmd', {
322 parameters: mvCommand,
323 onComplete: deleteAllMarkedRows()});
326 function expandFloorEvent(event) {
327 expandFloor(event.target);
329 function expandFloor(target) {
330 if (target.nodeName.toLowerCase() != "span") {
331 return; // ignore clicks on child UL
333 ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
334 var parentUL = target.parentNode;
335 if (currentlyExpandedFloor != null) {
336 currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
338 parentUL.className = parentUL.className + " floor-expanded";
339 currentlyExpandedFloor = parentUL;
342 // These functions handle moving sticky notes around the screen by dragging them
344 var uid_of_note_being_dragged = 0;
345 var saved_cursor_style = 'default';
346 var note_was_dragged = 0;
348 function NotesDragMouseUp(evt) {
349 document.onmouseup = null;
350 document.onmousemove = null;
351 if (document.layers) {
352 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
355 d = $('note-' + uid_of_note_being_dragged);
356 d.style.cursor = saved_cursor_style;
358 // If any motion actually occurred, submit an ajax http call to record it to the server
359 if (note_was_dragged > 0) {
360 p = 'note_uid=' + uid_of_note_being_dragged
361 + '&left=' + d.style.left
362 + '&top=' + d.style.top
363 + '&r=' + CtdlRandomString();
373 uid_of_note_being_dragged = '';
377 function NotesDragMouseMove(evt) {
378 x = (ns6 ? evt.clientX : event.clientX);
379 x_increment = x - saved_x;
380 y = (ns6 ? evt.clientY : event.clientY);
381 y_increment = y - saved_y;
384 d = $('note-' + uid_of_note_being_dragged);
386 divTop = parseInt(d.style.top);
387 divLeft = parseInt(d.style.left);
389 d.style.top = (divTop + y_increment) + 'px';
390 d.style.left = (divLeft + x_increment) + 'px';
394 note_was_dragged = 1;
399 function NotesDragMouseDown(evt, uid) {
400 saved_x = (ns6 ? evt.clientX : event.clientX);
401 saved_y = (ns6 ? evt.clientY : event.clientY);
402 document.onmouseup = NotesDragMouseUp;
403 document.onmousemove = NotesDragMouseMove;
404 if (document.layers) {
405 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
407 uid_of_note_being_dragged = uid;
408 d = $('note-' + uid_of_note_being_dragged);
409 saved_cursor_style = d.style.cursor;
410 d.style.cursor = 'move';
411 return false; // disable the default action
415 // Called when the user clicks on the palette icon of a sticky note to change its color.
416 // It toggles the color selector visible or invisible.
418 function NotesClickPalette(evt, uid) {
419 uid_of_note_being_colored = uid;
420 d = $('palette-' + uid_of_note_being_colored);
422 if (d.style.display) {
423 if (d.style.display == 'none') {
424 d.style.display = 'block';
427 d.style.display = 'none';
431 d.style.display = 'block';
438 // Called when the user clicks on one of the colors in an open color selector.
439 // Sets the desired color and then closes the color selector.
441 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
442 uid_of_note_being_colored = uid;
443 palette_button = $('palette-' + uid_of_note_being_colored);
444 note_div = $('note-' + uid_of_note_being_colored);
445 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
447 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
449 note_div.style.backgroundColor = notecolor;
450 titlebar_div.style.backgroundColor = titlecolor;
451 palette_button.style.display = 'none';
453 // submit an ajax http call to record it to the server
454 p = 'note_uid=' + uid_of_note_being_colored
458 + '&r=' + CtdlRandomString();
471 // These functions handle resizing sticky notes by dragging the resize handle
473 var uid_of_note_being_resized = 0;
474 var saved_cursor_style = 'default';
475 var note_was_resized = 0;
477 function NotesResizeMouseUp(evt) {
478 document.onmouseup = null;
479 document.onmousemove = null;
480 if (document.layers) {
481 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
484 d = $('note-' + uid_of_note_being_resized);
485 d.style.cursor = saved_cursor_style;
487 // If any motion actually occurred, submit an ajax http call to record it to the server
488 if (note_was_resized > 0) {
489 p = 'note_uid=' + uid_of_note_being_resized
490 + '&width=' + d.style.width
491 + '&height=' + d.style.height
492 + '&r=' + CtdlRandomString();
502 uid_of_note_being_resized = '';
503 return false; // disable the default action
506 function NotesResizeMouseMove(evt) {
507 x = (ns6 ? evt.clientX : event.clientX);
508 x_increment = x - saved_x;
509 y = (ns6 ? evt.clientY : event.clientY);
510 y_increment = y - saved_y;
513 d = $('note-' + uid_of_note_being_resized);
515 divTop = parseInt(d.style.height);
516 divLeft = parseInt(d.style.width);
518 newHeight = divTop + y_increment;
519 if (newHeight < 50) newHeight = 50;
521 newWidth = divLeft + x_increment;
522 if (newWidth < 50) newWidth = 50;
524 d.style.height = newHeight + 'px';
525 d.style.width = newWidth + 'px';
529 note_was_resized = 1;
530 return false; // disable the default action
534 function NotesResizeMouseDown(evt, uid) {
535 saved_x = (ns6 ? evt.clientX : event.clientX);
536 saved_y = (ns6 ? evt.clientY : event.clientY);
537 document.onmouseup = NotesResizeMouseUp;
538 document.onmousemove = NotesResizeMouseMove;
539 if (document.layers) {
540 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
542 uid_of_note_being_resized = uid;
543 d = $('note-' + uid_of_note_being_resized);
544 saved_cursor_style = d.style.cursor;
545 d.style.cursor = 'move';
546 return false; // disable the default action
550 function DeleteStickyNote(evt, uid, confirmation_prompt) {
551 uid_of_note_being_deleted = uid;
552 d = $('note-' + uid_of_note_being_deleted);
554 if (confirm(confirmation_prompt)) {
557 // submit an ajax http call to delete it on the server
558 p = 'note_uid=' + uid_of_note_being_deleted
560 + '&r=' + CtdlRandomString();
571 function ctdl_ts_getInnerText(el) {
572 if (typeof el == "string") return el;
573 if (typeof el == "undefined") { return el };
574 if (el.innerText) return el.innerText; //Not needed but it is faster
577 var cs = el.childNodes;
579 for (var i = 0; i < l; i++) {
580 switch (cs[i].nodeType) {
581 case 1: //ELEMENT_NODE
582 str += ts_getInnerText(cs[i]);
585 str += cs[i].nodeValue;
593 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
594 function CtdlLoadScreen(elementid) {
595 var elem = document.getElementById(elementid);
596 elem.innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\"> Loading....</font></td></tr></table><br></div>";
601 // Pop open the address book (target_input is the INPUT field to populate)
603 function PopOpenAddressBook(target_input) {
604 $('address_book_popup').style.display = 'block';
605 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
607 'address_book_popup_middle_div',
608 'display_address_book_middle_div',
617 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
618 $('address_book_inner_div').innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\"> Loading....</font></td></tr></table><br></div>";
619 p = 'which_addr_book=' + which_addr_book
620 + '&target_input=' + target_input
621 + '&r=' + CtdlRandomString();
623 'address_book_inner_div',
624 'display_address_book_inner_div',
632 // What happens when a contact is selected from the address book popup
633 // (populate the specified target)
635 function AddContactsToTarget(target, whichaddr) {
636 while (whichaddr.selectedIndex != -1) {
637 if (target.value.length > 0) {
638 target.value = target.value + ', ';
640 target.value = target.value + whichaddr.value;
641 whichaddr.options[whichaddr.selectedIndex].selected = false;
645 // Respond to a meeting invitation
646 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
647 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
648 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
649 Effect.Fade(question_divname, { duration: 0.5 });
652 // Handle a received RSVP
653 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
654 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
655 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
656 Effect.Fade(question_divname, { duration: 0.5 });
658 /* var fakeMouse = document.createEvent("MouseEvents");
659 fakeMouse.initMouseEvent("click", true, true, window,
660 0,0,0,0,0, false, false, false, false, 0, null); */
661 // TODO: Collapse into one function
662 function toggleTaskDtStart(event) {
663 var checkBox = $('nodtstart');
664 var checkBoxTime = $('dtstart_time_assoc');
665 var dtstart = document.getElementById("dtstart");
666 var dtstart_date = document.getElementById("dtstart_date");
667 var dtstart_time = document.getElementById("dtstart_time");
668 if (checkBox.checked) {
669 dtstart_date.style.visibility = "hidden";
670 dtstart_time.style.visibility = "hidden";
672 if (checkBoxTime.checked) {
673 dtstart_time.style.visibility = "visible";
675 dtstart_time.style.visibility = "hidden";
677 dtstart_date.style.visibility = "visible";
678 if (dtstart.value.length == 0)
679 dtstart.dpck._initCurrentDate();
682 function toggleTaskDue(event) {
683 var checkBox = $('nodue');
684 var checkBoxTime = $('due_time_assoc');
685 var due = document.getElementById("due");
686 var due_date = document.getElementById("due_date");
687 var due_time = document.getElementById("due_time");
688 if (checkBox.checked) {
689 due_date.style.visibility = "hidden";
690 due_time.style.visibility = "hidden";
692 if (checkBoxTime.checked) {
693 due_time.style.visibility = "visible";
695 due_time.style.visibility = "hidden";
697 due_date.style.visibility = "visible";
698 if (due.value.length == 0)
699 due.dpck._initCurrentDate();
702 function ToggleTaskDateOrNoDateActivate(event) {
703 var dtstart = document.getElementById("nodtstart");
704 if (dtstart != null) {
705 toggleTaskDtStart(null);
707 $('nodtstart').observe('click', toggleTaskDtStart);
708 $('dtstart_time_assoc').observe('click', toggleTaskDtStart);
709 $('nodue').observe('click', toggleTaskDue);
710 $('due_time_assoc').observe('click', toggleTaskDue);
713 function TaskViewGatherCategoriesFromTable() {
714 var table = $('taskview');
717 function attachDatePicker(relative) {
718 var dpck = new DatePicker({
720 language: 'en', //wclang.substr(0,2),
721 disableFutureDate: false,
722 dateFormat: [ ["yyyy", "mm", "dd"], "-"],
725 document.getElementById(relative).dpck = dpck; // attach a ref to it
727 function eventEditAllDay() {
728 var allDayCheck = document.getElementById("alldayevent");
729 var dtend_time = document.getElementById("dtend_time");
730 var dtstart_time = document.getElementById("dtstart_time");
731 if(allDayCheck.checked) {
732 dtstart_time.style.visibility = "hidden";
733 dtend_time.style.visibility = "hidden";
735 dtstart_time.style.visibility = "visible";
736 dtend_time.style.visibility = "visible";
740 // Functions which handle show/hide of various elements in the recurrence editor
742 function RecurrenceShowHide() {
744 if ($('is_recur').checked) {
745 $('rrule_div').style.display = 'block';
748 $('rrule_div').style.display = 'none';
751 if ($('freq_selector').selectedIndex == 4) {
752 $('weekday_selector').style.display = 'block';
755 $('weekday_selector').style.display = 'none';
758 if ($('freq_selector').selectedIndex == 5) {
759 $('monthday_selector').style.display = 'block';
762 $('monthday_selector').style.display = 'none';
765 if ($('rrend_count').checked) {
766 $('rrcount').disabled = false;
769 $('rrcount').disabled = true;
772 if ($('rrend_until').checked) {
773 $('rruntil').disabled = false;
776 $('rruntil').disabled = true;
779 if ($('rrmonthtype_mday').checked) {
780 $('rrmday').disabled = false;
783 $('rrmday').disabled = true;
786 if ($('rrmonthtype_wday').checked) {
787 $('rrmweek').disabled = false;
788 $('rrmweekday').disabled = false;
791 $('rrmweek').disabled = true;
792 $('rrmweekday').disabled = true;
795 if ($('freq_selector').selectedIndex == 6) {
796 $('yearday_selector').style.display = 'block';
799 $('yearday_selector').style.display = 'none';
802 $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
803 $('rrmday').innerHTML = $('dtstart').value.substr(8);
805 if ($('rryeartype_ywday').checked) {
806 $('rrymweek').disabled = false;
807 $('rrymweekday').disabled = false;
808 $('rrymonth').disabled = false;
811 $('rrymweek').disabled = true;
812 $('rrymweekday').disabled = true;
813 $('rrymonth').disabled = true;
819 // Enable or disable the 'check attendee availability' button depending on whether
820 // the attendees list is empty
821 function EnableOrDisableCheckButton()
823 if ($('attendees_box').value.length == 0) {
824 $('check_button').disabled = true;
827 $('check_button').disabled = false;
834 function launchChat(event) {
835 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
838 function WCLog(msg) {
839 if (!!window.console && !!console.log) {
841 } else if (!!window.opera && !!opera.postError) {
842 opera.postError(msg);
844 wc_log += msg + "\r\n";
848 function RefreshSMTPqueueDisplay() {
849 new Ajax.Updater('smtpqueue_inner_div',
850 'display_smtpqueue_inner_div', { method: 'get',
851 parameters: Math.random() } );
854 function DeleteSMTPqueueMsg(msgnum1, msgnum2) {
855 var p = encodeURI('g_cmd=DELE ' + msgnum1 + ',' + msgnum2);
860 onComplete: RefreshSMTPqueueDisplay()
866 function ConfirmLogoff() {
869 'do_template?template=confirmlogoff',
873 onSuccess: function(cl_success) {
881 function switch_to_lang(new_lang) {
882 p = 'push?url=' + encodeURI(window.location);
883 new Ajax.Request(p, { method: 'get' } );
884 window.location = 'switch_language?lang=' + new_lang ;
888 function toggle_roomlist()
890 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
891 if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) {
892 $('roomlist').style.display = 'none';
893 $('expand_roomlist').src = 'static/webcit_icons/expand.gif';
898 $('roomlist').style.display = 'block';
899 $('expand_roomlist').src = 'static/webcit_icons/collapse.gif';
900 $('roomlist').innerHTML = '';
901 FillRooms(IconBarRoomList);
905 // tell the server what I did
906 p = 'toggle_roomlist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
907 new Ajax.Request(p, { method: 'get' } );
909 return false; /* this prevents the click from registering as a roomlist button press */
913 function toggle_wholist()
915 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
916 if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
917 $('online_users').style.display = 'none';
918 $('expand_wholist').src = 'static/webcit_icons/expand.gif';
923 $('online_users').style.display = 'block';
924 $('expand_wholist').src = 'static/webcit_icons/collapse.gif';
925 activate_iconbar_wholist_populat0r();
929 // tell the server what I did
930 p = 'toggle_wholist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
931 new Ajax.Request(p, { method: 'get' } );
933 return false; /* this prevents the click from registering as a wholist button press */