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 document.poppedLayer.innerHTML = "";
204 function unhide_imsg_popup() {
205 if (browserType == "gecko") {
206 document.poppedLayer = eval('document.getElementById(\'important_message\')');
208 else if (browserType == "ie") {
209 document.poppedLayer = eval('document.all[\'important_message\']');
212 document.poppedLayer = eval('document.layers[\'`important_message\']');
215 document.poppedLayer.style.visibility = "visible";
216 setTimeout('hide_imsg_popup()', 5000);
219 function ajax_important_message(messagetext)
221 if (browserType == "gecko") {
222 document.poppedLayer = eval('document.getElementById(\'important_message\')');
224 else if (browserType == "ie") {
225 document.poppedLayer = eval('document.all[\'important_message\']');
228 document.poppedLayer = eval('document.layers[\'`important_message\']');
230 document.poppedLayer.style.visibility = "visible";
231 setTimeout('hide_imsg_popup()', 5000);
232 document.poppedLayer.innerHTML = messagetext;
235 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
236 function activate_entmsg_autocompleters() {
237 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
238 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
239 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
242 function activate_iconbar_wholist_populat0r()
244 new Ajax.PeriodicalUpdater('online_users', 'do_template?template=who_iconbar', {method: 'get', frequency: 30});
247 function setupIconBar() {
249 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
250 if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) {
251 $('roomlist').style.display = 'block';
252 $('roomlist').innerHTML = '';
253 FillRooms(IconBarRoomList);
256 $('roomlist').style.display = 'none';
259 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
260 if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
261 $('online_users').style.display = 'block';
262 activate_iconbar_wholist_populat0r();
265 $('online_users').style.display = 'none';
270 function GenericTreeRoomList(roomlist) {
271 var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
272 var curRoomName = "";
273 if (document.getElementById("rmname")) {
274 curRoomName = getTextContent(document.getElementById("rmname"));
276 currentDropTargets = new Array();
277 var iconbar = document.getElementById("iconbar");
278 var ul = document.createElement("ul");
279 roomlist.appendChild(ul);
280 // Add mailbox, because they are special
281 var mailboxLI = document.createElement("li");
282 ul.appendChild(mailboxLI);
283 var mailboxSPAN = document.createElement("span");
284 var _mailbox = getTextContent(document.getElementById("mbox_template"));
285 mailboxSPAN.appendChild(document.createTextNode(_mailbox));
286 $(mailboxSPAN).observe('click', expandFloorEvent);
287 mailboxLI.appendChild(mailboxSPAN);
288 mailboxLI.className = "floor";
289 var mailboxUL = document.createElement("ul");
290 mailboxLI.appendChild(mailboxUL);
291 var mailboxRooms = GetMailboxRooms();
292 for(var i=0; i<mailboxRooms.length; i++) {
293 var room = mailboxRooms[i];
294 currentDropTargets.push(addRoomToList(mailboxUL, room, curRoomName));
296 if (currentExpanded != null && currentExpanded == _mailbox ) {
297 expandFloor(mailboxSPAN);
299 for(var a=0; a<floors.length; a++) {
300 var floor = floors[a];
301 var floornum = floor[0];
307 var floorLI = document.createElement("li");
308 ul.appendChild(floorLI);
309 var floorSPAN = document.createElement("span");
310 floorSPAN.appendChild(document.createTextNode(name));
311 $(floorSPAN).observe('click', expandFloorEvent);
312 floorLI.appendChild(floorSPAN);
313 floorLI.className = "floor";
314 var floorUL = document.createElement("ul");
315 floorLI.appendChild(floorUL);
316 var roomsForFloor = GetRoomsByFloorNum(floornum);
317 for(var b=0; b<roomsForFloor.length; b++) {
318 var room = roomsForFloor[b];
319 currentDropTargets.push(addRoomToList(floorUL, room, curRoomName));
321 if (currentExpanded != null && currentExpanded == name) {
322 expandFloor(floorSPAN);
327 function IconBarRoomList() {
328 roomlist = document.getElementById("roomlist");
329 GenericTreeRoomList(roomlist);
331 function KNRoomsRoomList() {
332 roomlist = document.getElementById("roomlist_knrooms");
333 GenericTreeRoomList(roomlist);
336 function addRoomToList(floorUL,room, roomToEmphasize) {
337 var roomName = room[RN_ROOM_NAME];
338 var flag = room[RN_ROOM_FLAG];
339 var curView = room[RN_CUR_VIEW];
340 var view = room[RN_DEF_VIEW];
341 var raflags = room[RN_RAFLAGS];
342 var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
343 var hasNewMsgs = ((raflags & UA_HASNEWMSGS) == UA_HASNEWMSGS);
344 var roomLI = document.createElement("li");
345 var roomA = document.createElement("a");
346 roomA.setAttribute("href","dotgoto?room="+encodeURIComponent(roomName));
347 roomA.appendChild(document.createTextNode(roomName));
348 roomLI.appendChild(roomA);
349 floorUL.appendChild(roomLI);
350 var className = "room ";
351 if (view == VIEW_MAILBOX) {
352 className += "room-private"
353 } else if (view == VIEW_ADDRESSBOOK) {
354 className += "room-addr";
355 } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
356 className += "room-cal";
357 } else if (view == VIEW_TASKS) {
358 className += "room-tasks";
359 } else if (view == VIEW_NOTES) {
360 className += "room-notes";
362 className += "room-chat";
365 className += " room-newmsgs";
367 if (roomName == roomToEmphasize) {
368 className += " room-emphasized";
370 roomLI.setAttribute("class", className);
371 roomA.dropTarget = true;
372 roomA.dropHandler = roomListDropHandler;
376 function roomListDropHandler(target, dropped) {
377 if (dropped.getAttribute("citadel:msgid")) {
378 var room = getTextContent(target);
380 for(msgId in currentlyMarkedRows) { //defined in summaryview.js
382 if (msgIds.length > 800) {
383 var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
384 new Ajax.Request("ajax_servcmd", {
385 parameters: mvCommand,
392 var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
393 new Ajax.Request('ajax_servcmd', {
395 parameters: mvCommand,
396 onComplete: deleteAllMarkedRows()});
399 function expandFloorEvent(event) {
400 expandFloor(event.target);
402 function expandFloor(target) {
403 if (target.nodeName.toLowerCase() != "span") {
404 return; // ignore clicks on child UL
406 ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
407 var parentUL = target.parentNode;
408 if (currentlyExpandedFloor != null) {
409 currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
411 parentUL.className = parentUL.className + " floor-expanded";
412 currentlyExpandedFloor = parentUL;
415 // These functions handle moving sticky notes around the screen by dragging them
417 var uid_of_note_being_dragged = 0;
418 var saved_cursor_style = 'default';
419 var note_was_dragged = 0;
421 function NotesDragMouseUp(evt) {
422 document.onmouseup = null;
423 document.onmousemove = null;
424 if (document.layers) {
425 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
428 d = $('note-' + uid_of_note_being_dragged);
429 d.style.cursor = saved_cursor_style;
431 // If any motion actually occurred, submit an ajax http call to record it to the server
432 if (note_was_dragged > 0) {
433 p = 'note_uid=' + uid_of_note_being_dragged
434 + '&left=' + d.style.left
435 + '&top=' + d.style.top
436 + '&r=' + CtdlRandomString();
446 uid_of_note_being_dragged = '';
450 function NotesDragMouseMove(evt) {
451 x = (ns6 ? evt.clientX : event.clientX);
452 x_increment = x - saved_x;
453 y = (ns6 ? evt.clientY : event.clientY);
454 y_increment = y - saved_y;
457 d = $('note-' + uid_of_note_being_dragged);
459 divTop = parseInt(d.style.top);
460 divLeft = parseInt(d.style.left);
462 d.style.top = (divTop + y_increment) + 'px';
463 d.style.left = (divLeft + x_increment) + 'px';
467 note_was_dragged = 1;
472 function NotesDragMouseDown(evt, uid) {
473 saved_x = (ns6 ? evt.clientX : event.clientX);
474 saved_y = (ns6 ? evt.clientY : event.clientY);
475 document.onmouseup = NotesDragMouseUp;
476 document.onmousemove = NotesDragMouseMove;
477 if (document.layers) {
478 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
480 uid_of_note_being_dragged = uid;
481 d = $('note-' + uid_of_note_being_dragged);
482 saved_cursor_style = d.style.cursor;
483 d.style.cursor = 'move';
484 return false; // disable the default action
488 // Called when the user clicks on the palette icon of a sticky note to change its color.
489 // It toggles the color selector visible or invisible.
491 function NotesClickPalette(evt, uid) {
492 uid_of_note_being_colored = uid;
493 d = $('palette-' + uid_of_note_being_colored);
495 if (d.style.display) {
496 if (d.style.display == 'none') {
497 d.style.display = 'block';
500 d.style.display = 'none';
504 d.style.display = 'block';
511 // Called when the user clicks on one of the colors in an open color selector.
512 // Sets the desired color and then closes the color selector.
514 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
515 uid_of_note_being_colored = uid;
516 palette_button = $('palette-' + uid_of_note_being_colored);
517 note_div = $('note-' + uid_of_note_being_colored);
518 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
520 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
522 note_div.style.backgroundColor = notecolor;
523 titlebar_div.style.backgroundColor = titlecolor;
524 palette_button.style.display = 'none';
526 // submit an ajax http call to record it to the server
527 p = 'note_uid=' + uid_of_note_being_colored
531 + '&r=' + CtdlRandomString();
544 // These functions handle resizing sticky notes by dragging the resize handle
546 var uid_of_note_being_resized = 0;
547 var saved_cursor_style = 'default';
548 var note_was_resized = 0;
550 function NotesResizeMouseUp(evt) {
551 document.onmouseup = null;
552 document.onmousemove = null;
553 if (document.layers) {
554 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
557 d = $('note-' + uid_of_note_being_resized);
558 d.style.cursor = saved_cursor_style;
560 // If any motion actually occurred, submit an ajax http call to record it to the server
561 if (note_was_resized > 0) {
562 p = 'note_uid=' + uid_of_note_being_resized
563 + '&width=' + d.style.width
564 + '&height=' + d.style.height
565 + '&r=' + CtdlRandomString();
575 uid_of_note_being_resized = '';
576 return false; // disable the default action
579 function NotesResizeMouseMove(evt) {
580 x = (ns6 ? evt.clientX : event.clientX);
581 x_increment = x - saved_x;
582 y = (ns6 ? evt.clientY : event.clientY);
583 y_increment = y - saved_y;
586 d = $('note-' + uid_of_note_being_resized);
588 divTop = parseInt(d.style.height);
589 divLeft = parseInt(d.style.width);
591 newHeight = divTop + y_increment;
592 if (newHeight < 50) newHeight = 50;
594 newWidth = divLeft + x_increment;
595 if (newWidth < 50) newWidth = 50;
597 d.style.height = newHeight + 'px';
598 d.style.width = newWidth + 'px';
602 note_was_resized = 1;
603 return false; // disable the default action
607 function NotesResizeMouseDown(evt, uid) {
608 saved_x = (ns6 ? evt.clientX : event.clientX);
609 saved_y = (ns6 ? evt.clientY : event.clientY);
610 document.onmouseup = NotesResizeMouseUp;
611 document.onmousemove = NotesResizeMouseMove;
612 if (document.layers) {
613 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
615 uid_of_note_being_resized = uid;
616 d = $('note-' + uid_of_note_being_resized);
617 saved_cursor_style = d.style.cursor;
618 d.style.cursor = 'move';
619 return false; // disable the default action
623 function DeleteStickyNote(evt, uid, confirmation_prompt) {
624 uid_of_note_being_deleted = uid;
625 d = $('note-' + uid_of_note_being_deleted);
627 if (confirm(confirmation_prompt)) {
630 // submit an ajax http call to delete it on the server
631 p = 'note_uid=' + uid_of_note_being_deleted
633 + '&r=' + CtdlRandomString();
644 function ctdl_ts_getInnerText(el) {
645 if (typeof el == "string") return el;
646 if (typeof el == "undefined") { return el };
647 if (el.innerText) return el.innerText; //Not needed but it is faster
650 var cs = el.childNodes;
652 for (var i = 0; i < l; i++) {
653 switch (cs[i].nodeType) {
654 case 1: //ELEMENT_NODE
655 str += ts_getInnerText(cs[i]);
658 str += cs[i].nodeValue;
666 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
667 function CtdlLoadScreen(elementid) {
668 var elem = document.getElementById(elementid);
669 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>";
674 // Pop open the address book (target_input is the INPUT field to populate)
676 function PopOpenAddressBook(target_input) {
677 $('address_book_popup').style.display = 'block';
678 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
680 'address_book_popup_middle_div',
681 'display_address_book_middle_div',
690 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
691 $('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>";
692 p = 'which_addr_book=' + which_addr_book
693 + '&target_input=' + target_input
694 + '&r=' + CtdlRandomString();
696 'address_book_inner_div',
697 'display_address_book_inner_div',
705 // What happens when a contact is selected from the address book popup
706 // (populate the specified target)
708 function AddContactsToTarget(target, whichaddr) {
709 while (whichaddr.selectedIndex != -1) {
710 if (target.value.length > 0) {
711 target.value = target.value + ', ';
713 target.value = target.value + whichaddr.value;
714 whichaddr.options[whichaddr.selectedIndex].selected = false;
718 // Respond to a meeting invitation
719 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
720 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
721 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
722 Effect.Fade(question_divname, { duration: 0.5 });
725 // Handle a received RSVP
726 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
727 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
728 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
729 Effect.Fade(question_divname, { duration: 0.5 });
731 /* var fakeMouse = document.createEvent("MouseEvents");
732 fakeMouse.initMouseEvent("click", true, true, window,
733 0,0,0,0,0, false, false, false, false, 0, null); */
734 // TODO: Collapse into one function
735 function toggleTaskDtStart(event) {
736 var checkBox = $('nodtstart');
737 var checkBoxTime = $('dtstart_time_assoc');
738 var dtstart = document.getElementById("dtstart");
739 var dtstart_date = document.getElementById("dtstart_date");
740 var dtstart_time = document.getElementById("dtstart_time");
741 if (checkBox.checked) {
742 dtstart_date.style.visibility = "hidden";
743 dtstart_time.style.visibility = "hidden";
745 if (checkBoxTime.checked) {
746 dtstart_time.style.visibility = "visible";
748 dtstart_time.style.visibility = "hidden";
750 dtstart_date.style.visibility = "visible";
751 if (dtstart.value.length == 0)
752 dtstart.dpck._initCurrentDate();
755 function toggleTaskDue(event) {
756 var checkBox = $('nodue');
757 var checkBoxTime = $('due_time_assoc');
758 var due = document.getElementById("due");
759 var due_date = document.getElementById("due_date");
760 var due_time = document.getElementById("due_time");
761 if (checkBox.checked) {
762 due_date.style.visibility = "hidden";
763 due_time.style.visibility = "hidden";
765 if (checkBoxTime.checked) {
766 due_time.style.visibility = "visible";
768 due_time.style.visibility = "hidden";
770 due_date.style.visibility = "visible";
771 if (due.value.length == 0)
772 due.dpck._initCurrentDate();
775 function ToggleTaskDateOrNoDateActivate(event) {
776 var dtstart = document.getElementById("nodtstart");
777 if (dtstart != null) {
778 toggleTaskDtStart(null);
780 $('nodtstart').observe('click', toggleTaskDtStart);
781 $('dtstart_time_assoc').observe('click', toggleTaskDtStart);
782 $('nodue').observe('click', toggleTaskDue);
783 $('due_time_assoc').observe('click', toggleTaskDue);
786 function TaskViewGatherCategoriesFromTable() {
787 var table = $('taskview');
790 function attachDatePicker(relative) {
791 var dpck = new DatePicker({
793 language: 'en', //wclang.substr(0,2),
794 disableFutureDate: false,
795 dateFormat: [ ["yyyy", "mm", "dd"], "-"],
798 document.getElementById(relative).dpck = dpck; // attach a ref to it
800 function eventEditAllDay() {
801 var allDayCheck = document.getElementById("alldayevent");
802 var dtend_time = document.getElementById("dtend_time");
803 var dtstart_time = document.getElementById("dtstart_time");
804 if(allDayCheck.checked) {
805 dtstart_time.style.visibility = "hidden";
806 dtend_time.style.visibility = "hidden";
808 dtstart_time.style.visibility = "visible";
809 dtend_time.style.visibility = "visible";
813 // Functions which handle show/hide of various elements in the recurrence editor
815 function RecurrenceShowHide() {
817 if ($('is_recur').checked) {
818 $('rrule_div').style.display = 'block';
821 $('rrule_div').style.display = 'none';
824 if ($('freq_selector').selectedIndex == 4) {
825 $('weekday_selector').style.display = 'block';
828 $('weekday_selector').style.display = 'none';
831 if ($('freq_selector').selectedIndex == 5) {
832 $('monthday_selector').style.display = 'block';
835 $('monthday_selector').style.display = 'none';
838 if ($('rrend_count').checked) {
839 $('rrcount').disabled = false;
842 $('rrcount').disabled = true;
845 if ($('rrend_until').checked) {
846 $('rruntil').disabled = false;
849 $('rruntil').disabled = true;
852 if ($('rrmonthtype_mday').checked) {
853 $('rrmday').disabled = false;
856 $('rrmday').disabled = true;
859 if ($('rrmonthtype_wday').checked) {
860 $('rrmweek').disabled = false;
861 $('rrmweekday').disabled = false;
864 $('rrmweek').disabled = true;
865 $('rrmweekday').disabled = true;
868 if ($('freq_selector').selectedIndex == 6) {
869 $('yearday_selector').style.display = 'block';
872 $('yearday_selector').style.display = 'none';
875 $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
876 $('rrmday').innerHTML = $('dtstart').value.substr(8);
878 if ($('rryeartype_ywday').checked) {
879 $('rrymweek').disabled = false;
880 $('rrymweekday').disabled = false;
881 $('rrymonth').disabled = false;
884 $('rrymweek').disabled = true;
885 $('rrymweekday').disabled = true;
886 $('rrymonth').disabled = true;
892 // Enable or disable the 'check attendee availability' button depending on whether
893 // the attendees list is empty
894 function EnableOrDisableCheckButton()
896 if ($('attendees_box').value.length == 0) {
897 $('check_button').disabled = true;
900 $('check_button').disabled = false;
907 function launchChat(event) {
908 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
911 function WCLog(msg) {
912 if (!!window.console && !!console.log) {
914 } else if (!!window.opera && !!opera.postError) {
915 opera.postError(msg);
917 wc_log += msg + "\r\n";
921 function RefreshSMTPqueueDisplay() {
922 new Ajax.Updater('smtpqueue_inner_div',
923 'display_smtpqueue_inner_div', { method: 'get',
924 parameters: Math.random() } );
927 function DeleteSMTPqueueMsg(msgnum1, msgnum2) {
928 var p = encodeURI('g_cmd=DELE ' + msgnum1 + ',' + msgnum2);
933 onComplete: RefreshSMTPqueueDisplay()
939 function ConfirmLogoff() {
942 'do_template?template=confirmlogoff',
946 onSuccess: function(cl_success) {
954 function switch_to_lang(new_lang) {
955 p = 'push?url=' + encodeURI(window.location);
956 new Ajax.Request(p, { method: 'get' } );
957 window.location = 'switch_language?lang=' + new_lang ;
961 function toggle_roomlist()
963 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
964 if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) {
965 $('roomlist').style.display = 'none';
966 $('expand_roomlist').src = 'static/webcit_icons/expand.gif';
971 $('roomlist').style.display = 'block';
972 $('expand_roomlist').src = 'static/webcit_icons/collapse.gif';
973 $('roomlist').innerHTML = '';
974 FillRooms(IconBarRoomList);
978 // tell the server what I did
979 p = 'toggle_roomlist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
980 new Ajax.Request(p, { method: 'get' } );
982 return false; /* this prevents the click from registering as a roomlist button press */
986 function toggle_wholist()
988 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
989 if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
990 $('online_users').style.display = 'none';
991 $('expand_wholist').src = 'static/webcit_icons/expand.gif';
996 $('online_users').style.display = 'block';
997 $('expand_wholist').src = 'static/webcit_icons/collapse.gif';
998 activate_iconbar_wholist_populat0r();
1002 // tell the server what I did
1003 p = 'toggle_wholist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
1004 new Ajax.Request(p, { method: 'get' } );
1006 return false; /* this prevents the click from registering as a wholist button press */