4 // JavaScript function library for WebCit.
10 var room_is_trash = 0;
12 if (document.layers) {
18 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
22 var ns6=document.getElementById&&!document.all;
23 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
24 Event.observe(window, 'load', taskViewActivate);
25 function CtdlRandomString() {
26 return((Math.random()+'').substr(3));
31 // We love string tokenizers.
32 function extract_token(source_string, token_num, delimiter) {
34 var extracted_string = source_string;
37 for (i=0; i<token_num; ++i) {
38 var j = extracted_string.indexOf(delimiter);
40 extracted_string = extracted_string.substr(j+1);
45 j = extracted_string.indexOf(delimiter);
47 extracted_string = extracted_string.substr(0, j);
50 return extracted_string;
55 // This code handles the popups for important-messages.
56 function hide_imsg_popup() {
57 if (browserType == "gecko") {
58 document.poppedLayer = eval('document.getElementById(\'important_message\')');
60 else if (browserType == "ie") {
61 document.poppedLayer = eval('document.all[\'important_message\']');
64 document.poppedLayer = eval('document.layers[\'`important_message\']');
67 document.poppedLayer.style.visibility = "hidden";
71 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
72 function activate_entmsg_autocompleters() {
73 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
74 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
75 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
80 // Toggle the icon bar between menu/roomlist...
81 var which_div_expanded = null;
82 var num_drop_targets = 0;
83 var drop_targets_elements = new Array();
84 var drop_targets_roomnames = new Array();
86 function switch_to_room_list() {
87 $('iconbar').innerHTML = $('iconbar').innerHTML.substr(0, $('iconbar').innerHTML.indexOf('switch'));
88 CtdlLoadScreen('iconbar');
89 new Ajax.Updater('iconbar', 'iconbar_ajax_rooms', { method: 'get' } );
92 function expand_floor(floor_div) {
93 if (which_div_expanded != null) {
94 if ($(which_div_expanded) != null) {
95 $(which_div_expanded).style.display = 'none' ;
99 // clicking on the already-expanded floor causes the whole list to collapse
100 if (which_div_expanded == floor_div) {
101 which_div_expanded = null;
103 // notify the server that no floors are expanded
105 'set_floordiv_expanded/-1', {
112 // expand the requested floor
113 $(floor_div).style.display = 'block';
114 which_div_expanded = floor_div;
116 // notify the server of which floor is expanded
118 'set_floordiv_expanded/'+floor_div, {
124 function switch_to_menu_buttons() {
125 which_div_expanded = null;
126 num_drop_targets = 0;
127 CtdlLoadScreen('iconbar');
128 new Ajax.Updater('iconbar', 'iconbar_ajax_menu', { method: 'get' } );
132 // Static variables for mailbox view...
134 var CtdlNumMsgsSelected = 0;
135 var CtdlMsgsSelected = new Array();
136 var CtdlLastMsgnumSelected = 0;
138 // This gets called when you single click on a message in the mailbox view.
139 // We know that the element id of the table row will be the letter 'm' plus the message number.
141 function CtdlSingleClickMsg(evt, msgnum) {
143 // Clear the preview pane until we load the new message
144 $('preview_pane').innerHTML = '';
146 // De-select any messages that were already selected, *unless* the Ctrl or
147 // Shift key is being pressed, in which case the user wants multi select
149 if ( (!evt.ctrlKey) && (!evt.shiftKey) ) {
150 if (CtdlNumMsgsSelected > 0) {
151 for (i=0; i<CtdlNumMsgsSelected; ++i) {
152 $('m'+CtdlMsgsSelected[i]).style.backgroundColor = '#fff';
153 $('m'+CtdlMsgsSelected[i]).style.color = '#000';
155 CtdlNumMsgsSelected = 0;
159 // For multi select ... is the message being clicked already selected?
160 already_selected = 0;
161 if ( (evt.ctrlKey) && (CtdlNumMsgsSelected > 0) ) {
162 for (i=0; i<CtdlNumMsgsSelected; ++i) {
163 if (CtdlMsgsSelected[i] == msgnum) {
164 already_selected = 1;
165 already_selected_pos = i;
170 // Now select (or de-select) the message
171 if ( (evt.ctrlKey) && (already_selected == 1) ) {
173 // Deselect: first un-highlight it...
174 $('m'+msgnum).style.backgroundColor = '#fff';
175 $('m'+msgnum).style.color = '#000';
177 // Then remove it from the selected messages list.
178 for (i=already_selected_pos; i<(CtdlNumMsgsSelected-1); ++i) {
179 CtdlMsgsSelected[i] = CtdlMsgsSelected[i+1];
181 CtdlNumMsgsSelected = CtdlNumMsgsSelected - 1;
185 else if (evt.shiftKey) {
187 // Group select: first clear everything out...
188 if (CtdlNumMsgsSelected > 0) {
189 for (i=0; i<CtdlNumMsgsSelected; ++i) {
190 $('m'+CtdlMsgsSelected[i]).style.backgroundColor = '#fff';
191 $('m'+CtdlMsgsSelected[i]).style.color = '#000';
194 CtdlNumMsgsSelected = 0;
196 // Then highlight and select the group.
197 // Traverse the table looking for a row whose ID contains the desired msgnum
199 var in_the_group = 0;
201 var table = $('summary_headers');
203 for (var r = 0; r < table.rows.length; r++) {
204 var thename = table.rows[r].id;
205 if ( (thename.substr(1) == msgnum) || (thename.substr(1) == CtdlLastMsgnumSelected) ) {
206 in_the_group = 1 - in_the_group;
212 if ( (in_the_group == 1) || (is_edge == 1) ) {
214 table.rows[r].style.backgroundColor='#69aaff';
215 table.rows[r].style.color='#fff';
217 // And add it to the selected messages list.
218 CtdlNumMsgsSelected = CtdlNumMsgsSelected + 1;
219 CtdlMsgsSelected[CtdlNumMsgsSelected-1] = thename.substr(1);
226 // Select: first highlight it...
227 $('m'+msgnum).style.backgroundColor='#69aaff';
228 $('m'+msgnum).style.color='#fff';
230 // Then add it to the selected messages list.
231 CtdlNumMsgsSelected = CtdlNumMsgsSelected + 1;
232 CtdlMsgsSelected[CtdlNumMsgsSelected-1] = msgnum;
235 CtdlLoadScreen('preview_pane');
236 // Update the preview pane
237 new Ajax.Updater('preview_pane', 'msg/'+msgnum, { method: 'get' } );
239 // Mark the message as read
243 parameters: 'g_cmd=SEEN '+msgnum+'|1',
244 onComplete: CtdlRemoveTheUnseenBold(msgnum)
249 // Save the selected position in case the user does a group select next time.
250 CtdlLastMsgnumSelected = msgnum;
252 return false; // try to defeat the default click behavior
255 // Delete selected messages.
256 function CtdlDeleteSelectedMessages(evt) {
258 if (CtdlNumMsgsSelected < 1) {
259 // Nothing to delete, so exit silently.
262 for (i=0; i<CtdlNumMsgsSelected; ++i) {
263 if (parseInt(room_is_trash) > 0) {
267 parameters: 'g_cmd=DELE ' + CtdlMsgsSelected[i],
268 onComplete: CtdlClearDeletedMsg(CtdlMsgsSelected[i])
276 parameters: 'g_cmd=MOVE ' + CtdlMsgsSelected[i] + '|_TRASH_|0',
277 onComplete: CtdlClearDeletedMsg(CtdlMsgsSelected[i])
282 CtdlNumMsgsSelected = 0;
284 // Clear the preview pane too.
285 $('preview_pane').innerHTML = '';
289 // Move selected messages.
290 function CtdlMoveSelectedMessages(evt, target_roomname) {
292 if (CtdlNumMsgsSelected < 1) {
293 // Nothing to delete, so exit silently.
296 for (i=0; i<CtdlNumMsgsSelected; ++i) {
300 parameters:'g_cmd=MOVE ' + CtdlMsgsSelected[i] + '|' + target_roomname + '|0',
301 onComplete:CtdlClearDeletedMsg(CtdlMsgsSelected[i])
305 CtdlNumMsgsSelected = 0;
307 // Clear the preview pane too.
308 $('preview_pane').innerHTML = '';
313 // This gets called when the user touches the keyboard after selecting messages...
314 function CtdlMsgListKeyPress(evt) {
315 if(document.all) { // aIEeee
316 var whichKey = window.event.keyCode;
318 else { // non-sux0r browsers
319 var whichKey = evt.which;
321 if (whichKey == 46) { // DELETE key
322 CtdlDeleteSelectedMessages(evt);
327 // Take the boldface away from a message to indicate that it has been seen.
328 function CtdlRemoveTheUnseenBold(msgnum) {
329 $('m'+msgnum).style.fontWeight='normal';
332 // A message has been deleted, so yank it from the list.
333 function CtdlClearDeletedMsg(msgnum) {
336 // Traverse the table looking for a row whose ID contains the desired msgnum
337 var table = $('summary_headers');
339 for (var r = 0; r < table.rows.length; r++) {
340 var thename = table.rows[r].id;
341 if (thename.substr(1) == msgnum) {
346 alert('error: browser failed to clear row ' + r);
351 else { // if we can't delete it,
352 new Effect.Squish('m'+msgnum); // just hide it.
358 // These functions called when the user down-clicks on the message list resizer bar
363 function CtdlResizeMsgListMouseUp(evt) {
364 document.onmouseup = null;
365 document.onmousemove = null;
366 if (document.layers) {
367 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
372 function CtdlResizeMsgListMouseMove(evt) {
373 y = (ns6 ? evt.clientY : event.clientY);
374 increment = y - saved_y;
376 // First move the bottom of the message list...
377 d = $('message_list');
379 divHeight = d.offsetHeight;
381 else if (d.style.pixelHeight) {
382 divHeight = d.style.pixelHeight;
384 d.style.height = (divHeight + increment) + 'px';
386 // Then move the top of the preview pane...
387 d = $('preview_pane');
389 divTop = d.offsetTop;
391 else if (d.style.pixelTop) {
392 divTop = d.style.pixelTop;
394 d.style.top = (divTop + increment) + 'px';
396 // Resize the bottom of the preview pane...
397 d = $('preview_pane');
399 divHeight = d.offsetHeight;
401 else if (d.style.pixelHeight) {
402 divHeight = d.style.pixelHeight;
404 d.style.height = (divHeight - increment) + 'px';
406 // Then move the top of the slider bar.
407 d = $('resize_msglist');
409 divTop = d.offsetTop;
411 else if (d.style.pixelTop) {
412 divTop = d.style.pixelTop;
414 d.style.top = (divTop + increment) + 'px';
420 function CtdlResizeMsgListMouseDown(evt) {
421 saved_y = (ns6 ? evt.clientY : event.clientY);
422 document.onmouseup = CtdlResizeMsgListMouseUp;
423 document.onmousemove = CtdlResizeMsgListMouseMove;
424 if (document.layers) {
425 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
427 return false; // disable the default action
434 // These functions handle moving sticky notes around the screen by dragging them
436 var uid_of_note_being_dragged = 0;
437 var saved_cursor_style = 'default';
438 var note_was_dragged = 0;
440 function NotesDragMouseUp(evt) {
441 document.onmouseup = null;
442 document.onmousemove = null;
443 if (document.layers) {
444 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
447 d = $('note-' + uid_of_note_being_dragged);
448 d.style.cursor = saved_cursor_style;
450 // If any motion actually occurred, submit an ajax http call to record it to the server
451 if (note_was_dragged > 0) {
452 p = 'note_uid=' + uid_of_note_being_dragged
453 + '&left=' + d.style.left
454 + '&top=' + d.style.top
455 + '&r=' + CtdlRandomString();
465 uid_of_note_being_dragged = '';
469 function NotesDragMouseMove(evt) {
470 x = (ns6 ? evt.clientX : event.clientX);
471 x_increment = x - saved_x;
472 y = (ns6 ? evt.clientY : event.clientY);
473 y_increment = y - saved_y;
476 d = $('note-' + uid_of_note_being_dragged);
478 divTop = parseInt(d.style.top);
479 divLeft = parseInt(d.style.left);
481 d.style.top = (divTop + y_increment) + 'px';
482 d.style.left = (divLeft + x_increment) + 'px';
486 note_was_dragged = 1;
491 function NotesDragMouseDown(evt, uid) {
492 saved_x = (ns6 ? evt.clientX : event.clientX);
493 saved_y = (ns6 ? evt.clientY : event.clientY);
494 document.onmouseup = NotesDragMouseUp;
495 document.onmousemove = NotesDragMouseMove;
496 if (document.layers) {
497 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
499 uid_of_note_being_dragged = uid;
500 d = $('note-' + uid_of_note_being_dragged);
501 saved_cursor_style = d.style.cursor;
502 d.style.cursor = 'move';
503 return false; // disable the default action
507 // Called when the user clicks on the palette icon of a sticky note to change its color.
508 // It toggles the color selector visible or invisible.
510 function NotesClickPalette(evt, uid) {
511 uid_of_note_being_colored = uid;
512 d = $('palette-' + uid_of_note_being_colored);
514 if (d.style.display) {
515 if (d.style.display == 'none') {
516 d.style.display = 'block';
519 d.style.display = 'none';
523 d.style.display = 'block';
530 // Called when the user clicks on one of the colors in an open color selector.
531 // Sets the desired color and then closes the color selector.
533 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
534 uid_of_note_being_colored = uid;
535 palette_button = $('palette-' + uid_of_note_being_colored);
536 note_div = $('note-' + uid_of_note_being_colored);
537 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
539 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
541 note_div.style.backgroundColor = notecolor;
542 titlebar_div.style.backgroundColor = titlecolor;
543 palette_button.style.display = 'none';
545 // submit an ajax http call to record it to the server
546 p = 'note_uid=' + uid_of_note_being_colored
550 + '&r=' + CtdlRandomString();
563 // These functions handle resizing sticky notes by dragging the resize handle
565 var uid_of_note_being_resized = 0;
566 var saved_cursor_style = 'default';
567 var note_was_resized = 0;
569 function NotesResizeMouseUp(evt) {
570 document.onmouseup = null;
571 document.onmousemove = null;
572 if (document.layers) {
573 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
576 d = $('note-' + uid_of_note_being_resized);
577 d.style.cursor = saved_cursor_style;
579 // If any motion actually occurred, submit an ajax http call to record it to the server
580 if (note_was_resized > 0) {
581 p = 'note_uid=' + uid_of_note_being_resized
582 + '&width=' + d.style.width
583 + '&height=' + d.style.height
584 + '&r=' + CtdlRandomString();
594 uid_of_note_being_resized = '';
595 return false; // disable the default action
598 function NotesResizeMouseMove(evt) {
599 x = (ns6 ? evt.clientX : event.clientX);
600 x_increment = x - saved_x;
601 y = (ns6 ? evt.clientY : event.clientY);
602 y_increment = y - saved_y;
605 d = $('note-' + uid_of_note_being_resized);
607 divTop = parseInt(d.style.height);
608 divLeft = parseInt(d.style.width);
610 d.style.height = (divTop + y_increment) + 'px';
611 d.style.width = (divLeft + x_increment) + 'px';
615 note_was_resized = 1;
616 return false; // disable the default action
620 function NotesResizeMouseDown(evt, uid) {
621 saved_x = (ns6 ? evt.clientX : event.clientX);
622 saved_y = (ns6 ? evt.clientY : event.clientY);
623 document.onmouseup = NotesResizeMouseUp;
624 document.onmousemove = NotesResizeMouseMove;
625 if (document.layers) {
626 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
628 uid_of_note_being_resized = uid;
629 d = $('note-' + uid_of_note_being_resized);
630 saved_cursor_style = d.style.cursor;
631 d.style.cursor = 'move';
632 return false; // disable the default action
636 function DeleteStickyNote(evt, uid, confirmation_prompt) {
637 uid_of_note_being_deleted = uid;
638 d = $('note-' + uid_of_note_being_deleted);
640 if (confirm(confirmation_prompt)) {
643 // submit an ajax http call to delete it on the server
644 p = 'note_uid=' + uid_of_note_being_deleted
646 + '&r=' + CtdlRandomString();
671 // These functions handle drag and drop message moving
675 function CtdlMoveMsgMouseDown(evt, msgnum) {
677 // do the highlight first
678 CtdlSingleClickMsg(evt, msgnum);
680 // Now handle the possibility of dragging
681 saved_x = (ns6 ? evt.clientX : event.clientX);
682 saved_y = (ns6 ? evt.clientY : event.clientY);
683 document.onmouseup = CtdlMoveMsgMouseUp;
684 document.onmousemove = CtdlMoveMsgMouseMove;
685 if (document.layers) {
686 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
692 function CtdlMoveMsgMouseMove(evt) {
693 x = (ns6 ? evt.clientX : event.clientX);
694 y = (ns6 ? evt.clientY : event.clientY);
696 if ( (x == saved_x) && (y == saved_y) ) {
700 if (CtdlNumMsgsSelected < 1) {
707 drag_o_text = "<div style=\"overflow:none; background-color:#fff; color:#000; border: 1px solid black; filter:alpha(opacity=75); -moz-opacity:.75; opacity:.75;\"><tr><td>";
708 for (i=0; i<CtdlNumMsgsSelected; ++i) {
709 drag_o_text = drag_o_text +
710 ctdl_ts_getInnerText(
711 $('m'+CtdlMsgsSelected[i]).cells[0]
714 drag_o_text = drag_o_text + "<div>";
716 mm_div = document.createElement("DIV");
717 mm_div.style.position='absolute';
718 mm_div.style.top = y + 'px';
719 mm_div.style.left = x + 'px';
720 mm_div.style.pixelHeight = '300';
721 mm_div.style.pixelWidth = '300';
722 mm_div.innerHTML = drag_o_text;
723 document.body.appendChild(mm_div);
726 mm_div.style.top = y + 'px';
727 mm_div.style.left = x + 'px';
730 return false; // prevent the default mouse action from happening?
733 function CtdlMoveMsgMouseUp(evt) {
734 document.onmouseup = null;
735 document.onmousemove = null;
736 if (document.layers) {
737 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
741 document.body.removeChild(mm_div);
745 if (num_drop_targets < 1) { // nowhere to drop
749 // Did we release the mouse button while hovering over a drop target?
750 // NOTE: this only works cross-browser because the iconbar div is always
751 // positioned at 0,0. Browsers differ in whether the 'offset'
752 // functions return pos relative to the document or parent.
754 for (i=0; i<num_drop_targets; ++i) {
756 x = (ns6 ? evt.clientX : event.clientX);
757 y = (ns6 ? evt.clientY : event.clientY);
759 l = parseInt(drop_targets_elements[i].offsetLeft);
760 t = parseInt(drop_targets_elements[i].offsetTop);
761 r = parseInt(drop_targets_elements[i].offsetLeft)
762 + parseInt(drop_targets_elements[i].offsetWidth);
763 b = parseInt(drop_targets_elements[i].offsetTop)
764 + parseInt(drop_targets_elements[i].offsetHeight);
766 /* alert('Offsets are: ' + l + ' ' + t + ' ' + r + ' ' + b + '.'); */
768 if ( (x >= l) && (x <= r) && (y >= t) && (y <= b) ) {
769 // Yes, we dropped it on a hotspot.
770 CtdlMoveSelectedMessages(evt, drop_targets_roomnames[i]);
779 function ctdl_ts_getInnerText(el) {
780 if (typeof el == "string") return el;
781 if (typeof el == "undefined") { return el };
782 if (el.innerText) return el.innerText; //Not needed but it is faster
785 var cs = el.childNodes;
787 for (var i = 0; i < l; i++) {
788 switch (cs[i].nodeType) {
789 case 1: //ELEMENT_NODE
790 str += ts_getInnerText(cs[i]);
793 str += cs[i].nodeValue;
801 function CtdlShowRaw(msgnum) {
802 var customnav = document.createElement("span");
803 var mode_citadel = document.createElement("a");
804 mode_citadel.appendChild(document.createTextNode("Citadel Source"));
805 var mode_rfc822 = document.createElement("a");
806 mode_rfc822.appendChild(document.createTextNode(" RFC822 Source"));
807 mode_citadel.setAttribute("href","#");
808 mode_rfc822.setAttribute("href","#");
809 mode_rfc822.setAttribute("onclick","rawSwitch822('" + msgnum + "');");
810 mode_citadel.setAttribute("onclick","rawSwitchCitadel('" + msgnum + "');");
811 customnav.appendChild(mode_citadel);
812 customnav.appendChild(mode_rfc822);
813 customnav.setAttribute("class","floatcustomnav");
814 floatwindow("headerscreen","pre",customnav);
815 rawSwitch822(msgnum);
818 function rawSwitch822(msgnum) {
819 CtdlLoadScreen("headerscreen");
820 new Ajax.Updater("headerscreen",
822 { method: 'post',parameters: 'g_cmd=MSG2 ' +msgnum } );
826 function rawSwitchCitadel(msgnum) {
827 CtdlLoadScreen("headerscreen");
828 new Ajax.Updater("headerscreen",
830 { method: 'post',parameters: 'g_cmd=MSG0 ' +msgnum } );
834 function floatwindow(newdivid,contentelementtype,customnav) {
835 var windiv = document.createElement("div");
836 windiv.setAttribute("class","floatwindow");
837 var winid = newdivid+"_window";
838 windiv.setAttribute("id",winid);
839 var nav = document.createElement("div");
840 if (customnav != null) {
841 nav.appendChild(customnav);
843 var minimizeA = document.createElement("a");
844 var minimizeButton = document.createTextNode("Close");
845 minimizeA.appendChild(minimizeButton);
846 minimizeA.setAttribute("onclick","killFloatWindow(this);");
847 minimizeA.setAttribute("href","#");
848 nav.appendChild(minimizeA);
849 nav.setAttribute("class","floatnav");
850 windiv.appendChild(nav);
851 var contentarea = document.createElement("pre");
852 contentarea.setAttribute("class","floatcontent");
853 contentarea.setAttribute("id",newdivid);
854 windiv.appendChild(contentarea);
855 document.body.appendChild(windiv);
857 function killFloatWindow(caller) {
858 var span = caller.parentNode;
859 var fwindow = span.parentNode;
860 fwindow.parentNode.removeChild(fwindow);
862 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
863 function CtdlLoadScreen(elementid) {
864 var elem = document.getElementById(elementid);
865 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>";
870 // Pop open the address book (target_input is the INPUT field to populate)
872 function PopOpenAddressBook(target_input) {
873 $('address_book_popup').style.display = 'block';
874 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
876 'address_book_popup_middle_div',
877 'display_address_book_middle_div',
886 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
887 $('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>";
888 p = 'which_addr_book=' + which_addr_book
889 + '&target_input=' + target_input
890 + '&r=' + CtdlRandomString();
892 'address_book_inner_div',
893 'display_address_book_inner_div',
901 // What happens when a contact is selected from the address book popup
902 // (populate the specified target)
904 function AddContactsToTarget(target, whichaddr) {
905 while (whichaddr.selectedIndex != -1) {
906 if (target.value.length > 0) {
907 target.value = target.value + ', ';
909 target.value = target.value + whichaddr.value;
910 whichaddr.options[whichaddr.selectedIndex].selected = false;
914 // Respond to a meeting invitation
915 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
916 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
917 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
918 Effect.Fade(question_divname, { duration: 0.5 });
921 // Handle a received RSVP
922 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
923 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
924 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
925 Effect.Fade(question_divname, { duration: 0.5 });
927 var fakeMouse = document.createEvent("MouseEvents");
928 fakeMouse.initMouseEvent("click", true, true, window,
929 0,0,0,0,0, false, false, false, false, 0, null);
930 // TODO: Collapse into one function
931 function toggleTaskDtStart(event) {
932 var checkBox = $('nodtstart');
933 dtStart = document.getElementById("dtstart");
934 if (checkBox.checked) {
935 dtStart.disabled = true;
936 dtStart.style.textDecoration = "line-through";
938 dtStart.disabled = false;
939 dtStart.style.textDecoration = "";
940 if (dtStart.value.length == 0)
941 dtStart.dpck._initCurrentDate();
944 function toggleTaskDue(event) {
945 var checkBox = $('nodue');
946 dueField = document.getElementById("due");
947 if (checkBox.checked) {
948 dueField.disabled = true;
949 dueField.style.textDecoration = "line-through";
951 dueField.disabled = false;
952 dueField.style.textDecoration = "";
953 if (dueField.value.length == 0)
954 dueField.dpck._initCurrentDate();
957 function ToggleTaskDateOrNoDateActivate(event) {
958 var dtstart = document.getElementById("nodtstart");
959 if (dtstart != null) {
960 toggleTaskDtStart(null);
962 $('nodtstart').observe('click', toggleTaskDtStart);
963 $('nodue').observe('click', toggleTaskDue);
966 function TaskViewGatherCategoriesFromTable() {
967 var table = $('taskview');
970 function attachDatePicker(relative) {
971 var dpck = new DatePicker({
973 language: 'en', // fix please
974 disableFutureDate: false
976 document.getElementById(relative).dpck = dpck; // attach a ref to it
978 function eventEditAllDay() {
979 var allDayCheck = document.getElementById("alldayevent");
980 var dtend= document.getElementById("dtendcell");
981 if(allDayCheck.checked) {
982 //dtend.disabled = true;
983 dtend.style.textDecoration = "line-through";
985 //dtend_day.disabled = false;
986 dtend.style.textDecoration = "";