2 * JavaScript function library for WebCit.
4 * Copyright (c) 2005-2012 by the citadel.org team
6 * This program is open source software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 3.
8 * the Free Software Foundation, either version 3 of the License, or
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.
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 var room_is_trash = 0;
23 var currentlyExpandedFloor = null;
25 var currentDropTarget = null;
27 var supportsAddEventListener = (!!document.addEventListener);
28 var today = new Date();
31 if (document.all) {browserType = "ie"}
32 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
35 var ns6=document.getElementById&&!document.all;
36 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
37 Event.observe(window, 'load', taskViewActivate);
38 //document.observe("dom:loaded", setupPrefEngine);
39 document.observe("dom:loaded", setupIconBar);
40 function CtdlRandomString() {
41 return((Math.random()+'').substr(3));
43 function strcmp ( str1, str2 ) {
44 // http://kevin.vanzonneveld.net
45 // + original by: Waldo Malqui Silva
46 // + input by: Steve Hilder
47 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
48 // + revised by: gorthaur
49 // * example 1: strcmp( 'waldo', 'owald' );
51 // * example 2: strcmp( 'owald', 'waldo' );
54 return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) );
57 function CtdlMarkLog($Which, $Status)
60 document.getElementById($Which).checked == false;
62 document.getElementById($Which).checked == true;
65 function ToggleLogEnable($Which)
68 var Status = !document.getElementById($Which).checked;
70 p= encodeURI('g_cmd=LOGS ' + $Which + '|0');
72 p= encodeURI('g_cmd=LOGS ' + $Which + '|1');
73 new Ajax.Request('ajax_servcmd', {
76 onComplete: CtdlMarkLog($Which, Status)
80 function SMTPRunQueue()
84 p= encodeURI('g_cmd=SMTP runqueue');
85 new Ajax.Request('ajax_servcmd', {
88 onComplete: function(transport) { ajax_important_message(transport.responseText.substr(4));}
92 function ToggleVisibility ($Which)
94 if (document.getElementById)
96 if (document.getElementById($Which).style.display == "none")
97 document.getElementById($Which).style.display = "inline";
99 document.getElementById($Which).style.display = "none";
103 function emptyElement(element) {
104 childNodes = element.childNodes;
105 for(var i=0; i<childNodes.length; i++) {
107 element.removeChild(childNodes[i]);
109 WCLog(e+"|"+e.description);
113 /** Implements superior internet explorer 'extract all child text from element' feature'. Falls back on buggy, patent violating standardized method */
114 function getTextContent(element) {
115 if (element.textContent == undefined) {
116 return element.innerText;
118 return element.textContent;
120 /** Same reasons as above */
121 function setTextContent(element, textContent) {
122 if(element.textContent == undefined) {
123 element.innerText = textContent;
125 element.textContent = textContent;
129 // We love string tokenizers.
130 function extract_token(source_string, token_num, delimiter) {
132 var extracted_string = source_string;
135 for (i=0; i<token_num; ++i) {
136 var j = extracted_string.indexOf(delimiter);
138 extracted_string = extracted_string.substr(j+1);
143 j = extracted_string.indexOf(delimiter);
145 extracted_string = extracted_string.substr(0, j);
148 return extracted_string;
151 function CtdlSpawnContextMenu(event, source) {
152 // remove any existing menus
153 disintergrateContextMenus(null);
154 var x = event.clientX-10; // cut a few pixels out so our mouseout works right
155 var y = event.clientY-10;
156 var contextDIV = document.createElement("div");
157 contextDIV.setAttribute("id", "ctdlContextMenu");
158 document.body.appendChild(contextDIV);
159 var sourceChildren = source.childNodes;
160 for(var j=0; j<sourceChildren.length; j++) {
161 contextDIV.appendChild(sourceChildren[j].cloneNode(true));
163 var leftRule = "left: "+x+"px;";
164 contextDIV.setAttribute("style", leftRule);
165 contextDIV.setAttribute("actual", leftRule);
166 contextDIV.style.top = y+"px";
167 contextDIV.style.display = "block";
168 $(contextDIV).observe('mouseout',disintergrateContextMenus);
170 function disintergrateContextMenus(event) {
171 var contextMenu = document.getElementById("ctdlContextMenu");
173 contextMenu.parentNode.removeChild(contextMenu);
175 Event.stopObserving(document,'click',disintergrateContextMenus);
177 // This code handles the popups for important-messages.
178 function hide_imsg_popup() {
179 if (browserType == "gecko") {
180 document.poppedLayer = eval('document.getElementById(\'important_message\')');
182 else if (browserType == "ie") {
183 document.poppedLayer = eval('document.all[\'important_message\']');
186 document.poppedLayer = eval('document.layers[\'`important_message\']');
189 document.poppedLayer.style.visibility = "hidden";
191 function remove_something(what_to_search, new_visibility) {
192 if (browserType == "gecko") {
193 document.poppedLayer = eval('document.getElementById(\'' + what_to_search + '\')');
195 else if (browserType == "ie") {
196 document.poppedLayer = eval('document.all[\'' + what_to_search + '\']');
199 document.poppedLayer = eval('document.layers[\'`' + what_to_search + '\']');
201 if (document.poppedLayer!= null)
202 document.poppedLayer.innerHTML = "";
205 function unhide_imsg_popup() {
206 if (browserType == "gecko") {
207 document.poppedLayer = eval('document.getElementById(\'important_message\')');
209 else if (browserType == "ie") {
210 document.poppedLayer = eval('document.all[\'important_message\']');
213 document.poppedLayer = eval('document.layers[\'`important_message\']');
216 document.poppedLayer.style.visibility = "visible";
217 setTimeout('hide_imsg_popup()', 5000);
220 function ajax_important_message(messagetext)
222 if (browserType == "gecko") {
223 document.poppedLayer = eval('document.getElementById(\'important_message\')');
225 else if (browserType == "ie") {
226 document.poppedLayer = eval('document.all[\'important_message\']');
229 document.poppedLayer = eval('document.layers[\'`important_message\']');
231 document.poppedLayer.style.visibility = "visible";
232 setTimeout('hide_imsg_popup()', 5000);
233 document.poppedLayer.innerHTML = messagetext;
236 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
237 function activate_entmsg_autocompleters() {
238 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
239 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
240 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
243 function activate_iconbar_wholist_populat0r()
245 new Ajax.PeriodicalUpdater('online_users', 'do_template?template=who_iconbar', {method: 'get', frequency: 30});
248 function setupIconBar() {
250 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
251 if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) {
252 $('roomlist').style.display = 'block';
253 $('roomlist').innerHTML = '';
254 FillRooms(IconBarRoomList);
257 $('roomlist').style.display = 'none';
260 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
261 if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
262 $('online_users').style.display = 'block';
263 activate_iconbar_wholist_populat0r();
266 $('online_users').style.display = 'none';
271 function GenericTreeRoomList(roomlist) {
272 var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
273 var curRoomName = "";
274 if (document.getElementById("rmname")) {
275 curRoomName = getTextContent(document.getElementById("rmname"));
277 currentDropTargets = new Array();
278 var iconbar = document.getElementById("iconbar");
279 var ul = document.createElement("ul");
280 roomlist.appendChild(ul);
281 // Add mailbox, because they are special
282 var mailboxLI = document.createElement("li");
283 ul.appendChild(mailboxLI);
284 var mailboxSPAN = document.createElement("span");
285 var _mailbox = getTextContent(document.getElementById("mbox_template"));
286 mailboxSPAN.appendChild(document.createTextNode(_mailbox));
287 $(mailboxSPAN).observe('click', expandFloorEvent);
288 mailboxLI.appendChild(mailboxSPAN);
289 mailboxLI.className = "floor";
290 var mailboxUL = document.createElement("ul");
291 mailboxLI.appendChild(mailboxUL);
292 var mailboxRooms = GetMailboxRooms();
293 for(var i=0; i<mailboxRooms.length; i++) {
294 var room = mailboxRooms[i];
295 currentDropTargets.push(addRoomToList(mailboxUL, room, curRoomName));
297 if (currentExpanded != null && currentExpanded == _mailbox ) {
298 expandFloor(mailboxSPAN);
300 for(var a=0; a<floors.length; a++) {
301 var floor = floors[a];
302 var floornum = floor[0];
308 var floorLI = document.createElement("li");
309 ul.appendChild(floorLI);
310 var floorSPAN = document.createElement("span");
311 floorSPAN.appendChild(document.createTextNode(name));
312 $(floorSPAN).observe('click', expandFloorEvent);
313 floorLI.appendChild(floorSPAN);
314 floorLI.className = "floor";
315 var floorUL = document.createElement("ul");
316 floorLI.appendChild(floorUL);
317 var roomsForFloor = GetRoomsByFloorNum(floornum);
318 for(var b=0; b<roomsForFloor.length; b++) {
319 var room = roomsForFloor[b];
320 currentDropTargets.push(addRoomToList(floorUL, room, curRoomName));
322 if (currentExpanded != null && currentExpanded == name) {
323 expandFloor(floorSPAN);
328 function IconBarRoomList() {
329 roomlist = document.getElementById("roomlist");
330 GenericTreeRoomList(roomlist);
332 function KNRoomsRoomList() {
333 roomlist = document.getElementById("roomlist_knrooms");
334 GenericTreeRoomList(roomlist);
337 function addRoomToList(floorUL,room, roomToEmphasize) {
338 var roomName = room[RN_ROOM_NAME];
339 var flag = room[RN_ROOM_FLAG];
340 var curView = room[RN_CUR_VIEW];
341 var view = room[RN_DEF_VIEW];
342 var raflags = room[RN_RAFLAGS];
343 var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
344 var hasNewMsgs = ((raflags & UA_HASNEWMSGS) == UA_HASNEWMSGS);
345 var roomLI = document.createElement("li");
346 var roomA = document.createElement("a");
347 roomA.setAttribute("href","dotgoto?room="+encodeURIComponent(roomName));
348 roomA.appendChild(document.createTextNode(roomName));
349 roomLI.appendChild(roomA);
350 floorUL.appendChild(roomLI);
351 var className = "room ";
352 if (view == VIEW_MAILBOX) {
353 className += "room-private"
354 } else if (view == VIEW_ADDRESSBOOK) {
355 className += "room-addr";
356 } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
357 className += "room-cal";
358 } else if (view == VIEW_TASKS) {
359 className += "room-tasks";
360 } else if (view == VIEW_NOTES) {
361 className += "room-notes";
363 className += "room-chat";
366 className += " room-newmsgs";
368 if (roomName == roomToEmphasize) {
369 className += " room-emphasized";
371 roomLI.setAttribute("class", className);
372 roomA.dropTarget = true;
373 roomA.dropHandler = roomListDropHandler;
377 function roomListDropHandler(target, dropped) {
378 if (dropped.getAttribute("citadel:msgid")) {
379 var room = getTextContent(target);
381 for(msgId in currentlyMarkedRows) { //defined in summaryview.js
383 if (msgIds.length > 800) {
384 var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
385 new Ajax.Request("ajax_servcmd", {
386 parameters: mvCommand,
393 var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
394 new Ajax.Request('ajax_servcmd', {
396 parameters: mvCommand,
397 onComplete: deleteAllMarkedRows()});
400 function expandFloorEvent(event) {
401 expandFloor(event.target);
403 function expandFloor(target) {
404 if (target.nodeName.toLowerCase() != "span") {
405 return; // ignore clicks on child UL
407 ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
408 var parentUL = target.parentNode;
409 if (currentlyExpandedFloor != null) {
410 currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
412 parentUL.className = parentUL.className + " floor-expanded";
413 currentlyExpandedFloor = parentUL;
416 // These functions handle moving sticky notes around the screen by dragging them
418 var uid_of_note_being_dragged = 0;
419 var saved_cursor_style = 'default';
420 var note_was_dragged = 0;
422 function NotesDragMouseUp(evt) {
423 document.onmouseup = null;
424 document.onmousemove = null;
425 if (document.layers) {
426 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
429 d = $('note-' + uid_of_note_being_dragged);
430 d.style.cursor = saved_cursor_style;
432 // If any motion actually occurred, submit an ajax http call to record it to the server
433 if (note_was_dragged > 0) {
434 p = 'note_uid=' + uid_of_note_being_dragged
435 + '&left=' + d.style.left
436 + '&top=' + d.style.top
437 + '&r=' + CtdlRandomString();
447 uid_of_note_being_dragged = '';
451 function NotesDragMouseMove(evt) {
452 x = (ns6 ? evt.clientX : event.clientX);
453 x_increment = x - saved_x;
454 y = (ns6 ? evt.clientY : event.clientY);
455 y_increment = y - saved_y;
458 d = $('note-' + uid_of_note_being_dragged);
460 divTop = parseInt(d.style.top);
461 divLeft = parseInt(d.style.left);
463 d.style.top = (divTop + y_increment) + 'px';
464 d.style.left = (divLeft + x_increment) + 'px';
468 note_was_dragged = 1;
473 function NotesDragMouseDown(evt, uid) {
474 saved_x = (ns6 ? evt.clientX : event.clientX);
475 saved_y = (ns6 ? evt.clientY : event.clientY);
476 document.onmouseup = NotesDragMouseUp;
477 document.onmousemove = NotesDragMouseMove;
478 if (document.layers) {
479 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
481 uid_of_note_being_dragged = uid;
482 d = $('note-' + uid_of_note_being_dragged);
483 saved_cursor_style = d.style.cursor;
484 d.style.cursor = 'move';
485 return false; // disable the default action
489 // Called when the user clicks on the palette icon of a sticky note to change its color.
490 // It toggles the color selector visible or invisible.
492 function NotesClickPalette(evt, uid) {
493 uid_of_note_being_colored = uid;
494 d = $('palette-' + uid_of_note_being_colored);
496 if (d.style.display) {
497 if (d.style.display == 'none') {
498 d.style.display = 'block';
501 d.style.display = 'none';
505 d.style.display = 'block';
512 // Called when the user clicks on one of the colors in an open color selector.
513 // Sets the desired color and then closes the color selector.
515 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
516 uid_of_note_being_colored = uid;
517 palette_button = $('palette-' + uid_of_note_being_colored);
518 note_div = $('note-' + uid_of_note_being_colored);
519 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
521 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
523 note_div.style.backgroundColor = notecolor;
524 titlebar_div.style.backgroundColor = titlecolor;
525 palette_button.style.display = 'none';
527 // submit an ajax http call to record it to the server
528 p = 'note_uid=' + uid_of_note_being_colored
532 + '&r=' + CtdlRandomString();
545 // These functions handle resizing sticky notes by dragging the resize handle
547 var uid_of_note_being_resized = 0;
548 var saved_cursor_style = 'default';
549 var note_was_resized = 0;
551 function NotesResizeMouseUp(evt) {
552 document.onmouseup = null;
553 document.onmousemove = null;
554 if (document.layers) {
555 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
558 d = $('note-' + uid_of_note_being_resized);
559 d.style.cursor = saved_cursor_style;
561 // If any motion actually occurred, submit an ajax http call to record it to the server
562 if (note_was_resized > 0) {
563 p = 'note_uid=' + uid_of_note_being_resized
564 + '&width=' + d.style.width
565 + '&height=' + d.style.height
566 + '&r=' + CtdlRandomString();
576 uid_of_note_being_resized = '';
577 return false; // disable the default action
580 function NotesResizeMouseMove(evt) {
581 x = (ns6 ? evt.clientX : event.clientX);
582 x_increment = x - saved_x;
583 y = (ns6 ? evt.clientY : event.clientY);
584 y_increment = y - saved_y;
587 d = $('note-' + uid_of_note_being_resized);
589 divTop = parseInt(d.style.height);
590 divLeft = parseInt(d.style.width);
592 newHeight = divTop + y_increment;
593 if (newHeight < 50) newHeight = 50;
595 newWidth = divLeft + x_increment;
596 if (newWidth < 50) newWidth = 50;
598 d.style.height = newHeight + 'px';
599 d.style.width = newWidth + 'px';
603 note_was_resized = 1;
604 return false; // disable the default action
608 function NotesResizeMouseDown(evt, uid) {
609 saved_x = (ns6 ? evt.clientX : event.clientX);
610 saved_y = (ns6 ? evt.clientY : event.clientY);
611 document.onmouseup = NotesResizeMouseUp;
612 document.onmousemove = NotesResizeMouseMove;
613 if (document.layers) {
614 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
616 uid_of_note_being_resized = uid;
617 d = $('note-' + uid_of_note_being_resized);
618 saved_cursor_style = d.style.cursor;
619 d.style.cursor = 'move';
620 return false; // disable the default action
624 function DeleteStickyNote(evt, uid, confirmation_prompt) {
625 uid_of_note_being_deleted = uid;
626 d = $('note-' + uid_of_note_being_deleted);
628 if (confirm(confirmation_prompt)) {
631 // submit an ajax http call to delete it on the server
632 p = 'note_uid=' + uid_of_note_being_deleted
634 + '&r=' + CtdlRandomString();
645 function ctdl_ts_getInnerText(el) {
646 if (typeof el == "string") return el;
647 if (typeof el == "undefined") { return el };
648 if (el.innerText) return el.innerText; //Not needed but it is faster
651 var cs = el.childNodes;
653 for (var i = 0; i < l; i++) {
654 switch (cs[i].nodeType) {
655 case 1: //ELEMENT_NODE
656 str += ts_getInnerText(cs[i]);
659 str += cs[i].nodeValue;
667 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
668 function CtdlLoadScreen(elementid) {
669 var elem = document.getElementById(elementid);
670 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>";
675 // Pop open the address book (target_input is the INPUT field to populate)
677 function PopOpenAddressBook(target_input) {
678 $('address_book_popup').style.display = 'block';
679 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
681 'address_book_popup_middle_div',
682 'display_address_book_middle_div',
691 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
692 $('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>";
693 p = 'which_addr_book=' + which_addr_book
694 + '&target_input=' + target_input
695 + '&r=' + CtdlRandomString();
697 'address_book_inner_div',
698 'display_address_book_inner_div',
706 // What happens when a contact is selected from the address book popup
707 // (populate the specified target)
709 function AddContactsToTarget(target, whichaddr) {
710 while (whichaddr.selectedIndex != -1) {
711 if (target.value.length > 0) {
712 target.value = target.value + ', ';
714 target.value = target.value + whichaddr.value;
715 whichaddr.options[whichaddr.selectedIndex].selected = false;
719 // Respond to a meeting invitation
720 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
721 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
722 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
723 Effect.Fade(question_divname, { duration: 0.5 });
726 // Handle a received RSVP
727 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
728 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
729 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
730 Effect.Fade(question_divname, { duration: 0.5 });
732 /* var fakeMouse = document.createEvent("MouseEvents");
733 fakeMouse.initMouseEvent("click", true, true, window,
734 0,0,0,0,0, false, false, false, false, 0, null); */
735 // TODO: Collapse into one function
736 function toggleTaskDtStart(event) {
737 var checkBox = $('nodtstart');
738 var checkBoxTime = $('dtstart_time_assoc');
739 var dtstart = document.getElementById("dtstart");
740 var dtstart_date = document.getElementById("dtstart_date");
741 var dtstart_time = document.getElementById("dtstart_time");
742 if (checkBox.checked) {
743 dtstart_date.style.visibility = "hidden";
744 dtstart_time.style.visibility = "hidden";
746 if (checkBoxTime.checked) {
747 dtstart_time.style.visibility = "visible";
749 dtstart_time.style.visibility = "hidden";
751 dtstart_date.style.visibility = "visible";
752 if (dtstart.value.length == 0)
753 dtstart.dpck._initCurrentDate();
756 function toggleTaskDue(event) {
757 var checkBox = $('nodue');
758 var checkBoxTime = $('due_time_assoc');
759 var due = document.getElementById("due");
760 var due_date = document.getElementById("due_date");
761 var due_time = document.getElementById("due_time");
762 if (checkBox.checked) {
763 due_date.style.visibility = "hidden";
764 due_time.style.visibility = "hidden";
766 if (checkBoxTime.checked) {
767 due_time.style.visibility = "visible";
769 due_time.style.visibility = "hidden";
771 due_date.style.visibility = "visible";
772 if (due.value.length == 0)
773 due.dpck._initCurrentDate();
776 function ToggleTaskDateOrNoDateActivate(event) {
777 var dtstart = document.getElementById("nodtstart");
778 if (dtstart != null) {
779 toggleTaskDtStart(null);
781 $('nodtstart').observe('click', toggleTaskDtStart);
782 $('dtstart_time_assoc').observe('click', toggleTaskDtStart);
783 $('nodue').observe('click', toggleTaskDue);
784 $('due_time_assoc').observe('click', toggleTaskDue);
787 function TaskViewGatherCategoriesFromTable() {
788 var table = $('taskview');
791 function attachDatePicker(relative) {
792 var dpck = new DatePicker({
794 language: 'en', //wclang.substr(0,2),
795 disableFutureDate: false,
796 dateFormat: [ ["yyyy", "mm", "dd"], "-"],
799 document.getElementById(relative).dpck = dpck; // attach a ref to it
801 function eventEditAllDay() {
802 var allDayCheck = document.getElementById("alldayevent");
803 var dtend_time = document.getElementById("dtend_time");
804 var dtstart_time = document.getElementById("dtstart_time");
805 if(allDayCheck.checked) {
806 dtstart_time.style.visibility = "hidden";
807 dtend_time.style.visibility = "hidden";
809 dtstart_time.style.visibility = "visible";
810 dtend_time.style.visibility = "visible";
814 // Functions which handle show/hide of various elements in the recurrence editor
816 function RecurrenceShowHide() {
818 if ($('is_recur').checked) {
819 $('rrule_div').style.display = 'block';
822 $('rrule_div').style.display = 'none';
825 if ($('freq_selector').selectedIndex == 4) {
826 $('weekday_selector').style.display = 'block';
829 $('weekday_selector').style.display = 'none';
832 if ($('freq_selector').selectedIndex == 5) {
833 $('monthday_selector').style.display = 'block';
836 $('monthday_selector').style.display = 'none';
839 if ($('rrend_count').checked) {
840 $('rrcount').disabled = false;
843 $('rrcount').disabled = true;
846 if ($('rrend_until').checked) {
847 $('rruntil').disabled = false;
850 $('rruntil').disabled = true;
853 if ($('rrmonthtype_mday').checked) {
854 $('rrmday').disabled = false;
857 $('rrmday').disabled = true;
860 if ($('rrmonthtype_wday').checked) {
861 $('rrmweek').disabled = false;
862 $('rrmweekday').disabled = false;
865 $('rrmweek').disabled = true;
866 $('rrmweekday').disabled = true;
869 if ($('freq_selector').selectedIndex == 6) {
870 $('yearday_selector').style.display = 'block';
873 $('yearday_selector').style.display = 'none';
876 $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
877 $('rrmday').innerHTML = $('dtstart').value.substr(8);
879 if ($('rryeartype_ywday').checked) {
880 $('rrymweek').disabled = false;
881 $('rrymweekday').disabled = false;
882 $('rrymonth').disabled = false;
885 $('rrymweek').disabled = true;
886 $('rrymweekday').disabled = true;
887 $('rrymonth').disabled = true;
893 // Enable or disable the 'check attendee availability' button depending on whether
894 // the attendees list is empty
895 function EnableOrDisableCheckButton()
897 if ($('attendees_box').value.length == 0) {
898 $('check_button').disabled = true;
901 $('check_button').disabled = false;
908 function launchChat(event) {
909 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
912 function WCLog(msg) {
913 if (!!window.console && !!console.log) {
915 } else if (!!window.opera && !!opera.postError) {
916 opera.postError(msg);
918 wc_log += msg + "\r\n";
922 function RefreshSMTPqueueDisplay() {
923 new Ajax.Updater('smtpqueue_inner_div',
924 'display_smtpqueue_inner_div', { method: 'get',
925 parameters: Math.random() } );
928 function DeleteSMTPqueueMsg(msgnum1, msgnum2) {
929 var p = encodeURI('g_cmd=DELE ' + msgnum1 + ',' + msgnum2);
934 onComplete: RefreshSMTPqueueDisplay()
940 function ConfirmLogoff() {
943 'do_template?template=confirmlogoff',
947 onSuccess: function(cl_success) {
955 function switch_to_lang(new_lang) {
956 p = 'push?url=' + encodeURI(window.location);
957 new Ajax.Request(p, { method: 'get' } );
958 window.location = 'switch_language?lang=' + new_lang ;
962 function toggle_roomlist()
964 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
965 if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) {
966 $('roomlist').style.display = 'none';
967 $('expand_roomlist').src = 'static/webcit_icons/expand.gif';
972 $('roomlist').style.display = 'block';
973 $('expand_roomlist').src = 'static/webcit_icons/collapse.gif';
974 $('roomlist').innerHTML = '';
975 FillRooms(IconBarRoomList);
979 // tell the server what I did
980 p = 'toggle_roomlist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
981 new Ajax.Request(p, { method: 'get' } );
983 return false; /* this prevents the click from registering as a roomlist button press */
987 function toggle_wholist()
989 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
990 if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
991 $('online_users').style.display = 'none';
992 $('expand_wholist').src = 'static/webcit_icons/expand.gif';
997 $('online_users').style.display = 'block';
998 $('expand_wholist').src = 'static/webcit_icons/collapse.gif';
999 activate_iconbar_wholist_populat0r();
1003 // tell the server what I did
1004 p = 'toggle_wholist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
1005 new Ajax.Request(p, { method: 'get' } );
1007 return false; /* this prevents the click from registering as a wholist button press */