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 NetworkSynchronizeRoom(NodeName)
96 p= encodeURI('g_cmd=NSYN ' + NodeName);
97 new Ajax.Request('ajax_servcmd', {
100 onComplete: function(transport) { ajax_important_message(transport.responseText.substr(4));}
103 function ToggleVisibility ($Which)
105 if (document.getElementById)
107 if (document.getElementById($Which).style.display == "none")
108 document.getElementById($Which).style.display = "inline";
110 document.getElementById($Which).style.display = "none";
114 function emptyElement(element) {
115 childNodes = element.childNodes;
116 for(var i=0; i<childNodes.length; i++) {
118 element.removeChild(childNodes[i]);
120 WCLog(e+"|"+e.description);
124 /** Implements superior internet explorer 'extract all child text from element' feature'. Falls back on buggy, patent violating standardized method */
125 function getTextContent(element) {
126 if (element.textContent == undefined) {
127 return element.innerText;
129 return element.textContent;
131 /** Same reasons as above */
132 function setTextContent(element, textContent) {
133 if(element.textContent == undefined) {
134 element.innerText = textContent;
136 element.textContent = textContent;
140 // We love string tokenizers.
141 function extract_token(source_string, token_num, delimiter) {
143 var extracted_string = source_string;
146 for (i=0; i<token_num; ++i) {
147 var j = extracted_string.indexOf(delimiter);
149 extracted_string = extracted_string.substr(j+1);
154 j = extracted_string.indexOf(delimiter);
156 extracted_string = extracted_string.substr(0, j);
159 return extracted_string;
162 function CtdlSpawnContextMenu(event, source) {
163 // remove any existing menus
164 disintergrateContextMenus(null);
165 var x = event.clientX-10; // cut a few pixels out so our mouseout works right
166 var y = event.clientY-10;
167 var contextDIV = document.createElement("div");
168 contextDIV.setAttribute("id", "ctdlContextMenu");
169 document.body.appendChild(contextDIV);
170 var sourceChildren = source.childNodes;
171 for(var j=0; j<sourceChildren.length; j++) {
172 contextDIV.appendChild(sourceChildren[j].cloneNode(true));
174 var leftRule = "left: "+x+"px;";
175 contextDIV.setAttribute("style", leftRule);
176 contextDIV.setAttribute("actual", leftRule);
177 contextDIV.style.top = y+"px";
178 contextDIV.style.display = "block";
179 $(contextDIV).observe('mouseout',disintergrateContextMenus);
181 function disintergrateContextMenus(event) {
182 var contextMenu = document.getElementById("ctdlContextMenu");
184 contextMenu.parentNode.removeChild(contextMenu);
186 Event.stopObserving(document,'click',disintergrateContextMenus);
188 // This code handles the popups for important-messages.
189 function hide_imsg_popup() {
190 if (browserType == "gecko") {
191 document.poppedLayer = eval('document.getElementById(\'important_message\')');
193 else if (browserType == "ie") {
194 document.poppedLayer = eval('document.all[\'important_message\']');
197 document.poppedLayer = eval('document.layers[\'`important_message\']');
200 document.poppedLayer.style.visibility = "hidden";
202 function remove_something(what_to_search, new_visibility) {
203 if (browserType == "gecko") {
204 document.poppedLayer = eval('document.getElementById(\'' + what_to_search + '\')');
206 else if (browserType == "ie") {
207 document.poppedLayer = eval('document.all[\'' + what_to_search + '\']');
210 document.poppedLayer = eval('document.layers[\'`' + what_to_search + '\']');
212 if (document.poppedLayer!= null)
213 document.poppedLayer.innerHTML = "";
216 function unhide_imsg_popup() {
217 if (browserType == "gecko") {
218 document.poppedLayer = eval('document.getElementById(\'important_message\')');
220 else if (browserType == "ie") {
221 document.poppedLayer = eval('document.all[\'important_message\']');
224 document.poppedLayer = eval('document.layers[\'`important_message\']');
227 document.poppedLayer.style.visibility = "visible";
228 setTimeout('hide_imsg_popup()', 5000);
231 function ajax_important_message(messagetext)
233 if (browserType == "gecko") {
234 document.poppedLayer = eval('document.getElementById(\'important_message\')');
236 else if (browserType == "ie") {
237 document.poppedLayer = eval('document.all[\'important_message\']');
240 document.poppedLayer = eval('document.layers[\'`important_message\']');
242 document.poppedLayer.style.visibility = "visible";
243 setTimeout('hide_imsg_popup()', 5000);
244 document.poppedLayer.innerHTML = messagetext;
247 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
248 function activate_entmsg_autocompleters() {
249 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
250 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
251 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
254 function activate_iconbar_wholist_populat0r()
256 new Ajax.PeriodicalUpdater('online_users', 'do_template?template=who_iconbar', {method: 'get', frequency: 30});
259 function setupIconBar() {
261 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
262 if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) {
263 $('roomlist').style.display = 'block';
264 $('roomlist').innerHTML = '';
265 FillRooms(IconBarRoomList);
268 $('roomlist').style.display = 'none';
271 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
272 if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
273 $('online_users').style.display = 'block';
274 activate_iconbar_wholist_populat0r();
277 $('online_users').style.display = 'none';
282 function GenericTreeRoomList(roomlist) {
283 var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
284 var curRoomName = "";
285 if (document.getElementById("rmname")) {
286 curRoomName = getTextContent(document.getElementById("rmname"));
288 currentDropTargets = new Array();
289 var iconbar = document.getElementById("iconbar");
290 var ul = document.createElement("ul");
291 roomlist.appendChild(ul);
292 // Add mailbox, because they are special
293 var mailboxLI = document.createElement("li");
294 ul.appendChild(mailboxLI);
295 var mailboxSPAN = document.createElement("span");
296 var _mailbox = getTextContent(document.getElementById("mbox_template"));
297 mailboxSPAN.appendChild(document.createTextNode(_mailbox));
298 $(mailboxSPAN).observe('click', expandFloorEvent);
299 mailboxLI.appendChild(mailboxSPAN);
300 mailboxLI.className = "floor";
301 var mailboxUL = document.createElement("ul");
302 mailboxLI.appendChild(mailboxUL);
303 var mailboxRooms = GetMailboxRooms();
304 for(var i=0; i<mailboxRooms.length; i++) {
305 var room = mailboxRooms[i];
306 currentDropTargets.push(addRoomToList(mailboxUL, room, curRoomName));
308 if (currentExpanded != null && currentExpanded == _mailbox ) {
309 expandFloor(mailboxSPAN);
311 for(var a=0; a<floors.length; a++) {
312 var floor = floors[a];
313 var floornum = floor[0];
319 var floorLI = document.createElement("li");
320 ul.appendChild(floorLI);
321 var floorSPAN = document.createElement("span");
322 floorSPAN.appendChild(document.createTextNode(name));
323 $(floorSPAN).observe('click', expandFloorEvent);
324 floorLI.appendChild(floorSPAN);
325 floorLI.className = "floor";
326 var floorUL = document.createElement("ul");
327 floorLI.appendChild(floorUL);
328 var roomsForFloor = GetRoomsByFloorNum(floornum);
329 for(var b=0; b<roomsForFloor.length; b++) {
330 var room = roomsForFloor[b];
331 currentDropTargets.push(addRoomToList(floorUL, room, curRoomName));
333 if (currentExpanded != null && currentExpanded == name) {
334 expandFloor(floorSPAN);
339 function IconBarRoomList() {
340 roomlist = document.getElementById("roomlist");
341 GenericTreeRoomList(roomlist);
343 function KNRoomsRoomList() {
344 roomlist = document.getElementById("roomlist_knrooms");
345 GenericTreeRoomList(roomlist);
348 function addRoomToList(floorUL,room, roomToEmphasize) {
349 var roomName = room[RN_ROOM_NAME];
350 var flag = room[RN_ROOM_FLAG];
351 var curView = room[RN_CUR_VIEW];
352 var view = room[RN_DEF_VIEW];
353 var raflags = room[RN_RAFLAGS];
354 var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
355 var hasNewMsgs = ((raflags & UA_HASNEWMSGS) == UA_HASNEWMSGS);
356 var roomLI = document.createElement("li");
357 var roomA = document.createElement("a");
358 roomA.setAttribute("href","dotgoto?room="+encodeURIComponent(roomName));
359 roomA.appendChild(document.createTextNode(roomName));
360 roomLI.appendChild(roomA);
361 floorUL.appendChild(roomLI);
362 var className = "room ";
363 if (view == VIEW_MAILBOX) {
364 className += "room-private"
365 } else if (view == VIEW_ADDRESSBOOK) {
366 className += "room-addr";
367 } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
368 className += "room-cal";
369 } else if (view == VIEW_TASKS) {
370 className += "room-tasks";
371 } else if (view == VIEW_NOTES) {
372 className += "room-notes";
374 className += "room-chat";
377 className += " room-newmsgs";
379 if (roomName == roomToEmphasize) {
380 className += " room-emphasized";
382 roomLI.setAttribute("class", className);
383 roomA.dropTarget = true;
384 roomA.dropHandler = roomListDropHandler;
388 function roomListDropHandler(target, dropped) {
389 if (dropped.getAttribute("citadel:msgid")) {
390 var room = getTextContent(target);
392 for(msgId in currentlyMarkedRows) { //defined in summaryview.js
394 if (msgIds.length > 800) {
395 var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
396 new Ajax.Request("ajax_servcmd", {
397 parameters: mvCommand,
404 var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
405 new Ajax.Request('ajax_servcmd', {
407 parameters: mvCommand,
408 onComplete: deleteAllMarkedRows()});
411 function expandFloorEvent(event) {
412 expandFloor(event.target);
414 function expandFloor(target) {
415 if (target.nodeName.toLowerCase() != "span") {
416 return; // ignore clicks on child UL
418 ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
419 var parentUL = target.parentNode;
420 if (currentlyExpandedFloor != null) {
421 currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
423 parentUL.className = parentUL.className + " floor-expanded";
424 currentlyExpandedFloor = parentUL;
427 // These functions handle moving sticky notes around the screen by dragging them
429 var uid_of_note_being_dragged = 0;
430 var saved_cursor_style = 'default';
431 var note_was_dragged = 0;
433 function NotesDragMouseUp(evt) {
434 document.onmouseup = null;
435 document.onmousemove = null;
436 if (document.layers) {
437 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
440 d = $('note-' + uid_of_note_being_dragged);
441 d.style.cursor = saved_cursor_style;
443 // If any motion actually occurred, submit an ajax http call to record it to the server
444 if (note_was_dragged > 0) {
445 p = 'note_uid=' + uid_of_note_being_dragged
446 + '&left=' + d.style.left
447 + '&top=' + d.style.top
448 + '&r=' + CtdlRandomString();
458 uid_of_note_being_dragged = '';
462 function NotesDragMouseMove(evt) {
463 x = (ns6 ? evt.clientX : event.clientX);
464 x_increment = x - saved_x;
465 y = (ns6 ? evt.clientY : event.clientY);
466 y_increment = y - saved_y;
469 d = $('note-' + uid_of_note_being_dragged);
471 divTop = parseInt(d.style.top);
472 divLeft = parseInt(d.style.left);
474 d.style.top = (divTop + y_increment) + 'px';
475 d.style.left = (divLeft + x_increment) + 'px';
479 note_was_dragged = 1;
484 function NotesDragMouseDown(evt, uid) {
485 saved_x = (ns6 ? evt.clientX : event.clientX);
486 saved_y = (ns6 ? evt.clientY : event.clientY);
487 document.onmouseup = NotesDragMouseUp;
488 document.onmousemove = NotesDragMouseMove;
489 if (document.layers) {
490 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
492 uid_of_note_being_dragged = uid;
493 d = $('note-' + uid_of_note_being_dragged);
494 saved_cursor_style = d.style.cursor;
495 d.style.cursor = 'move';
496 return false; // disable the default action
500 // Called when the user clicks on the palette icon of a sticky note to change its color.
501 // It toggles the color selector visible or invisible.
503 function NotesClickPalette(evt, uid) {
504 uid_of_note_being_colored = uid;
505 d = $('palette-' + uid_of_note_being_colored);
507 if (d.style.display) {
508 if (d.style.display == 'none') {
509 d.style.display = 'block';
512 d.style.display = 'none';
516 d.style.display = 'block';
523 // Called when the user clicks on one of the colors in an open color selector.
524 // Sets the desired color and then closes the color selector.
526 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
527 uid_of_note_being_colored = uid;
528 palette_button = $('palette-' + uid_of_note_being_colored);
529 note_div = $('note-' + uid_of_note_being_colored);
530 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
532 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
534 note_div.style.backgroundColor = notecolor;
535 titlebar_div.style.backgroundColor = titlecolor;
536 palette_button.style.display = 'none';
538 // submit an ajax http call to record it to the server
539 p = 'note_uid=' + uid_of_note_being_colored
543 + '&r=' + CtdlRandomString();
556 // These functions handle resizing sticky notes by dragging the resize handle
558 var uid_of_note_being_resized = 0;
559 var saved_cursor_style = 'default';
560 var note_was_resized = 0;
562 function NotesResizeMouseUp(evt) {
563 document.onmouseup = null;
564 document.onmousemove = null;
565 if (document.layers) {
566 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
569 d = $('note-' + uid_of_note_being_resized);
570 d.style.cursor = saved_cursor_style;
572 // If any motion actually occurred, submit an ajax http call to record it to the server
573 if (note_was_resized > 0) {
574 p = 'note_uid=' + uid_of_note_being_resized
575 + '&width=' + d.style.width
576 + '&height=' + d.style.height
577 + '&r=' + CtdlRandomString();
587 uid_of_note_being_resized = '';
588 return false; // disable the default action
591 function NotesResizeMouseMove(evt) {
592 x = (ns6 ? evt.clientX : event.clientX);
593 x_increment = x - saved_x;
594 y = (ns6 ? evt.clientY : event.clientY);
595 y_increment = y - saved_y;
598 d = $('note-' + uid_of_note_being_resized);
600 divTop = parseInt(d.style.height);
601 divLeft = parseInt(d.style.width);
603 newHeight = divTop + y_increment;
604 if (newHeight < 50) newHeight = 50;
606 newWidth = divLeft + x_increment;
607 if (newWidth < 50) newWidth = 50;
609 d.style.height = newHeight + 'px';
610 d.style.width = newWidth + 'px';
614 note_was_resized = 1;
615 return false; // disable the default action
619 function NotesResizeMouseDown(evt, uid) {
620 saved_x = (ns6 ? evt.clientX : event.clientX);
621 saved_y = (ns6 ? evt.clientY : event.clientY);
622 document.onmouseup = NotesResizeMouseUp;
623 document.onmousemove = NotesResizeMouseMove;
624 if (document.layers) {
625 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
627 uid_of_note_being_resized = uid;
628 d = $('note-' + uid_of_note_being_resized);
629 saved_cursor_style = d.style.cursor;
630 d.style.cursor = 'move';
631 return false; // disable the default action
635 function DeleteStickyNote(evt, uid, confirmation_prompt) {
636 uid_of_note_being_deleted = uid;
637 d = $('note-' + uid_of_note_being_deleted);
639 if (confirm(confirmation_prompt)) {
642 // submit an ajax http call to delete it on the server
643 p = 'note_uid=' + uid_of_note_being_deleted
645 + '&r=' + CtdlRandomString();
656 function ctdl_ts_getInnerText(el) {
657 if (typeof el == "string") return el;
658 if (typeof el == "undefined") { return el };
659 if (el.innerText) return el.innerText; //Not needed but it is faster
662 var cs = el.childNodes;
664 for (var i = 0; i < l; i++) {
665 switch (cs[i].nodeType) {
666 case 1: //ELEMENT_NODE
667 str += ts_getInnerText(cs[i]);
670 str += cs[i].nodeValue;
678 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
679 function CtdlLoadScreen(elementid) {
680 var elem = document.getElementById(elementid);
681 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>";
686 // Pop open the address book (target_input is the INPUT field to populate)
688 function PopOpenAddressBook(target_input) {
689 $('address_book_popup').style.display = 'block';
690 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
692 'address_book_popup_middle_div',
693 'display_address_book_middle_div',
702 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
703 $('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>";
704 p = 'which_addr_book=' + which_addr_book
705 + '&target_input=' + target_input
706 + '&r=' + CtdlRandomString();
708 'address_book_inner_div',
709 'display_address_book_inner_div',
717 // What happens when a contact is selected from the address book popup
718 // (populate the specified target)
720 function AddContactsToTarget(target, whichaddr) {
721 while (whichaddr.selectedIndex != -1) {
722 if (target.value.length > 0) {
723 target.value = target.value + ', ';
725 target.value = target.value + whichaddr.value;
726 whichaddr.options[whichaddr.selectedIndex].selected = false;
730 // Respond to a meeting invitation
731 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
732 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
733 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
734 Effect.Fade(question_divname, { duration: 0.5 });
737 // Handle a received RSVP
738 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
739 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
740 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
741 Effect.Fade(question_divname, { duration: 0.5 });
743 /* var fakeMouse = document.createEvent("MouseEvents");
744 fakeMouse.initMouseEvent("click", true, true, window,
745 0,0,0,0,0, false, false, false, false, 0, null); */
746 // TODO: Collapse into one function
747 function toggleTaskDtStart(event) {
748 var checkBox = $('nodtstart');
749 var checkBoxTime = $('dtstart_time_assoc');
750 var dtstart = document.getElementById("dtstart");
751 var dtstart_date = document.getElementById("dtstart_date");
752 var dtstart_time = document.getElementById("dtstart_time");
753 if (checkBox.checked) {
754 dtstart_date.style.visibility = "hidden";
755 dtstart_time.style.visibility = "hidden";
757 if (checkBoxTime.checked) {
758 dtstart_time.style.visibility = "visible";
760 dtstart_time.style.visibility = "hidden";
762 dtstart_date.style.visibility = "visible";
763 if (dtstart.value.length == 0)
764 dtstart.dpck._initCurrentDate();
767 function toggleTaskDue(event) {
768 var checkBox = $('nodue');
769 var checkBoxTime = $('due_time_assoc');
770 var due = document.getElementById("due");
771 var due_date = document.getElementById("due_date");
772 var due_time = document.getElementById("due_time");
773 if (checkBox.checked) {
774 due_date.style.visibility = "hidden";
775 due_time.style.visibility = "hidden";
777 if (checkBoxTime.checked) {
778 due_time.style.visibility = "visible";
780 due_time.style.visibility = "hidden";
782 due_date.style.visibility = "visible";
783 if (due.value.length == 0)
784 due.dpck._initCurrentDate();
787 function ToggleTaskDateOrNoDateActivate(event) {
788 var dtstart = document.getElementById("nodtstart");
789 if (dtstart != null) {
790 toggleTaskDtStart(null);
792 $('nodtstart').observe('click', toggleTaskDtStart);
793 $('dtstart_time_assoc').observe('click', toggleTaskDtStart);
794 $('nodue').observe('click', toggleTaskDue);
795 $('due_time_assoc').observe('click', toggleTaskDue);
798 function TaskViewGatherCategoriesFromTable() {
799 var table = $('taskview');
802 function attachDatePicker(relative) {
803 var dpck = new DatePicker({
805 language: 'en', //wclang.substr(0,2),
806 disableFutureDate: false,
807 dateFormat: [ ["yyyy", "mm", "dd"], "-"],
810 document.getElementById(relative).dpck = dpck; // attach a ref to it
812 function eventEditAllDay() {
813 var allDayCheck = document.getElementById("alldayevent");
814 var dtend_time = document.getElementById("dtend_time");
815 var dtstart_time = document.getElementById("dtstart_time");
816 if(allDayCheck.checked) {
817 dtstart_time.style.visibility = "hidden";
818 dtend_time.style.visibility = "hidden";
820 dtstart_time.style.visibility = "visible";
821 dtend_time.style.visibility = "visible";
825 // Functions which handle show/hide of various elements in the recurrence editor
827 function RecurrenceShowHide() {
829 if ($('is_recur').checked) {
830 $('rrule_div').style.display = 'block';
833 $('rrule_div').style.display = 'none';
836 if ($('freq_selector').selectedIndex == 4) {
837 $('weekday_selector').style.display = 'block';
840 $('weekday_selector').style.display = 'none';
843 if ($('freq_selector').selectedIndex == 5) {
844 $('monthday_selector').style.display = 'block';
847 $('monthday_selector').style.display = 'none';
850 if ($('rrend_count').checked) {
851 $('rrcount').disabled = false;
854 $('rrcount').disabled = true;
857 if ($('rrend_until').checked) {
858 $('rruntil').disabled = false;
861 $('rruntil').disabled = true;
864 if ($('rrmonthtype_mday').checked) {
865 $('rrmday').disabled = false;
868 $('rrmday').disabled = true;
871 if ($('rrmonthtype_wday').checked) {
872 $('rrmweek').disabled = false;
873 $('rrmweekday').disabled = false;
876 $('rrmweek').disabled = true;
877 $('rrmweekday').disabled = true;
880 if ($('freq_selector').selectedIndex == 6) {
881 $('yearday_selector').style.display = 'block';
884 $('yearday_selector').style.display = 'none';
887 $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
888 $('rrmday').innerHTML = $('dtstart').value.substr(8);
890 if ($('rryeartype_ywday').checked) {
891 $('rrymweek').disabled = false;
892 $('rrymweekday').disabled = false;
893 $('rrymonth').disabled = false;
896 $('rrymweek').disabled = true;
897 $('rrymweekday').disabled = true;
898 $('rrymonth').disabled = true;
904 // Enable or disable the 'check attendee availability' button depending on whether
905 // the attendees list is empty
906 function EnableOrDisableCheckButton()
908 if ($('attendees_box').value.length == 0) {
909 $('check_button').disabled = true;
912 $('check_button').disabled = false;
919 function launchChat(event) {
920 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
923 function WCLog(msg) {
924 if (!!window.console && !!console.log) {
926 } else if (!!window.opera && !!opera.postError) {
927 opera.postError(msg);
929 wc_log += msg + "\r\n";
933 function RefreshSMTPqueueDisplay() {
934 new Ajax.Updater('smtpqueue_inner_div',
935 'display_smtpqueue_inner_div', { method: 'get',
936 parameters: Math.random() } );
939 function DeleteSMTPqueueMsg(msgnum1, msgnum2) {
940 var p = encodeURI('g_cmd=DELE ' + msgnum1 + ',' + msgnum2);
945 onComplete: RefreshSMTPqueueDisplay()
951 function ConfirmLogoff() {
954 'do_template?template=confirmlogoff',
958 onSuccess: function(cl_success) {
966 function switch_to_lang(new_lang) {
967 p = 'push?url=' + encodeURI(window.location);
968 new Ajax.Request(p, { method: 'get' } );
969 window.location = 'switch_language?lang=' + new_lang ;
973 function toggle_roomlist()
975 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
976 if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) {
977 $('roomlist').style.display = 'none';
978 $('expand_roomlist').src = 'static/webcit_icons/expand.gif';
983 $('roomlist').style.display = 'block';
984 $('expand_roomlist').src = 'static/webcit_icons/collapse.gif';
985 $('roomlist').innerHTML = '';
986 FillRooms(IconBarRoomList);
990 // tell the server what I did
991 p = 'toggle_roomlist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
992 new Ajax.Request(p, { method: 'get' } );
994 return false; /* this prevents the click from registering as a roomlist button press */
998 function toggle_wholist()
1000 /* WARNING: VILE, SLEAZY HACK. We determine the state of the box based on the image loaded. */
1001 if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
1002 $('online_users').style.display = 'none';
1003 $('expand_wholist').src = 'static/webcit_icons/expand.gif';
1008 $('online_users').style.display = 'block';
1009 $('expand_wholist').src = 'static/webcit_icons/collapse.gif';
1010 activate_iconbar_wholist_populat0r();
1014 // tell the server what I did
1015 p = 'toggle_wholist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
1016 new Ajax.Request(p, { method: 'get' } );
1018 return false; /* this prevents the click from registering as a wholist button press */