3 * Copyright 2005 - 2009 The Citadel Team
4 * Licensed under the GPL V3
6 * JavaScript function library for WebCit.
12 var room_is_trash = 0;
14 var currentlyExpandedFloor = null;
17 var _switchToRoomList = "switch to room list";
18 var _switchToMenu = "switch to menu";
20 var currentDropTarget = null;
22 var supportsAddEventListener = (!!document.addEventListener);
23 var today = new Date();
27 if (document.all) {browserType = "ie"}
28 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
31 var ns6=document.getElementById&&!document.all;
32 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
33 Event.observe(window, 'load', taskViewActivate);
34 Event.observe(window, 'load', fixbanner);
35 Event.observe(window, 'load', resizeViewport);
36 Event.observe(window, 'resize', resizeViewport);
37 //document.observe("dom:loaded", setupPrefEngine);
38 document.observe("dom:loaded", setupIconBar);
39 function CtdlRandomString() {
40 return((Math.random()+'').substr(3));
42 function strcmp ( str1, str2 ) {
43 // http://kevin.vanzonneveld.net
44 // + original by: Waldo Malqui Silva
45 // + input by: Steve Hilder
46 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
47 // + revised by: gorthaur
48 // * example 1: strcmp( 'waldo', 'owald' );
50 // * example 2: strcmp( 'owald', 'waldo' );
53 return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) );
56 function emptyElement(element) {
57 childNodes = element.childNodes;
58 for(var i=0; i<childNodes.length; i++) {
60 element.removeChild(childNodes[i]);
62 WCLog(e+"|"+e.description);
66 /** Implements superior internet explorer 'extract all child text from element' feature'. Falls back on buggy, patent violating standardized method */
67 function getTextContent(element) {
68 if (element.textContent == undefined) {
69 return element.innerText;
71 return element.textContent;
73 /** Same reasons as above */
74 function setTextContent(element, textContent) {
75 if(element.textContent == undefined) {
76 element.innerText = textContent;
78 element.textContent = textContent;
82 // We love string tokenizers.
83 function extract_token(source_string, token_num, delimiter) {
85 var extracted_string = source_string;
88 for (i=0; i<token_num; ++i) {
89 var j = extracted_string.indexOf(delimiter);
91 extracted_string = extracted_string.substr(j+1);
96 j = extracted_string.indexOf(delimiter);
98 extracted_string = extracted_string.substr(0, j);
101 return extracted_string;
104 function CtdlSpawnContextMenu(event, source) {
105 // remove any existing menus
106 disintergrateContextMenus(null);
107 var x = event.clientX-10; // cut a few pixels out so our mouseout works right
108 var y = event.clientY-10;
109 var contextDIV = document.createElement("div");
110 contextDIV.setAttribute("id", "ctdlContextMenu");
111 document.body.appendChild(contextDIV);
112 var sourceChildren = source.childNodes;
113 for(var j=0; j<sourceChildren.length; j++) {
114 contextDIV.appendChild(sourceChildren[j].cloneNode(true));
116 var leftRule = "left: "+x+"px;";
117 contextDIV.setAttribute("style", leftRule);
118 contextDIV.setAttribute("actual", leftRule);
119 contextDIV.style.top = y+"px";
120 contextDIV.style.display = "block";
121 $(contextDIV).observe('mouseout',disintergrateContextMenus);
123 function disintergrateContextMenus(event) {
124 var contextMenu = document.getElementById("ctdlContextMenu");
126 contextMenu.parentNode.removeChild(contextMenu);
128 Event.stopObserving(document,'click',disintergrateContextMenus);
130 // This code handles the popups for important-messages.
131 function hide_imsg_popup() {
132 if (browserType == "gecko") {
133 document.poppedLayer = eval('document.getElementById(\'important_message\')');
135 else if (browserType == "ie") {
136 document.poppedLayer = eval('document.all[\'important_message\']');
139 document.poppedLayer = eval('document.layers[\'`important_message\']');
142 document.poppedLayer.style.visibility = "hidden";
146 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
147 function activate_entmsg_autocompleters() {
148 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
149 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
150 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
153 function setupIconBar() {
154 if (!document.getElementById("switch")) {
157 _switchToRoomList = getTextContent(document.getElementById("rmlist_template"));
158 _switchToMenu = getTextContent(document.getElementById("mnlist_template"));
159 var switchSpan = document.getElementById("switch").firstChild;
160 if (switchSpan != null) {
161 setTextContent(switchSpan, _switchToRoomList);
162 $(switchSpan).observe('click', changeIconBarEvent);
163 var currentView = ctdlLocalPrefs.readPref("iconbar_view");
164 if (currentView != null) {
165 switchSpan.ctdlSwitchIconBarTo = currentView;
166 changeIconBar(switchSpan);
168 switchSpan.ctdlSwitchIconBarTo = "rooms";
171 var online_users = document.getElementById("online_users");
172 if (online_users.offsetParent != null && online_users.offsetTop > 0) {
173 new Ajax.PeriodicalUpdater('online_users', 'do_template?template=who_iconbar', {method: 'get', frequency: 30});
176 function changeIconBarEvent(event) {
177 changeIconBar(event.target);
179 function changeIconBar(target) {
180 var switchTo = target.ctdlSwitchIconBarTo;
181 WCLog("Changing to: " + switchTo);
182 ctdlLocalPrefs.setPref("iconbar_view", target.ctdlSwitchIconBarTo);
183 if (switchTo == "rooms") {
184 switch_to_room_list();
185 setTextContent(target, _switchToMenu);
186 target.ctdlSwitchIconBarTo = "menu";
188 switch_to_menu_buttons();
189 setTextContent(target, _switchToRoomList);
190 target.ctdlSwitchIconBarTo = "rooms";
193 function switch_to_room_list() {
194 var roomlist = document.getElementById("roomlist");
195 var summary = document.getElementById("iconbar_menu");
196 if (!rooms || !floors || !roomlist) {
197 FillRooms(IconBarRoomList);
199 roomlist.className = roomlist.className.replace("hidden","");
200 summary.className += " hidden";
203 function switch_to_menu_buttons() {
204 if (roomlist != null) {
205 roomlist.className += "hidden";
207 var iconbar = document.getElementById("iconbar_menu");
208 iconbar.className = iconbar.className.replace("hidden","");
209 var roomlist = document.getElementById("roomlist");
210 roomlist.className += " hidden";
213 function GenericTreeRoomList(roomlist) {
214 var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
215 var curRoomName = "";
216 if (document.getElementById("rmname")) {
217 curRoomName = getTextContent(document.getElementById("rmname"));
219 currentDropTargets = new Array();
220 var iconbar = document.getElementById("iconbar");
221 var ul = document.createElement("ul");
222 roomlist.appendChild(ul);
223 // Add mailbox, because they are special
224 var mailboxLI = document.createElement("li");
225 ul.appendChild(mailboxLI);
226 var mailboxSPAN = document.createElement("span");
227 var _mailbox = getTextContent(document.getElementById("mbox_template"));
228 mailboxSPAN.appendChild(document.createTextNode(_mailbox));
229 $(mailboxSPAN).observe('click', expandFloorEvent);
230 mailboxLI.appendChild(mailboxSPAN);
231 mailboxLI.className = "floor";
232 var mailboxUL = document.createElement("ul");
233 mailboxLI.appendChild(mailboxUL);
234 var mailboxRooms = GetMailboxRooms();
235 for(var i=0; i<mailboxRooms.length; i++) {
236 var room = mailboxRooms[i];
237 currentDropTargets.push(addRoomToList(mailboxUL, room, curRoomName));
239 if (currentExpanded != null && currentExpanded == _mailbox ) {
240 expandFloor(mailboxSPAN);
242 for(var a=0; a<floors.length; a++) {
243 var floor = floors[a];
244 var floornum = floor[0];
250 var floorLI = document.createElement("li");
251 ul.appendChild(floorLI);
252 var floorSPAN = document.createElement("span");
253 floorSPAN.appendChild(document.createTextNode(name));
254 $(floorSPAN).observe('click', expandFloorEvent);
255 floorLI.appendChild(floorSPAN);
256 floorLI.className = "floor";
257 var floorUL = document.createElement("ul");
258 floorLI.appendChild(floorUL);
259 var roomsForFloor = GetRoomsByFloorNum(floornum);
260 for(var b=0; b<roomsForFloor.length; b++) {
261 var room = roomsForFloor[b];
262 currentDropTargets.push(addRoomToList(floorUL, room, curRoomName));
264 if (currentExpanded != null && currentExpanded == name) {
265 expandFloor(floorSPAN);
270 function IconBarRoomList() {
271 roomlist = document.getElementById("roomlist");
272 GenericTreeRoomList(roomlist);
274 function KNRoomsRoomList() {
275 roomlist = document.getElementById("roomlist_knrooms");
276 GenericTreeRoomList(roomlist);
279 function addRoomToList(floorUL,room, roomToEmphasize) {
280 var roomName = room[RN_ROOM_NAME];
281 var flag = room[RN_ROOM_FLAG];
282 var curView = room[RN_CUR_VIEW];
283 var view = room[RN_DEF_VIEW];
284 var raflags = room[RN_RAFLAGS];
285 var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
286 var hasNewMsgs = ((raflags & UA_HASNEWMSGS) == UA_HASNEWMSGS);
287 var roomLI = document.createElement("li");
288 var roomA = document.createElement("a");
289 roomA.setAttribute("href","dotgoto?room="+roomName);
290 roomA.appendChild(document.createTextNode(roomName));
291 roomLI.appendChild(roomA);
292 floorUL.appendChild(roomLI);
293 var className = "room ";
294 if (view == VIEW_MAILBOX) {
295 className += "room-private"
296 } else if (view == VIEW_ADDRESSBOOK) {
297 className += "room-addr";
298 } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
299 className += "room-cal";
300 } else if (view == VIEW_TASKS) {
301 className += "room-tasks";
302 } else if (view == VIEW_NOTES) {
303 className += "room-notes";
305 className += "room-chat";
308 className += " room-newmsgs";
310 if (roomName == roomToEmphasize) {
311 className += " room-emphasized";
313 roomLI.setAttribute("class", className);
314 roomA.dropTarget = true;
315 roomA.dropHandler = roomListDropHandler;
319 function roomListDropHandler(target, dropped) {
320 if (dropped.getAttribute("citadel:msgid")) {
321 var room = getTextContent(target);
323 for(msgId in currentlyMarkedRows) { //defined in summaryview.js
326 var mvCommand = "g_cmd=MOVE " + msgIds + "|"+room+"|0";
327 new Ajax.Request('ajax_servcmd', {
329 parameters: mvCommand,
330 onComplete: deleteAllMarkedRows()});
333 function expandFloorEvent(event) {
334 expandFloor(event.target);
336 function expandFloor(target) {
337 if (target.nodeName.toLowerCase() != "span") {
338 return; // ignore clicks on child UL
340 ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
341 var parentUL = target.parentNode;
342 if (currentlyExpandedFloor != null) {
343 currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
345 parentUL.className = parentUL.className + " floor-expanded";
346 currentlyExpandedFloor = parentUL;
349 // These functions handle moving sticky notes around the screen by dragging them
351 var uid_of_note_being_dragged = 0;
352 var saved_cursor_style = 'default';
353 var note_was_dragged = 0;
355 function NotesDragMouseUp(evt) {
356 document.onmouseup = null;
357 document.onmousemove = null;
358 if (document.layers) {
359 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
362 d = $('note-' + uid_of_note_being_dragged);
363 d.style.cursor = saved_cursor_style;
365 // If any motion actually occurred, submit an ajax http call to record it to the server
366 if (note_was_dragged > 0) {
367 p = 'note_uid=' + uid_of_note_being_dragged
368 + '&left=' + d.style.left
369 + '&top=' + d.style.top
370 + '&r=' + CtdlRandomString();
380 uid_of_note_being_dragged = '';
384 function NotesDragMouseMove(evt) {
385 x = (ns6 ? evt.clientX : event.clientX);
386 x_increment = x - saved_x;
387 y = (ns6 ? evt.clientY : event.clientY);
388 y_increment = y - saved_y;
391 d = $('note-' + uid_of_note_being_dragged);
393 divTop = parseInt(d.style.top);
394 divLeft = parseInt(d.style.left);
396 d.style.top = (divTop + y_increment) + 'px';
397 d.style.left = (divLeft + x_increment) + 'px';
401 note_was_dragged = 1;
406 function NotesDragMouseDown(evt, uid) {
407 saved_x = (ns6 ? evt.clientX : event.clientX);
408 saved_y = (ns6 ? evt.clientY : event.clientY);
409 document.onmouseup = NotesDragMouseUp;
410 document.onmousemove = NotesDragMouseMove;
411 if (document.layers) {
412 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
414 uid_of_note_being_dragged = uid;
415 d = $('note-' + uid_of_note_being_dragged);
416 saved_cursor_style = d.style.cursor;
417 d.style.cursor = 'move';
418 return false; // disable the default action
422 // Called when the user clicks on the palette icon of a sticky note to change its color.
423 // It toggles the color selector visible or invisible.
425 function NotesClickPalette(evt, uid) {
426 uid_of_note_being_colored = uid;
427 d = $('palette-' + uid_of_note_being_colored);
429 if (d.style.display) {
430 if (d.style.display == 'none') {
431 d.style.display = 'block';
434 d.style.display = 'none';
438 d.style.display = 'block';
445 // Called when the user clicks on one of the colors in an open color selector.
446 // Sets the desired color and then closes the color selector.
448 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
449 uid_of_note_being_colored = uid;
450 palette_button = $('palette-' + uid_of_note_being_colored);
451 note_div = $('note-' + uid_of_note_being_colored);
452 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
454 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
456 note_div.style.backgroundColor = notecolor;
457 titlebar_div.style.backgroundColor = titlecolor;
458 palette_button.style.display = 'none';
460 // submit an ajax http call to record it to the server
461 p = 'note_uid=' + uid_of_note_being_colored
465 + '&r=' + CtdlRandomString();
478 // These functions handle resizing sticky notes by dragging the resize handle
480 var uid_of_note_being_resized = 0;
481 var saved_cursor_style = 'default';
482 var note_was_resized = 0;
484 function NotesResizeMouseUp(evt) {
485 document.onmouseup = null;
486 document.onmousemove = null;
487 if (document.layers) {
488 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
491 d = $('note-' + uid_of_note_being_resized);
492 d.style.cursor = saved_cursor_style;
494 // If any motion actually occurred, submit an ajax http call to record it to the server
495 if (note_was_resized > 0) {
496 p = 'note_uid=' + uid_of_note_being_resized
497 + '&width=' + d.style.width
498 + '&height=' + d.style.height
499 + '&r=' + CtdlRandomString();
509 uid_of_note_being_resized = '';
510 return false; // disable the default action
513 function NotesResizeMouseMove(evt) {
514 x = (ns6 ? evt.clientX : event.clientX);
515 x_increment = x - saved_x;
516 y = (ns6 ? evt.clientY : event.clientY);
517 y_increment = y - saved_y;
520 d = $('note-' + uid_of_note_being_resized);
522 divTop = parseInt(d.style.height);
523 divLeft = parseInt(d.style.width);
525 newHeight = divTop + y_increment;
526 if (newHeight < 50) newHeight = 50;
528 newWidth = divLeft + x_increment;
529 if (newWidth < 50) newWidth = 50;
531 d.style.height = newHeight + 'px';
532 d.style.width = newWidth + 'px';
536 note_was_resized = 1;
537 return false; // disable the default action
541 function NotesResizeMouseDown(evt, uid) {
542 saved_x = (ns6 ? evt.clientX : event.clientX);
543 saved_y = (ns6 ? evt.clientY : event.clientY);
544 document.onmouseup = NotesResizeMouseUp;
545 document.onmousemove = NotesResizeMouseMove;
546 if (document.layers) {
547 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
549 uid_of_note_being_resized = uid;
550 d = $('note-' + uid_of_note_being_resized);
551 saved_cursor_style = d.style.cursor;
552 d.style.cursor = 'move';
553 return false; // disable the default action
557 function DeleteStickyNote(evt, uid, confirmation_prompt) {
558 uid_of_note_being_deleted = uid;
559 d = $('note-' + uid_of_note_being_deleted);
561 if (confirm(confirmation_prompt)) {
564 // submit an ajax http call to delete it on the server
565 p = 'note_uid=' + uid_of_note_being_deleted
567 + '&r=' + CtdlRandomString();
578 function ctdl_ts_getInnerText(el) {
579 if (typeof el == "string") return el;
580 if (typeof el == "undefined") { return el };
581 if (el.innerText) return el.innerText; //Not needed but it is faster
584 var cs = el.childNodes;
586 for (var i = 0; i < l; i++) {
587 switch (cs[i].nodeType) {
588 case 1: //ELEMENT_NODE
589 str += ts_getInnerText(cs[i]);
592 str += cs[i].nodeValue;
600 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
601 function CtdlLoadScreen(elementid) {
602 var elem = document.getElementById(elementid);
603 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>";
608 // Pop open the address book (target_input is the INPUT field to populate)
610 function PopOpenAddressBook(target_input) {
611 $('address_book_popup').style.display = 'block';
612 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
614 'address_book_popup_middle_div',
615 'display_address_book_middle_div',
624 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
625 $('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>";
626 p = 'which_addr_book=' + which_addr_book
627 + '&target_input=' + target_input
628 + '&r=' + CtdlRandomString();
630 'address_book_inner_div',
631 'display_address_book_inner_div',
639 // What happens when a contact is selected from the address book popup
640 // (populate the specified target)
642 function AddContactsToTarget(target, whichaddr) {
643 while (whichaddr.selectedIndex != -1) {
644 if (target.value.length > 0) {
645 target.value = target.value + ', ';
647 target.value = target.value + whichaddr.value;
648 whichaddr.options[whichaddr.selectedIndex].selected = false;
652 // Respond to a meeting invitation
653 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
654 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
655 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
656 Effect.Fade(question_divname, { duration: 0.5 });
659 // Handle a received RSVP
660 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
661 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
662 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
663 Effect.Fade(question_divname, { duration: 0.5 });
665 /* var fakeMouse = document.createEvent("MouseEvents");
666 fakeMouse.initMouseEvent("click", true, true, window,
667 0,0,0,0,0, false, false, false, false, 0, null); */
668 // TODO: Collapse into one function
669 function toggleTaskDtStart(event) {
670 var checkBox = $('nodtstart');
671 var checkBoxTime = $('dtstart_time_assoc');
672 var dtstart = document.getElementById("dtstart");
673 var dtstart_date = document.getElementById("dtstart_date");
674 var dtstart_time = document.getElementById("dtstart_time");
675 if (checkBox.checked) {
676 dtstart_date.style.visibility = "hidden";
677 dtstart_time.style.visibility = "hidden";
679 if (checkBoxTime.checked) {
680 dtstart_time.style.visibility = "visible";
682 dtstart_time.style.visibility = "hidden";
684 dtstart_date.style.visibility = "visible";
685 if (dtstart.value.length == 0)
686 dtstart.dpck._initCurrentDate();
689 function toggleTaskDue(event) {
690 var checkBox = $('nodue');
691 var checkBoxTime = $('due_time_assoc');
692 var due = document.getElementById("due");
693 var due_date = document.getElementById("due_date");
694 var due_time = document.getElementById("due_time");
695 if (checkBox.checked) {
696 due_date.style.visibility = "hidden";
697 due_time.style.visibility = "hidden";
699 if (checkBoxTime.checked) {
700 due_time.style.visibility = "visible";
702 due_time.style.visibility = "hidden";
704 due_date.style.visibility = "visible";
705 if (due.value.length == 0)
706 due.dpck._initCurrentDate();
709 function ToggleTaskDateOrNoDateActivate(event) {
710 var dtstart = document.getElementById("nodtstart");
711 if (dtstart != null) {
712 toggleTaskDtStart(null);
714 $('nodtstart').observe('click', toggleTaskDtStart);
715 $('dtstart_time_assoc').observe('click', toggleTaskDtStart);
716 $('nodue').observe('click', toggleTaskDue);
717 $('due_time_assoc').observe('click', toggleTaskDue);
720 function TaskViewGatherCategoriesFromTable() {
721 var table = $('taskview');
724 function attachDatePicker(relative) {
725 var dpck = new DatePicker({
727 language: 'en', //wclang.substr(0,2),
728 disableFutureDate: false,
729 dateFormat: [ ["yyyy", "mm", "dd"], "-"],
732 document.getElementById(relative).dpck = dpck; // attach a ref to it
734 function eventEditAllDay() {
735 var allDayCheck = document.getElementById("alldayevent");
736 var dtend_time = document.getElementById("dtend_time");
737 var dtstart_time = document.getElementById("dtstart_time");
738 if(allDayCheck.checked) {
739 dtstart_time.style.visibility = "hidden";
740 dtend_time.style.visibility = "hidden";
742 dtstart_time.style.visibility = "visible";
743 dtend_time.style.visibility = "visible";
747 // Functions which handle show/hide of various elements in the recurrence editor
749 function RecurrenceShowHide() {
751 if ($('is_recur').checked) {
752 $('rrule_div').style.display = 'block';
755 $('rrule_div').style.display = 'none';
758 if ($('freq_selector').selectedIndex == 4) {
759 $('weekday_selector').style.display = 'block';
762 $('weekday_selector').style.display = 'none';
765 if ($('freq_selector').selectedIndex == 5) {
766 $('monthday_selector').style.display = 'block';
769 $('monthday_selector').style.display = 'none';
772 if ($('rrend_count').checked) {
773 $('rrcount').disabled = false;
776 $('rrcount').disabled = true;
779 if ($('rrend_until').checked) {
780 $('rruntil').disabled = false;
783 $('rruntil').disabled = true;
786 if ($('rrmonthtype_mday').checked) {
787 $('rrmday').disabled = false;
790 $('rrmday').disabled = true;
793 if ($('rrmonthtype_wday').checked) {
794 $('rrmweek').disabled = false;
795 $('rrmweekday').disabled = false;
798 $('rrmweek').disabled = true;
799 $('rrmweekday').disabled = true;
802 if ($('freq_selector').selectedIndex == 6) {
803 $('yearday_selector').style.display = 'block';
806 $('yearday_selector').style.display = 'none';
809 $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
810 $('rrmday').innerHTML = $('dtstart').value.substr(8);
812 if ($('rryeartype_ywday').checked) {
813 $('rrymweek').disabled = false;
814 $('rrymweekday').disabled = false;
815 $('rrymonth').disabled = false;
818 $('rrymweek').disabled = true;
819 $('rrymweekday').disabled = true;
820 $('rrymonth').disabled = true;
826 // Enable or disable the 'check attendee availability' button depending on whether
827 // the attendees list is empty
828 function EnableOrDisableCheckButton()
830 if ($('attendees_box').value.length == 0) {
831 $('check_button').disabled = true;
834 $('check_button').disabled = false;
841 function launchChat(event) {
842 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
845 function WCLog(msg) {
846 if (!!window.console && !!console.log) {
848 } else if (!!window.opera && !!opera.postError) {
849 opera.postError(msg);
851 wc_log += msg + "\r\n";
855 function fixMissingCSSTable(elems) {
856 if (elems[0] == null || elems[1] == null) {
859 if (elems[0].getStyle("display") != "table-cell") {
860 var parentNode = elems[0].parentNode;
861 var table = document.createElement("table");
862 table.style.width = "100%";
863 var tbody = document.createElement("tbody");
864 table.appendChild(tbody);
865 var tr = document.createElement("tr");
866 tbody.appendChild(tr);
867 parentNode.appendChild(table);
868 for(var i=0; i<elems.length; i++) {
869 parentNode.removeChild(elems[i]);
870 var td = document.createElement("td");
871 td.appendChild(elems[i]);
876 function fixbanner() {
877 // Use prototype api methods here
878 var elems = [$('room_banner'),$('actiondiv')];
879 fixMissingCSSTable(elems);
881 Event.observe(window, 'resize', makeContentScrollable);
882 makeContentScrollable();
885 function makeContentScrollable() {
886 if (document.getElementById("banner")
887 && document.getElementById("content")
888 && !document.getElementById("summary_view")) {
889 WCLog("makeContentScrollable");
890 document.body.style.overflowY="hidden";
891 var global = $("global");
892 global.className += "scrollable";
893 var content = document.getElementById("content");
894 var banner = document.getElementById("banner");
895 var bannerHeight = banner.offsetHeight;
896 banner.style.width="100%";
897 var bannerPercent = (bannerHeight/document.viewport.getHeight())*100;
898 //banner.style.height=bannerPercent+"%";
899 content.style.overflowY="scroll";
900 //content.style.top=bannerPercent+"%";
901 content.style.height=(100-bannerPercent)+"%";
902 content.style.right="0px";
905 function fixOffsetBanner() {
906 var banner = document.getElementById("banner");
907 if (banner.offsetLeft > 0) {
908 var viewportWidth = document.viewport.getWidth();
909 var iconbarWidth = document.getElementById("iconbar").offsetWidth;
910 var contentDiv = document.getElementById("content");
911 var newContentWidth = viewportWidth-iconbarWidth;
912 contentDiv.style.width = newContentWidth+"px";
915 /** Attempt to stop overflowing in x-axis in IE6 */
916 function resizeViewport() {
917 var documentWidth = 0;
918 var viewportWidth = document.viewport.getWidth();
919 var iconbar = $('iconbar');
920 var global = $('global');
921 if (iconbar == null || global == null || document.documentElement == null) {
924 if (typeof window.offsetWidth != 'undefined') {
925 documentWidth = window.offsetWidth;
927 documentWidth = document.documentElement.offsetWidth;
929 if (documentWidth > viewportWidth) {
930 WCLog("resizeViewport");
931 document.documentElement.style.width = viewportWidth+"px";
932 document.documentElement.style.overflowX = "hidden";
933 //viewportWidth = 0.98 * viewportWidth;
934 var newIconBarSize = 0.16 * viewportWidth;
935 var newContentSize = viewportWidth - newIconBarSize;
936 iconbar.style.width = newIconBarSize+"px";
937 global.style.width = newContentSize+"px";
941 function RefreshSMTPqueueDisplay() {
942 new Ajax.Updater('smtpqueue_inner_div',
943 'display_smtpqueue_inner_div', { method: 'get',
944 parameters: Math.random() } );
947 function DeleteSMTPqueueMsg(msgnum1, msgnum2) {
951 parameters: 'g_cmd=DELE ' + msgnum1 + ',' + msgnum2,
952 onComplete: RefreshSMTPqueueDisplay()