3 var listFilter = 'view_today';
5 var listOfSelection = null;
6 var selectedCalendarCell;
8 var hideCompletedTasks = 0;
11 var currentView = "dayview";
13 var cachedDateSelectors = new Array();
15 var contactSelectorAction = 'calendars-contacts';
17 var eventsToDelete = new Array();
18 var ownersOfEventsToDelete = new Array();
20 function newEvent(sender, type) {
21 var day = sender.getAttribute("day");
26 if (sender.parentNode.getAttribute("id") != "toolbar"
27 && currentView == "multicolumndayview" && type == "event")
28 user = sender.parentNode.parentNode.getAttribute("user");
30 var hour = sender.getAttribute("hour");
31 var urlstr = UserFolderURL + "../" + user + "/Calendar/new" + type;
32 var params = new Array();
34 params.push("day=" + day);
36 params.push("hm=" + hour);
37 if (params.length > 0)
38 urlstr += "?" + params.join("&");
40 window.open(urlstr, "", "width=620,height=600,resizable=0");
42 return false; /* stop following the link */
45 function _editEventId(id, owner) {
48 urlBase = UserFolderURL + "../" + owner + "/";
49 urlBase += "Calendar/"
51 var urlstr = urlBase + id + "/edit";
53 var win = window.open(urlstr, "SOGo_edit_" + id,
54 "width=620,height=600,resizable=0,scrollbars=0,toolbar=0," +
55 "location=0,directories=0,status=0,menubar=0,copyhistory=0");
59 function editEvent() {
60 if (listOfSelection) {
61 var nodes = listOfSelection.getSelectedRows();
63 for (var i = 0; i < nodes.length; i++)
64 _editEventId(nodes[i].getAttribute("id"),
65 nodes[i].getAttribute("owner"));
66 } else if (selectedCalendarCell) {
67 _editEventId(selectedCalendarCell.getAttribute("aptCName"),
68 selectedCalendarCell.getAttribute("owner"));
71 return false; /* stop following the link */
74 function _batchDeleteEvents() {
75 var events = eventsToDelete.shift();
76 var owner = ownersOfEventsToDelete.shift();
77 var urlstr = (UserFolderURL + "../" + owner + "/Calendar/batchDelete?ids="
79 document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
84 function deleteEvent()
86 if (listOfSelection) {
87 var nodes = listOfSelection.getSelectedRows();
89 if (nodes.length > 0) {
91 if (listOfSelection == $("tasksList"))
92 label = labels["taskDeleteConfirmation"].decodeEntities();
94 label = labels["appointmentDeleteConfirmation"].decodeEntities();
97 if (document.deleteEventAjaxRequest) {
98 document.deleteEventAjaxRequest.aborted = true;
99 document.deleteEventAjaxRequest.abort();
101 var sortedNodes = new Array();
102 var owners = new Array();
104 for (var i = 0; i < nodes.length; i++) {
105 var owner = nodes[i].getAttribute("owner");
106 if (!sortedNodes[owner]) {
107 sortedNodes[owner] = new Array();
110 sortedNodes[owner].push(nodes[i].getAttribute("id"));
112 for (var i = 0; i < owners.length; i++) {
113 ownersOfEventsToDelete.push(owners[i]);
114 eventsToDelete.push(sortedNodes[owners[i]]);
116 _batchDeleteEvents();
120 else if (selectedCalendarCell) {
121 var label = labels["appointmentDeleteConfirmation"].decodeEntities();
122 if (confirm(label)) {
123 if (document.deleteEventAjaxRequest) {
124 document.deleteEventAjaxRequest.aborted = true;
125 document.deleteEventAjaxRequest.abort();
127 eventsToDelete.push([selectedCalendarCell.getAttribute("aptCName")]);
128 ownersOfEventsToDelete.push(selectedCalendarCell.getAttribute("owner"));
129 _batchDeleteEvents();
133 window.alert("no selection");
138 function modifyEvent(sender, modification) {
139 var currentLocation = '' + window.location;
140 var arr = currentLocation.split("/");
141 arr[arr.length-1] = modification;
143 document.modifyEventAjaxRequest = triggerAjaxRequest(arr.join("/"),
150 function closeInvitationWindow() {
151 var closeDiv = document.createElement("div");
152 closeDiv.addClassName("javascriptPopupBackground");
153 var closePseudoWin = document.createElement("div");
154 closePseudoWin.addClassName("javascriptMessagePseudoWindow");
155 closePseudoWin.style.top = "0px;";
156 closePseudoWin.style.left = "0px;";
157 closePseudoWin.style.right = "0px;";
158 closePseudoWin.appendChild(document.createTextNode(labels["closeThisWindowMessage"].decodeEntities()));
159 document.body.appendChild(closeDiv);
160 document.body.appendChild(closePseudoWin);
163 function modifyEventCallback(http) {
164 if (http.readyState == 4) {
165 if (http.status == 200) {
166 log("closing window...?");
167 if (queryParameters["mail-invitation"] == "yes")
168 closeInvitationWindow();
170 window.opener.setTimeout("refreshAppointmentsAndDisplay();", 100);
171 window.setTimeout("window.close();", 100);
175 log("showing alert...");
176 window.alert(labels["eventPartStatModificationError"]);
178 document.modifyEventAjaxRequest = null;
182 function deleteEventCallback(http)
184 if (http.readyState == 4
185 && http.status == 200) {
186 var nodes = http.callbackData;
187 for (var i = 0; i < nodes.length; i++) {
188 var node = $(nodes[i]);
190 node.parentNode.removeChild(node);
192 if (eventsToDelete.length)
193 _batchDeleteEvents();
195 document.deleteEventAjaxRequest = null;
196 refreshAppointments();
198 changeCalendarDisplay();
202 log ("ajax fuckage");
205 function editDoubleClickedEvent(node)
207 _editEventId(node.getAttribute("id"),
208 node.getAttribute("owner"));
213 function onSelectAll() {
214 var list = $("appointmentsList");
215 list.selectRowsMatchingClass("appointmentRow");
220 function displayAppointment(event) {
221 _editEventId(this.getAttribute("aptCName"),
222 this.getAttribute("owner"));
224 event.preventDefault();
225 event.stopPropagation();
226 event.cancelBubble = true;
227 event.returnValue = false;
230 function onDaySelect(node)
232 var day = node.getAttribute("day");
233 var needRefresh = (listFilter == 'view_selectedday'
234 && day != currentDay);
236 var td = node.getParentWithTagName("td");
237 var table = td.getParentWithTagName("table");
239 // log ("table.selected: " + table.selected);
241 if (document.selectedDate)
242 document.selectedDate.deselect();
245 document.selectedDate = td;
247 changeCalendarDisplay( { "day": day } );
249 refreshAppointments();
254 function onDateSelectorGotoMonth(node)
256 var day = node.getAttribute("date");
258 changeDateSelectorDisplay(day, true);
263 function onCalendarGotoDay(node)
265 var day = node.getAttribute("date");
267 changeDateSelectorDisplay(day);
268 changeCalendarDisplay( { "day": day } );
275 changeDateSelectorDisplay('');
276 changeCalendarDisplay();
281 function setDateSelectorContent(content)
283 var div = $("dateSelectorView");
285 div.innerHTML = content;
286 if (currentDay.length > 0)
287 restoreCurrentDaySelection(div);
290 function dateSelectorCallback(http)
292 if (http.readyState == 4
293 && http.status == 200) {
294 document.dateSelectorAjaxRequest = null;
295 var content = http.responseText;
296 setDateSelectorContent(content);
297 cachedDateSelectors[http.callbackData] = content;
300 log ("ajax fuckage");
303 function appointmentsListCallback(http)
305 var div = $("appointmentsListView");
307 if (http.readyState == 4
308 && http.status == 200) {
309 document.appointmentsListAjaxRequest = null;
310 div.innerHTML = http.responseText;
311 var params = parseQueryParameters(http.callbackData);
312 sortKey = params["sort"];
313 sortOrder = params["desc"];
314 var list = $("appointmentsList");
315 list.addEventListener("selectionchange",
316 onAppointmentsSelectionChange, true);
317 configureSortableTableHeaders();
320 log ("ajax fuckage");
323 function tasksListCallback(http)
325 var div = $("tasksListView");
327 if (http.readyState == 4
328 && http.status == 200) {
329 document.tasksListAjaxRequest = null;
330 var list = $("tasksList");
331 var scroll = list.scrollTop;
332 div.innerHTML = http.responseText;
333 list = $("tasksList");
334 list.addEventListener("selectionchange",
335 onTasksSelectionChange, true);
336 list.scrollTop = scroll;
337 if (http.callbackData) {
338 var selectedNodesId = http.callbackData;
339 for (var i = 0; i < selectedNodesId.length; i++)
340 $(selectedNodesId[i]).select();
344 log ("ajax fuckage");
347 function restoreCurrentDaySelection(div)
349 var elements = div.getElementsByTagName("a");
352 while (!day && i < elements.length)
354 day = elements[i].getAttribute("day");
359 && day.substr(0, 6) == currentDay.substr(0, 6)) {
360 for (i = 0; i < elements.length; i++) {
361 day = elements[i].getAttribute("day");
362 if (day && day == currentDay) {
363 var td = elements[i].getParentWithTagName("td");
364 if (document.selectedDate)
365 document.selectedDate.deselect();
367 document.selectedDate = td;
373 function changeDateSelectorDisplay(day, keepCurrentDay)
375 var url = ApplicationBaseURL + "dateselector";
377 url += "?day=" + day;
379 if (day != currentDay) {
384 var month = day.substr(0, 6);
385 if (cachedDateSelectors[month]) {
386 // log ("restoring cached selector for month: " + month);
387 setDateSelectorContent(cachedDateSelectors[month]);
390 // log ("loading selector for month: " + month);
391 if (document.dateSelectorAjaxRequest) {
392 document.dateSelectorAjaxRequest.aborted = true;
393 document.dateSelectorAjaxRequest.abort();
395 document.dateSelectorAjaxRequest
396 = triggerAjaxRequest(url,
397 dateSelectorCallback,
403 function changeCalendarDisplay(time, newView)
405 var url = ApplicationBaseURL + ((newView) ? newView : currentView);
407 selectedCalendarCell = null;
419 url += "?day=" + day;
422 // log ("switching to view: " + newView);
423 // log ("changeCalendarDisplay: " + url);
425 if (document.dayDisplayAjaxRequest) {
426 // log ("aborting day ajaxrq");
427 document.dayDisplayAjaxRequest.aborted = true;
428 document.dayDisplayAjaxRequest.abort();
430 document.dayDisplayAjaxRequest = triggerAjaxRequest(url,
431 calendarDisplayCallback,
439 function _ensureView(view) {
440 if (currentView != view)
441 changeCalendarDisplay(null, view);
446 function onDayOverview()
448 return _ensureView("dayview");
451 function onMulticolumnDayOverview()
453 return _ensureView("multicolumndayview");
456 function onWeekOverview()
458 return _ensureView("weekview");
461 function onMonthOverview()
463 return _ensureView("monthview");
466 function scrollDayView(hour)
470 if (hour.length == 3)
471 rowNumber = parseInt(hour.substr(0, 1));
473 if (hour.substr(0, 1) == "0")
474 rowNumber = parseInt(hour.substr(1, 1));
476 rowNumber = parseInt(hour.substr(0, 2));
481 var daysView = $("daysView");
482 var hours = daysView.childNodesWithTag("div")[0].childNodesWithTag("div");
483 if (hours.length > 0)
484 daysView.parentNode.scrollTop = hours[rowNumber + 1].offsetTop;
487 function onClickableCellsDblClick(event) {
488 newEvent(this, 'event');
490 event.cancelBubble = true;
491 event.returnValue = false;
494 function calendarDisplayCallback(http)
496 var div = $("calendarView");
498 // log ("calendardisplaycallback: " + div);
499 if (http.readyState == 4
500 && http.status == 200) {
501 document.dayDisplayAjaxRequest = null;
502 div.innerHTML = http.responseText;
503 if (http.callbackData["view"])
504 currentView = http.callbackData["view"];
505 if (http.callbackData["day"])
506 currentDay = http.callbackData["day"];
508 if (http.callbackData["hour"])
509 hour = http.callbackData["hour"];
511 if (currentView == "monthview")
512 contentView = $("calendarContent");
516 contentView = $("daysView");
518 var appointments = document.getElementsByClassName("appointment", contentView);
519 for (var i = 0; i < appointments.length; i++) {
520 appointments[i].addEventListener("mousedown", listRowMouseDownHandler, true);
521 appointments[i].addEventListener("click", onCalendarSelectAppointment, false);
522 appointments[i].addEventListener("dblclick", displayAppointment, true);
524 var days = document.getElementsByClassName("day", contentView);
525 if (currentView == "monthview")
526 for (var i = 0; i < days.length; i++) {
527 days[i].addEventListener("click", onCalendarSelectDay, true);
528 days[i].addEventListener("dblclick", onClickableCellsDblClick, false);
531 for (var i = 0; i < days.length; i++) {
532 days[i].addEventListener("click", onCalendarSelectDay, false);
533 var clickableCells = document.getElementsByClassName("clickableHourCell",
535 for (var j = 0; j < clickableCells.length; j++)
536 clickableCells[j].addEventListener("dblclick",
537 onClickableCellsDblClick, false);
542 log ("ajax fuckage");
545 function assignCalendar(name)
549 node.calendar = new skycalendar(node);
550 node.calendar.setCalendarPage(ResourcesURL + "/skycalendar.html");
551 var dateFormat = node.getAttribute("dateFormat");
553 node.calendar.setDateFormat(dateFormat);
556 function popupCalendar(node)
558 var nodeId = node.getAttribute("inputId");
559 var input = $(nodeId);
560 input.calendar.popup();
565 function onAppointmentContextMenu(event, element)
567 var topNode = $("appointmentsList");
570 var menu = $("appointmentsListMenu");
572 menu.addEventListener("hideMenu", onAppointmentContextMenuHide, false);
573 onMenuClick(event, "appointmentsListMenu");
575 var topNode = $("appointmentsList");
576 var selectedNodes = topNode.getSelectedRows();
577 topNode.menuSelectedRows = selectedNodes;
578 for (var i = 0; i < selectedNodes.length; i++)
579 selectedNodes[i].deselect();
581 topNode.menuSelectedEntry = element;
585 function onAppointmentContextMenuHide(event)
587 var topNode = $("appointmentsList");
589 if (topNode.menuSelectedEntry) {
590 topNode.menuSelectedEntry.deselect();
591 topNode.menuSelectedEntry = null;
593 if (topNode.menuSelectedRows) {
594 var nodeIds = topNode.menuSelectedRows;
595 for (var i = 0; i < nodeIds.length; i++) {
596 var node = $(nodeIds[i]);
599 topNode.menuSelectedRows = null;
603 function onAppointmentsSelectionChange() {
604 listOfSelection = this;
605 this.removeClassName("_unfocused");
606 $("tasksList").addClassName("_unfocused");
609 function onTasksSelectionChange() {
610 listOfSelection = this;
611 this.removeClassName("_unfocused");
612 $("appointmentsList").addClassName("_unfocused");
615 function _loadAppointmentHref(href) {
616 if (document.appointmentsListAjaxRequest) {
617 document.appointmentsListAjaxRequest.aborted = true;
618 document.appointmentsListAjaxRequest.abort();
620 var url = ApplicationBaseURL + href;
621 document.appointmentsListAjaxRequest
622 = triggerAjaxRequest(url, appointmentsListCallback, href);
627 function _loadTasksHref(href) {
628 if (document.tasksListAjaxRequest) {
629 document.tasksListAjaxRequest.aborted = true;
630 document.tasksListAjaxRequest.abort();
632 url = ApplicationBaseURL + href;
634 var selectedIds = $("tasksList").getSelectedNodesId();
635 document.tasksListAjaxRequest
636 = triggerAjaxRequest(url, tasksListCallback, selectedIds);
641 function onHeaderClick(event) {
642 // log("onHeaderClick: " + this.link);
643 _loadAppointmentHref(this.link);
645 event.preventDefault();
648 function refreshAppointments() {
649 return _loadAppointmentHref("aptlist?desc=" + sortOrder
651 + "&day=" + currentDay
652 + "&filterpopup=" + listFilter);
655 function refreshTasks() {
656 return _loadTasksHref("taskslist?hide-completed=" + hideCompletedTasks);
659 function refreshAppointmentsAndDisplay()
661 refreshAppointments();
662 changeCalendarDisplay();
665 function onListFilterChange() {
666 var node = $("filterpopup");
668 listFilter = node.value;
669 // log ("listFilter = " + listFilter);
671 return refreshAppointments();
674 function onAppointmentClick(event)
676 var node = event.target.getParentWithTagName("tr");
677 var day = node.getAttribute("day");
678 var hour = node.getAttribute("hour");
680 changeCalendarDisplay( { "day": day, "hour": hour} );
681 changeDateSelectorDisplay(day);
683 return onRowClick(event);
686 function selectMonthInMenu(menu, month)
688 var entries = menu.childNodes[1].childNodesWithTag("LI");
689 for (i = 0; i < entries.length; i++) {
690 var entry = entries[i];
691 var entryMonth = entry.getAttribute("month");
692 if (entryMonth == month)
693 entry.addClassName("currentMonth");
695 entry.removeClassName("currentMonth");
699 function selectYearInMenu(menu, month)
701 var entries = menu.childNodes[1].childNodes;
702 for (i = 0; i < entries.length; i++) {
703 var entry = entries[i];
704 if (entry instanceof HTMLLIElement) {
705 var entryMonth = entry.innerHTML;
706 if (entryMonth == month)
707 entry.addClassName("currentMonth");
709 entry.removeClassName("currentMonth");
714 function popupMonthMenu(event, menuId)
716 var node = event.target;
718 if (event.button == 0) {
719 event.cancelBubble = true;
720 event.returnValue = false;
722 if (document.currentPopupMenu)
723 hideMenu(event, document.currentPopupMenu);
725 var popup = $(menuId);
726 var id = node.getAttribute("id");
727 if (id == "monthLabel")
728 selectMonthInMenu(popup, node.getAttribute("month"));
730 selectYearInMenu(popup, node.innerHTML);
732 var diff = (popup.offsetWidth - node.offsetWidth) /2;
734 popup.style.top = (node.offsetTop + 95) + "px";
735 popup.style.left = (node.offsetLeft - diff) + "px";
736 popup.style.visibility = "visible";
738 bodyOnClick = "" + document.body.getAttribute("onclick");
739 document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');");
740 document.currentPopupMenu = popup;
744 function onMonthMenuItemClick(node)
746 var month = '' + node.getAttribute("month");
747 var year = '' + $("yearLabel").innerHTML;
749 changeDateSelectorDisplay(year+month+"01", true);
754 function onYearMenuItemClick(node) {
755 var month = '' + $("monthLabel").getAttribute("month");;
756 var year = '' + node.innerHTML;
758 changeDateSelectorDisplay(year+month+"01", true);
763 function onSearchFormSubmit() {
764 log ("search not implemented");
769 function onCalendarSelectAppointment() {
770 var list = $("appointmentsList");
773 var aptCName = this.getAttribute("aptCName");
774 if (selectedCalendarCell)
775 selectedCalendarCell.deselect();
777 selectedCalendarCell = this;
778 var row = $(aptCName);
780 var div = row.parentNode.parentNode.parentNode;
781 div.scrollTop = row.offsetTop - (div.offsetHeight / 2);
786 function onCalendarSelectDay(event) {
788 if (currentView == "multicolumndayview")
789 day = this.parentNode.getAttribute("day");
791 day = this.getAttribute("day");
792 var needRefresh = (listFilter == 'view_selectedday'
793 && day != currentDay);
795 if (currentView == 'weekview')
796 changeWeekCalendarDisplayOfSelectedDay(this);
797 else if (currentView == 'monthview')
798 changeMonthCalendarDisplayOfSelectedDay(this);
799 changeDateSelectorDisplay(day);
801 if (listOfSelection) {
802 listOfSelection.addClassName("_unfocused");
803 listOfSelection = null;
807 refreshAppointments();
810 function changeWeekCalendarDisplayOfSelectedDay(node) {
811 var days = document.getElementsByClassName("day", node.parentNode);
813 for (var i = 0; i < days.length; i++)
815 days[i].removeClassName("selectedDay");
817 node.addClassName("selectedDay");
820 function findMonthCalendarSelectedCell(daysContainer) {
824 while (!found && i < daysContainer.childNodes.length) {
825 var currentNode = daysContainer.childNodes[i];
826 if (currentNode instanceof HTMLDivElement
827 && currentNode.hasClassName("selectedDay")) {
828 daysContainer.selectedCell = currentNode;
836 function changeMonthCalendarDisplayOfSelectedDay(node)
838 var daysContainer = node.parentNode;
839 if (!daysContainer.selectedCell)
840 findMonthCalendarSelectedCell(daysContainer);
842 if (daysContainer.selectedCell)
843 daysContainer.selectedCell.removeClassName("selectedDay");
844 daysContainer.selectedCell = node;
845 node.addClassName("selectedDay");
848 function onHideCompletedTasks(node)
850 hideCompletedTasks = (node.checked ? 1 : 0);
852 return refreshTasks();
855 function updateTaskStatus(node)
857 var taskId = node.parentNode.getAttribute("id");
858 var taskOwner = node.parentNode.getAttribute("owner");
859 var newStatus = (node.checked ? 1 : 0);
860 // log ("update task status: " + taskId);
862 var http = createHTTPClient();
864 url = (UserFolderURL + "../" + taskOwner + "/Calendar/"
865 + taskId + "/changeStatus?status=" + newStatus);
868 // log ("url: " + url);
869 // TODO: add parameter to signal that we are only interested in OK
871 http.open("GET", url, false /* not async */);
873 if (http.status == 200)
876 log ("no http client?");
881 function updateCalendarStatus()
883 var list = new Array();
885 var clist = $("calendarsList");
886 var nodes = clist.childNodesWithTag("ul")[0].childNodesWithTag("li");
887 for (var i = 0; i < nodes.length; i++) {
888 var input = nodes[i].childNodesWithTag("input")[0];
890 list.push(nodes[i].getAttribute("uid"));
894 list.push(nodes[0].getAttribute("uid"));
895 nodes[0].childNodesWithTag("input")[0].checked = true;
897 // ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
898 // + list.join(",") + "/Calendar/");
900 updateCalendarsList();
901 refreshAppointments();
903 changeCalendarDisplay();
908 function calendarUidsList()
912 var nodes = $("uixselector-calendarsList-display").childNodesWithTag("li");
913 for (var i = 0; i < nodes.length; i++) {
914 var currentNode = nodes[i];
915 var input = currentNode.childNodesWithTag("input")[0];
918 list += currentNode.getAttribute("uid") + ",";
921 return list.substr(0, list.length - 1);
924 // function updateCalendarContacts(contacts)
926 // var list = contacts.split(",");
928 // var clist = $("calendarsList");
929 // var nodes = clist.childNodes[5].childNodes;
930 // for (var i = 0; i < nodes.length; i++) {
931 // var currentNode = nodes[i];
932 // if (currentNode instanceof HTMLLIElement) {
933 // var input = currentNode.childNodes[3];
934 // if (!input.checked)
936 // list += currentNode.getAttribute("uid") + ",";
941 function inhibitMyCalendarEntry()
943 var clist = $("calendarsList");
944 var nodes = clist.childNodes[5].childNodes;
948 while (!done && i < nodes.length) {
949 var currentNode = nodes[i];
950 if (currentNode instanceof HTMLLIElement) {
951 var input = currentNode.childNodes[3];
952 if (currentNode.getAttribute("uid") == UserLogin) {
954 // currentNode.style.color = "#999;";
955 currentNode.style.fontWeight = "bold;";
956 // currentNode.setAttribute("onclick", "");
963 function userCalendarEntry(user, color) {
964 var li = document.createElement("li");
965 li.setAttribute("uid", user);
966 li.addEventListener("mousedown", listRowMouseDownHandler, false);
967 li.addEventListener("click", onRowClick, false);
968 var colorBox = document.createElement("span");
969 colorBox.addClassName("colorBox");
971 log("color: " + color);
972 colorBox.style.backgroundColor = color + ";";
974 li.appendChild(colorBox);
975 var checkBox = document.createElement("input");
976 checkBox.addClassName("checkBox");
977 checkBox.type = "checkbox";
978 checkBox.addEventListener("change", updateCalendarStatus, false);
979 li.appendChild(checkBox);
980 var text = document.createTextNode(" " + user);
981 li.appendChild(text);
986 function ensureSelfIfPresent() {
987 var ul = $("uixselector-calendarsList-display");
988 var list = ul.childNodesWithTag("li");
989 var selfEntry = userCalendarEntry(UserLogin, indexColor(0));
990 selfEntry.style.fontWeight = "bold;";
991 if (list.length < 1) {
992 ul.appendChild(selfEntry);
993 } else if (list[0].getAttribute("uid") != UserLogin) {
994 ul.insertBefore(selfEntry, list[0]);
998 function updateCalendarsList(method)
1000 ensureSelfIfPresent();
1001 var url = (ApplicationBaseURL + "updateCalendars?ids="
1002 + calendarUidsList());
1003 if (document.calendarsListAjaxRequest) {
1004 document.calendarsListAjaxRequest.aborted = true;
1005 document.calendarsListAjaxRequest.abort();
1007 var http = createHTTPClient();
1010 http.open("GET", url, false);
1013 if (method == "removal")
1014 updateCalendarStatus();
1016 http = createHTTPClient();
1017 http.url = ApplicationBaseURL + "checkRights";
1018 http.open("GET", http.url, false /* not async */);
1020 if (http.status == 200
1021 && http.responseText.length > 0) {
1022 rights = http.responseText.split(",");
1023 var list = $("uixselector-calendarsList-display").childNodesWithTag("li");
1024 for (var i = 0; i < list.length; i++) {
1025 var input = list[i].childNodesWithTag("input")[0];
1026 if (rights[i] == "1") {
1027 list[i].removeClassName("denied");
1028 input.disabled = false;
1031 input.checked = false;
1032 input.disabled = true;
1033 list[i].addClassName("denied");
1040 function addContact(tag, fullContactName, contactId, contactName, contactEmail)
1042 var uids = $("uixselector-calendarsList-uidList");
1043 // log("addContact");
1046 var re = new RegExp("(^|,)" + contactId + "($|,)");
1048 if (!re.test(uids.value))
1050 if (uids.value.length > 0)
1051 uids.value += ',' + contactId;
1053 uids.value = contactId;
1054 var names = $("uixselector-calendarsList-display");
1055 var listElems = names.childNodesWithTag("li");
1056 var colorDef = indexColor(listElems.length);
1057 names.appendChild(userCalendarEntry(contactId, colorDef));
1059 var styles = document.getElementsByTagName("style");
1060 styles[0].innerHTML += ('.ownerIs' + contactId + ' {'
1061 + ' background-color: '
1063 + ' !important; }');
1070 function onChangeCalendar(list) {
1071 var form = document.forms.editform;
1072 log ("before: " + form.getAttribute("action"));
1073 var urlElems = form.getAttribute("action").split("/");
1074 urlElems[urlElems.length-4]
1075 = list.childNodesWithTag("option")[list.value].innerHTML;
1076 form.setAttribute("action", urlElems.join("/"));
1077 log ("after: " + form.getAttribute("action"));
1080 function validateBrowseURL(input) {
1081 var button = $("browseURLBtn");
1083 if (input.value.length) {
1084 if (!button.enabled)
1085 enableAnchor(button);
1086 } else if (!button.disabled)
1087 disableAnchor(button);
1090 function browseURL(anchor, event) {
1091 if (event.button == 0) {
1092 var input = $("url");
1093 var url = input.value;
1095 window.open(url, '_blank');
1101 function initializeMenus() {
1102 var menus = new Array("monthListMenu", "yearListMenu",
1103 "appointmentsListMenu", "calendarsMenu", "searchMenu");
1104 initMenusNamed(menus);
1106 $("calendarsList").attachMenu("calendarsMenu");
1108 var accessRightsMenuEntry = $("accessRightsMenuEntry");
1109 accessRightsMenuEntry.addEventListener("mouseup",
1110 onAccessRightsMenuEntryMouseUp,
1114 function onAccessRightsMenuEntryMouseUp(event) {
1115 var folders = $("uixselector-calendarsList-display");
1116 var selected = folders.getSelectedNodes()[0];
1117 var uid = selected.getAttribute("uid");
1118 log("application base url: " + ApplicationBaseURL);
1119 if (uid == UserLogin)
1120 url = ApplicationBaseURL + "acls";
1122 url = UserFolderURL + "../" + uid + "/Calendar/acls";
1124 openAclWindow(url, uid);
1127 function configureDragHandles() {
1128 var handle = $("verticalDragHandle");
1130 handle.addInterface(SOGoDragHandlesInterface);
1131 handle.leftBlock=$("leftPanel");
1132 handle.rightBlock=$("rightPanel");
1135 handle = $("rightDragHandle");
1137 handle.addInterface(SOGoDragHandlesInterface);
1138 handle.upperBlock=$("appointmentsListView");
1139 handle.lowerBlock=$("calendarView");
1143 function initCalendarContactsSelector() {
1144 var selector = $("calendarsList");
1145 inhibitMyCalendarEntry();
1146 updateCalendarStatus();
1147 selector.changeNotification = updateCalendarsList;
1149 var list = $("uixselector-calendarsList-display").childNodesWithTag("li");
1150 for (var i = 0; i < list.length; i++) {
1151 var input = list[i].childNodesWithTag("input")[0];
1152 input.addEventListener("change", updateCalendarStatus, false);
1156 function initCalendars() {
1157 if (!document.body.hasClassName("popup"))
1158 initCalendarContactsSelector();
1161 function onSchedulerBodyKeyUp(event) {
1162 if (event.which == 46) {
1163 window.alert("coucou");
1165 event.cancelBubble = true;
1169 window.addEventListener("load", initCalendars, false);
1170 // document.body.addEventListener("keyup", onSchedulerBodyKeyUp, false);