2 * Copyright 2005 - 2010 The Citadel Team
3 * Licensed under the GPL V3
5 * JavaScript function library for WebCit.
10 var room_is_trash = 0;
12 var currentlyExpandedFloor = null;
15 var _switchToRoomList = "switch to room list";
16 var _switchToMenu = "switch to menu";
18 var currentDropTarget = null;
20 var supportsAddEventListener = (!!document.addEventListener);
21 var today = new Date();
24 if (document.all) {browserType = "ie"}
25 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
28 var ns6=document.getElementById&&!document.all;
29 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
30 Event.observe(window, 'load', taskViewActivate);
31 //document.observe("dom:loaded", setupPrefEngine);
32 document.observe("dom:loaded", setupIconBar);
33 function CtdlRandomString() {
34 return((Math.random()+'').substr(3));
36 function strcmp ( str1, str2 ) {
37 // http://kevin.vanzonneveld.net
38 // + original by: Waldo Malqui Silva
39 // + input by: Steve Hilder
40 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
41 // + revised by: gorthaur
42 // * example 1: strcmp( 'waldo', 'owald' );
44 // * example 2: strcmp( 'owald', 'waldo' );
47 return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) );
52 function ToggleVisibility ($Which)
54 if (document.getElementById)
56 if (document.getElementById($Which).style.display == "none")
57 document.getElementById($Which).style.display = "inline";
59 document.getElementById($Which).style.display = "none";
63 function emptyElement(element) {
64 childNodes = element.childNodes;
65 for(var i=0; i<childNodes.length; i++) {
67 element.removeChild(childNodes[i]);
69 WCLog(e+"|"+e.description);
73 /** Implements superior internet explorer 'extract all child text from element' feature'. Falls back on buggy, patent violating standardized method */
74 function getTextContent(element) {
75 if (element.textContent == undefined) {
76 return element.innerText;
78 return element.textContent;
80 /** Same reasons as above */
81 function setTextContent(element, textContent) {
82 if(element.textContent == undefined) {
83 element.innerText = textContent;
85 element.textContent = textContent;
89 // We love string tokenizers.
90 function extract_token(source_string, token_num, delimiter) {
92 var extracted_string = source_string;
95 for (i=0; i<token_num; ++i) {
96 var j = extracted_string.indexOf(delimiter);
98 extracted_string = extracted_string.substr(j+1);
103 j = extracted_string.indexOf(delimiter);
105 extracted_string = extracted_string.substr(0, j);
108 return extracted_string;
111 function CtdlSpawnContextMenu(event, source) {
112 // remove any existing menus
113 disintergrateContextMenus(null);
114 var x = event.clientX-10; // cut a few pixels out so our mouseout works right
115 var y = event.clientY-10;
116 var contextDIV = document.createElement("div");
117 contextDIV.setAttribute("id", "ctdlContextMenu");
118 document.body.appendChild(contextDIV);
119 var sourceChildren = source.childNodes;
120 for(var j=0; j<sourceChildren.length; j++) {
121 contextDIV.appendChild(sourceChildren[j].cloneNode(true));
123 var leftRule = "left: "+x+"px;";
124 contextDIV.setAttribute("style", leftRule);
125 contextDIV.setAttribute("actual", leftRule);
126 contextDIV.style.top = y+"px";
127 contextDIV.style.display = "block";
128 $(contextDIV).observe('mouseout',disintergrateContextMenus);
130 function disintergrateContextMenus(event) {
131 var contextMenu = document.getElementById("ctdlContextMenu");
133 contextMenu.parentNode.removeChild(contextMenu);
135 Event.stopObserving(document,'click',disintergrateContextMenus);
137 // This code handles the popups for important-messages.
138 function hide_imsg_popup() {
139 if (browserType == "gecko") {
140 document.poppedLayer = eval('document.getElementById(\'important_message\')');
142 else if (browserType == "ie") {
143 document.poppedLayer = eval('document.all[\'important_message\']');
146 document.poppedLayer = eval('document.layers[\'`important_message\']');
149 document.poppedLayer.style.visibility = "hidden";
153 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
154 function activate_entmsg_autocompleters() {
155 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
156 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
157 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
160 function activate_iconbar_wholist_populat0r()
162 new Ajax.PeriodicalUpdater('online_users', 'do_template?template=who_iconbar', {method: 'get', frequency: 30});
165 function setupIconBar() {
166 if (!document.getElementById("switch")) {
169 _switchToRoomList = getTextContent(document.getElementById("rmlist_template"));
170 _switchToMenu = getTextContent(document.getElementById("mnlist_template"));
171 var switchSpan = document.getElementById("switch").firstChild;
172 if (switchSpan != null) {
173 setTextContent(switchSpan, _switchToRoomList);
174 $(switchSpan).observe('click', changeIconBarEvent);
175 var currentView = ctdlLocalPrefs.readPref("iconbar_view");
176 if (currentView != null) {
177 switchSpan.ctdlSwitchIconBarTo = currentView;
178 changeIconBar(switchSpan);
180 switchSpan.ctdlSwitchIconBarTo = "rooms";
183 var online_users = document.getElementById("online_users");
185 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
186 if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
187 $('online_users').style.display = 'block';
188 activate_iconbar_wholist_populat0r();
191 $('online_users').style.display = 'none';
195 function changeIconBarEvent(event) {
196 changeIconBar(event.target);
198 function changeIconBar(target) {
199 var switchTo = target.ctdlSwitchIconBarTo;
200 WCLog("Changing to: " + switchTo);
201 ctdlLocalPrefs.setPref("iconbar_view", target.ctdlSwitchIconBarTo);
202 if (switchTo == "rooms") {
203 switch_to_room_list();
204 setTextContent(target, _switchToMenu);
205 target.ctdlSwitchIconBarTo = "menu";
207 switch_to_menu_buttons();
208 setTextContent(target, _switchToRoomList);
209 target.ctdlSwitchIconBarTo = "rooms";
212 function switch_to_room_list() {
213 var roomlist = document.getElementById("roomlist");
214 var summary = document.getElementById("iconbar_menu");
215 if (!rooms || !floors || !roomlist) {
216 FillRooms(IconBarRoomList);
218 roomlist.className = roomlist.className.replace("hidden","");
219 summary.className += " hidden";
222 function switch_to_menu_buttons() {
223 if (roomlist != null) {
224 roomlist.className += "hidden";
226 var iconbar = document.getElementById("iconbar_menu");
227 iconbar.className = iconbar.className.replace("hidden","");
228 var roomlist = document.getElementById("roomlist");
229 roomlist.className += " hidden";
232 function GenericTreeRoomList(roomlist) {
233 var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
234 var curRoomName = "";
235 if (document.getElementById("rmname")) {
236 curRoomName = getTextContent(document.getElementById("rmname"));
238 currentDropTargets = new Array();
239 var iconbar = document.getElementById("iconbar");
240 var ul = document.createElement("ul");
241 roomlist.appendChild(ul);
242 // Add mailbox, because they are special
243 var mailboxLI = document.createElement("li");
244 ul.appendChild(mailboxLI);
245 var mailboxSPAN = document.createElement("span");
246 var _mailbox = getTextContent(document.getElementById("mbox_template"));
247 mailboxSPAN.appendChild(document.createTextNode(_mailbox));
248 $(mailboxSPAN).observe('click', expandFloorEvent);
249 mailboxLI.appendChild(mailboxSPAN);
250 mailboxLI.className = "floor";
251 var mailboxUL = document.createElement("ul");
252 mailboxLI.appendChild(mailboxUL);
253 var mailboxRooms = GetMailboxRooms();
254 for(var i=0; i<mailboxRooms.length; i++) {
255 var room = mailboxRooms[i];
256 currentDropTargets.push(addRoomToList(mailboxUL, room, curRoomName));
258 if (currentExpanded != null && currentExpanded == _mailbox ) {
259 expandFloor(mailboxSPAN);
261 for(var a=0; a<floors.length; a++) {
262 var floor = floors[a];
263 var floornum = floor[0];
269 var floorLI = document.createElement("li");
270 ul.appendChild(floorLI);
271 var floorSPAN = document.createElement("span");
272 floorSPAN.appendChild(document.createTextNode(name));
273 $(floorSPAN).observe('click', expandFloorEvent);
274 floorLI.appendChild(floorSPAN);
275 floorLI.className = "floor";
276 var floorUL = document.createElement("ul");
277 floorLI.appendChild(floorUL);
278 var roomsForFloor = GetRoomsByFloorNum(floornum);
279 for(var b=0; b<roomsForFloor.length; b++) {
280 var room = roomsForFloor[b];
281 currentDropTargets.push(addRoomToList(floorUL, room, curRoomName));
283 if (currentExpanded != null && currentExpanded == name) {
284 expandFloor(floorSPAN);
289 function IconBarRoomList() {
290 roomlist = document.getElementById("roomlist");
291 GenericTreeRoomList(roomlist);
293 function KNRoomsRoomList() {
294 roomlist = document.getElementById("roomlist_knrooms");
295 GenericTreeRoomList(roomlist);
298 function addRoomToList(floorUL,room, roomToEmphasize) {
299 var roomName = room[RN_ROOM_NAME];
300 var flag = room[RN_ROOM_FLAG];
301 var curView = room[RN_CUR_VIEW];
302 var view = room[RN_DEF_VIEW];
303 var raflags = room[RN_RAFLAGS];
304 var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
305 var hasNewMsgs = ((raflags & UA_HASNEWMSGS) == UA_HASNEWMSGS);
306 var roomLI = document.createElement("li");
307 var roomA = document.createElement("a");
308 roomA.setAttribute("href","dotgoto?room="+roomName);
309 roomA.appendChild(document.createTextNode(roomName));
310 roomLI.appendChild(roomA);
311 floorUL.appendChild(roomLI);
312 var className = "room ";
313 if (view == VIEW_MAILBOX) {
314 className += "room-private"
315 } else if (view == VIEW_ADDRESSBOOK) {
316 className += "room-addr";
317 } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
318 className += "room-cal";
319 } else if (view == VIEW_TASKS) {
320 className += "room-tasks";
321 } else if (view == VIEW_NOTES) {
322 className += "room-notes";
324 className += "room-chat";
327 className += " room-newmsgs";
329 if (roomName == roomToEmphasize) {
330 className += " room-emphasized";
332 roomLI.setAttribute("class", className);
333 roomA.dropTarget = true;
334 roomA.dropHandler = roomListDropHandler;
338 function roomListDropHandler(target, dropped) {
339 if (dropped.getAttribute("citadel:msgid")) {
340 var room = getTextContent(target);
342 for(msgId in currentlyMarkedRows) { //defined in summaryview.js
345 var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
346 new Ajax.Request('ajax_servcmd', {
348 parameters: mvCommand,
349 onComplete: deleteAllMarkedRows()});
352 function expandFloorEvent(event) {
353 expandFloor(event.target);
355 function expandFloor(target) {
356 if (target.nodeName.toLowerCase() != "span") {
357 return; // ignore clicks on child UL
359 ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
360 var parentUL = target.parentNode;
361 if (currentlyExpandedFloor != null) {
362 currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
364 parentUL.className = parentUL.className + " floor-expanded";
365 currentlyExpandedFloor = parentUL;
368 // These functions handle moving sticky notes around the screen by dragging them
370 var uid_of_note_being_dragged = 0;
371 var saved_cursor_style = 'default';
372 var note_was_dragged = 0;
374 function NotesDragMouseUp(evt) {
375 document.onmouseup = null;
376 document.onmousemove = null;
377 if (document.layers) {
378 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
381 d = $('note-' + uid_of_note_being_dragged);
382 d.style.cursor = saved_cursor_style;
384 // If any motion actually occurred, submit an ajax http call to record it to the server
385 if (note_was_dragged > 0) {
386 p = 'note_uid=' + uid_of_note_being_dragged
387 + '&left=' + d.style.left
388 + '&top=' + d.style.top
389 + '&r=' + CtdlRandomString();
399 uid_of_note_being_dragged = '';
403 function NotesDragMouseMove(evt) {
404 x = (ns6 ? evt.clientX : event.clientX);
405 x_increment = x - saved_x;
406 y = (ns6 ? evt.clientY : event.clientY);
407 y_increment = y - saved_y;
410 d = $('note-' + uid_of_note_being_dragged);
412 divTop = parseInt(d.style.top);
413 divLeft = parseInt(d.style.left);
415 d.style.top = (divTop + y_increment) + 'px';
416 d.style.left = (divLeft + x_increment) + 'px';
420 note_was_dragged = 1;
425 function NotesDragMouseDown(evt, uid) {
426 saved_x = (ns6 ? evt.clientX : event.clientX);
427 saved_y = (ns6 ? evt.clientY : event.clientY);
428 document.onmouseup = NotesDragMouseUp;
429 document.onmousemove = NotesDragMouseMove;
430 if (document.layers) {
431 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
433 uid_of_note_being_dragged = uid;
434 d = $('note-' + uid_of_note_being_dragged);
435 saved_cursor_style = d.style.cursor;
436 d.style.cursor = 'move';
437 return false; // disable the default action
441 // Called when the user clicks on the palette icon of a sticky note to change its color.
442 // It toggles the color selector visible or invisible.
444 function NotesClickPalette(evt, uid) {
445 uid_of_note_being_colored = uid;
446 d = $('palette-' + uid_of_note_being_colored);
448 if (d.style.display) {
449 if (d.style.display == 'none') {
450 d.style.display = 'block';
453 d.style.display = 'none';
457 d.style.display = 'block';
464 // Called when the user clicks on one of the colors in an open color selector.
465 // Sets the desired color and then closes the color selector.
467 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
468 uid_of_note_being_colored = uid;
469 palette_button = $('palette-' + uid_of_note_being_colored);
470 note_div = $('note-' + uid_of_note_being_colored);
471 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
473 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
475 note_div.style.backgroundColor = notecolor;
476 titlebar_div.style.backgroundColor = titlecolor;
477 palette_button.style.display = 'none';
479 // submit an ajax http call to record it to the server
480 p = 'note_uid=' + uid_of_note_being_colored
484 + '&r=' + CtdlRandomString();
497 // These functions handle resizing sticky notes by dragging the resize handle
499 var uid_of_note_being_resized = 0;
500 var saved_cursor_style = 'default';
501 var note_was_resized = 0;
503 function NotesResizeMouseUp(evt) {
504 document.onmouseup = null;
505 document.onmousemove = null;
506 if (document.layers) {
507 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
510 d = $('note-' + uid_of_note_being_resized);
511 d.style.cursor = saved_cursor_style;
513 // If any motion actually occurred, submit an ajax http call to record it to the server
514 if (note_was_resized > 0) {
515 p = 'note_uid=' + uid_of_note_being_resized
516 + '&width=' + d.style.width
517 + '&height=' + d.style.height
518 + '&r=' + CtdlRandomString();
528 uid_of_note_being_resized = '';
529 return false; // disable the default action
532 function NotesResizeMouseMove(evt) {
533 x = (ns6 ? evt.clientX : event.clientX);
534 x_increment = x - saved_x;
535 y = (ns6 ? evt.clientY : event.clientY);
536 y_increment = y - saved_y;
539 d = $('note-' + uid_of_note_being_resized);
541 divTop = parseInt(d.style.height);
542 divLeft = parseInt(d.style.width);
544 newHeight = divTop + y_increment;
545 if (newHeight < 50) newHeight = 50;
547 newWidth = divLeft + x_increment;
548 if (newWidth < 50) newWidth = 50;
550 d.style.height = newHeight + 'px';
551 d.style.width = newWidth + 'px';
555 note_was_resized = 1;
556 return false; // disable the default action
560 function NotesResizeMouseDown(evt, uid) {
561 saved_x = (ns6 ? evt.clientX : event.clientX);
562 saved_y = (ns6 ? evt.clientY : event.clientY);
563 document.onmouseup = NotesResizeMouseUp;
564 document.onmousemove = NotesResizeMouseMove;
565 if (document.layers) {
566 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
568 uid_of_note_being_resized = uid;
569 d = $('note-' + uid_of_note_being_resized);
570 saved_cursor_style = d.style.cursor;
571 d.style.cursor = 'move';
572 return false; // disable the default action
576 function DeleteStickyNote(evt, uid, confirmation_prompt) {
577 uid_of_note_being_deleted = uid;
578 d = $('note-' + uid_of_note_being_deleted);
580 if (confirm(confirmation_prompt)) {
583 // submit an ajax http call to delete it on the server
584 p = 'note_uid=' + uid_of_note_being_deleted
586 + '&r=' + CtdlRandomString();
597 function ctdl_ts_getInnerText(el) {
598 if (typeof el == "string") return el;
599 if (typeof el == "undefined") { return el };
600 if (el.innerText) return el.innerText; //Not needed but it is faster
603 var cs = el.childNodes;
605 for (var i = 0; i < l; i++) {
606 switch (cs[i].nodeType) {
607 case 1: //ELEMENT_NODE
608 str += ts_getInnerText(cs[i]);
611 str += cs[i].nodeValue;
619 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
620 function CtdlLoadScreen(elementid) {
621 var elem = document.getElementById(elementid);
622 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>";
627 // Pop open the address book (target_input is the INPUT field to populate)
629 function PopOpenAddressBook(target_input) {
630 $('address_book_popup').style.display = 'block';
631 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
633 'address_book_popup_middle_div',
634 'display_address_book_middle_div',
643 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
644 $('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>";
645 p = 'which_addr_book=' + which_addr_book
646 + '&target_input=' + target_input
647 + '&r=' + CtdlRandomString();
649 'address_book_inner_div',
650 'display_address_book_inner_div',
658 // What happens when a contact is selected from the address book popup
659 // (populate the specified target)
661 function AddContactsToTarget(target, whichaddr) {
662 while (whichaddr.selectedIndex != -1) {
663 if (target.value.length > 0) {
664 target.value = target.value + ', ';
666 target.value = target.value + whichaddr.value;
667 whichaddr.options[whichaddr.selectedIndex].selected = false;
671 // Respond to a meeting invitation
672 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
673 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
674 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
675 Effect.Fade(question_divname, { duration: 0.5 });
678 // Handle a received RSVP
679 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
680 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
681 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
682 Effect.Fade(question_divname, { duration: 0.5 });
684 /* var fakeMouse = document.createEvent("MouseEvents");
685 fakeMouse.initMouseEvent("click", true, true, window,
686 0,0,0,0,0, false, false, false, false, 0, null); */
687 // TODO: Collapse into one function
688 function toggleTaskDtStart(event) {
689 var checkBox = $('nodtstart');
690 var checkBoxTime = $('dtstart_time_assoc');
691 var dtstart = document.getElementById("dtstart");
692 var dtstart_date = document.getElementById("dtstart_date");
693 var dtstart_time = document.getElementById("dtstart_time");
694 if (checkBox.checked) {
695 dtstart_date.style.visibility = "hidden";
696 dtstart_time.style.visibility = "hidden";
698 if (checkBoxTime.checked) {
699 dtstart_time.style.visibility = "visible";
701 dtstart_time.style.visibility = "hidden";
703 dtstart_date.style.visibility = "visible";
704 if (dtstart.value.length == 0)
705 dtstart.dpck._initCurrentDate();
708 function toggleTaskDue(event) {
709 var checkBox = $('nodue');
710 var checkBoxTime = $('due_time_assoc');
711 var due = document.getElementById("due");
712 var due_date = document.getElementById("due_date");
713 var due_time = document.getElementById("due_time");
714 if (checkBox.checked) {
715 due_date.style.visibility = "hidden";
716 due_time.style.visibility = "hidden";
718 if (checkBoxTime.checked) {
719 due_time.style.visibility = "visible";
721 due_time.style.visibility = "hidden";
723 due_date.style.visibility = "visible";
724 if (due.value.length == 0)
725 due.dpck._initCurrentDate();
728 function ToggleTaskDateOrNoDateActivate(event) {
729 var dtstart = document.getElementById("nodtstart");
730 if (dtstart != null) {
731 toggleTaskDtStart(null);
733 $('nodtstart').observe('click', toggleTaskDtStart);
734 $('dtstart_time_assoc').observe('click', toggleTaskDtStart);
735 $('nodue').observe('click', toggleTaskDue);
736 $('due_time_assoc').observe('click', toggleTaskDue);
739 function TaskViewGatherCategoriesFromTable() {
740 var table = $('taskview');
743 function attachDatePicker(relative) {
744 var dpck = new DatePicker({
746 language: 'en', //wclang.substr(0,2),
747 disableFutureDate: false,
748 dateFormat: [ ["yyyy", "mm", "dd"], "-"],
751 document.getElementById(relative).dpck = dpck; // attach a ref to it
753 function eventEditAllDay() {
754 var allDayCheck = document.getElementById("alldayevent");
755 var dtend_time = document.getElementById("dtend_time");
756 var dtstart_time = document.getElementById("dtstart_time");
757 if(allDayCheck.checked) {
758 dtstart_time.style.visibility = "hidden";
759 dtend_time.style.visibility = "hidden";
761 dtstart_time.style.visibility = "visible";
762 dtend_time.style.visibility = "visible";
766 // Functions which handle show/hide of various elements in the recurrence editor
768 function RecurrenceShowHide() {
770 if ($('is_recur').checked) {
771 $('rrule_div').style.display = 'block';
774 $('rrule_div').style.display = 'none';
777 if ($('freq_selector').selectedIndex == 4) {
778 $('weekday_selector').style.display = 'block';
781 $('weekday_selector').style.display = 'none';
784 if ($('freq_selector').selectedIndex == 5) {
785 $('monthday_selector').style.display = 'block';
788 $('monthday_selector').style.display = 'none';
791 if ($('rrend_count').checked) {
792 $('rrcount').disabled = false;
795 $('rrcount').disabled = true;
798 if ($('rrend_until').checked) {
799 $('rruntil').disabled = false;
802 $('rruntil').disabled = true;
805 if ($('rrmonthtype_mday').checked) {
806 $('rrmday').disabled = false;
809 $('rrmday').disabled = true;
812 if ($('rrmonthtype_wday').checked) {
813 $('rrmweek').disabled = false;
814 $('rrmweekday').disabled = false;
817 $('rrmweek').disabled = true;
818 $('rrmweekday').disabled = true;
821 if ($('freq_selector').selectedIndex == 6) {
822 $('yearday_selector').style.display = 'block';
825 $('yearday_selector').style.display = 'none';
828 $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
829 $('rrmday').innerHTML = $('dtstart').value.substr(8);
831 if ($('rryeartype_ywday').checked) {
832 $('rrymweek').disabled = false;
833 $('rrymweekday').disabled = false;
834 $('rrymonth').disabled = false;
837 $('rrymweek').disabled = true;
838 $('rrymweekday').disabled = true;
839 $('rrymonth').disabled = true;
845 // Enable or disable the 'check attendee availability' button depending on whether
846 // the attendees list is empty
847 function EnableOrDisableCheckButton()
849 if ($('attendees_box').value.length == 0) {
850 $('check_button').disabled = true;
853 $('check_button').disabled = false;
860 function launchChat(event) {
861 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
864 function WCLog(msg) {
865 if (!!window.console && !!console.log) {
867 } else if (!!window.opera && !!opera.postError) {
868 opera.postError(msg);
870 wc_log += msg + "\r\n";
874 function RefreshSMTPqueueDisplay() {
875 new Ajax.Updater('smtpqueue_inner_div',
876 'display_smtpqueue_inner_div', { method: 'get',
877 parameters: Math.random() } );
880 function DeleteSMTPqueueMsg(msgnum1, msgnum2) {
881 var p = encodeURI('g_cmd=DELE ' + msgnum1 + ',' + msgnum2);
886 onComplete: RefreshSMTPqueueDisplay()
892 function ConfirmLogoff() {
895 'do_template?template=confirmlogoff',
898 onSuccess: function(cl_success) {
906 function switch_to_lang(new_lang) {
907 p = 'push?url=' + encodeURI(window.location);
908 new Ajax.Request(p, { method: 'get' } );
909 window.location = 'switch_language?lang=' + new_lang ;
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/expand.gif';
923 $('online_users').style.display = 'block';
924 $('expand_wholist').src = 'static/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 */