2006-08-19 00:40:04 +02:00
|
|
|
var sortOrder = '';
|
|
|
|
var sortKey = '';
|
2006-08-31 01:13:18 +02:00
|
|
|
var listFilter = 'view_today';
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-10-12 23:05:32 +02:00
|
|
|
var listOfSelection = null;
|
2007-01-30 14:50:52 +01:00
|
|
|
var selectedCalendarCell;
|
2006-10-12 23:05:32 +02:00
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
var hideCompletedTasks = 0;
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
var currentDay = '';
|
2006-11-15 22:54:47 +01:00
|
|
|
var currentView = "dayview";
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
var cachedDateSelectors = new Array();
|
|
|
|
|
2006-10-14 01:37:27 +02:00
|
|
|
var contactSelectorAction = 'calendars-contacts';
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
var eventsToDelete = new Array();
|
|
|
|
var ownersOfEventsToDelete = new Array();
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function newEvent(sender, type) {
|
2006-08-31 01:13:18 +02:00
|
|
|
var day = sender.getAttribute("day");
|
2006-09-05 23:52:52 +02:00
|
|
|
if (!day)
|
|
|
|
day = currentDay;
|
|
|
|
|
2007-02-13 23:01:02 +01:00
|
|
|
var user = UserLogin;
|
|
|
|
if (currentView == "multicolumndayview" && type == "event")
|
|
|
|
user = sender.parentNode.parentNode.getAttribute("user");
|
|
|
|
|
2006-08-31 01:13:18 +02:00
|
|
|
var hour = sender.getAttribute("hour");
|
2007-02-13 23:01:02 +01:00
|
|
|
var urlstr = UserFolderURL + "../" + user + "/Calendar/new" + type;
|
2006-11-07 17:13:03 +01:00
|
|
|
var params = new Array();
|
|
|
|
if (day)
|
|
|
|
params.push("day=" + day);
|
|
|
|
if (hour)
|
|
|
|
params.push("hm=" + hour);
|
|
|
|
if (params.length > 0)
|
|
|
|
urlstr += "?" + params.join("&");
|
2006-08-15 22:52:23 +02:00
|
|
|
|
2006-10-27 00:00:54 +02:00
|
|
|
window.open(urlstr, "", "width=620,height=600,resizable=0");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
|
|
|
|
2006-10-17 00:35:22 +02:00
|
|
|
function _editEventId(id, owner) {
|
|
|
|
var urlBase;
|
|
|
|
if (owner)
|
|
|
|
urlBase = UserFolderURL + "../" + owner + "/";
|
|
|
|
urlBase += "Calendar/"
|
|
|
|
|
|
|
|
var urlstr = urlBase + id + "/edit";
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
var win = window.open(urlstr, "SOGo_edit_" + id,
|
2006-10-23 23:37:53 +02:00
|
|
|
"width=620,height=600,resizable=0,scrollbars=0,toolbar=0," +
|
2006-08-22 00:36:33 +02:00
|
|
|
"location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
|
|
|
win.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
function editEvent() {
|
2006-10-12 23:05:32 +02:00
|
|
|
if (listOfSelection) {
|
2006-10-17 00:35:22 +02:00
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-10-12 23:05:32 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++)
|
2006-10-27 17:03:48 +02:00
|
|
|
_editEventId(nodes[i].getAttribute("id"),
|
|
|
|
nodes[i].getAttribute("owner"));
|
2007-01-30 14:50:52 +01:00
|
|
|
} else if (selectedCalendarCell) {
|
|
|
|
_editEventId(selectedCalendarCell.getAttribute("aptCName"),
|
|
|
|
selectedCalendarCell.getAttribute("owner"));
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
2006-08-25 22:49:34 +02:00
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
function _batchDeleteEvents() {
|
|
|
|
var events = eventsToDelete.shift();
|
|
|
|
var owner = ownersOfEventsToDelete.shift();
|
2006-10-17 00:35:22 +02:00
|
|
|
var urlstr = (UserFolderURL + "../" + owner + "/Calendar/batchDelete?ids="
|
|
|
|
+ events.join('/'));
|
2006-10-18 23:53:47 +02:00
|
|
|
document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
deleteEventCallback,
|
|
|
|
events);
|
2006-10-17 00:35:22 +02:00
|
|
|
}
|
|
|
|
|
2006-10-12 23:05:32 +02:00
|
|
|
function deleteEvent()
|
|
|
|
{
|
|
|
|
if (listOfSelection) {
|
2006-10-17 00:35:22 +02:00
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
2006-10-12 23:05:32 +02:00
|
|
|
|
|
|
|
if (nodes.length > 0) {
|
2006-11-06 18:44:07 +01:00
|
|
|
var label = "";
|
|
|
|
if (listOfSelection == $("tasksList"))
|
|
|
|
label = labels["taskDeleteConfirmation"].decodeEntities();
|
|
|
|
else
|
|
|
|
label = labels["appointmentDeleteConfirmation"].decodeEntities();
|
|
|
|
|
|
|
|
if (confirm(label)) {
|
2006-10-18 23:53:47 +02:00
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
2006-10-17 00:35:22 +02:00
|
|
|
var sortedNodes = new Array();
|
|
|
|
var owners = new Array();
|
|
|
|
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var owner = nodes[i].getAttribute("owner");
|
2006-10-18 23:53:47 +02:00
|
|
|
if (!sortedNodes[owner]) {
|
2006-10-17 00:35:22 +02:00
|
|
|
sortedNodes[owner] = new Array();
|
|
|
|
owners.push(owner);
|
2006-10-18 23:53:47 +02:00
|
|
|
}
|
2006-10-17 00:35:22 +02:00
|
|
|
sortedNodes[owner].push(nodes[i].getAttribute("id"));
|
|
|
|
}
|
2006-10-18 23:53:47 +02:00
|
|
|
for (var i = 0; i < owners.length; i++) {
|
|
|
|
ownersOfEventsToDelete.push(owners[i]);
|
|
|
|
eventsToDelete.push(sortedNodes[owners[i]]);
|
|
|
|
}
|
|
|
|
_batchDeleteEvents();
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
2007-01-30 14:50:52 +01:00
|
|
|
else if (selectedCalendarCell) {
|
|
|
|
var label = labels["appointmentDeleteConfirmation"].decodeEntities();
|
|
|
|
if (confirm(label)) {
|
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
eventsToDelete.push([selectedCalendarCell.getAttribute("aptCName")]);
|
|
|
|
ownersOfEventsToDelete.push(selectedCalendarCell.getAttribute("owner"));
|
|
|
|
_batchDeleteEvents();
|
|
|
|
}
|
|
|
|
}
|
2006-11-13 23:31:41 +01:00
|
|
|
else
|
|
|
|
window.alert("no selection");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-08-25 22:49:34 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-07 19:14:29 +01:00
|
|
|
function modifyEvent(sender, modification) {
|
|
|
|
var currentLocation = '' + window.location;
|
|
|
|
var arr = currentLocation.split("/");
|
|
|
|
arr[arr.length-1] = modification;
|
2006-11-15 01:10:53 +01:00
|
|
|
|
|
|
|
document.modifyEventAjaxRequest = triggerAjaxRequest(arr.join("/"),
|
|
|
|
modifyEventCallback,
|
|
|
|
modification);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-01-04 23:30:48 +01:00
|
|
|
function closeInvitationWindow() {
|
|
|
|
var closeDiv = document.createElement("div");
|
|
|
|
closeDiv.addClassName("javascriptPopupBackground");
|
|
|
|
var closePseudoWin = document.createElement("div");
|
|
|
|
closePseudoWin.addClassName("javascriptMessagePseudoWindow");
|
|
|
|
closePseudoWin.style.top = "0px;";
|
|
|
|
closePseudoWin.style.left = "0px;";
|
|
|
|
closePseudoWin.style.right = "0px;";
|
|
|
|
closePseudoWin.appendChild(document.createTextNode(labels["closeThisWindowMessage"].decodeEntities()));
|
|
|
|
document.body.appendChild(closeDiv);
|
|
|
|
document.body.appendChild(closePseudoWin);
|
|
|
|
}
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
function modifyEventCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
log("closing window...?");
|
2007-01-04 23:30:48 +01:00
|
|
|
if (queryParameters["mail-invitation"] == "yes")
|
|
|
|
closeInvitationWindow();
|
2007-01-30 15:02:27 +01:00
|
|
|
else {
|
|
|
|
window.opener.setTimeout("refreshAppointmentsAndDisplay();", 100);
|
|
|
|
window.setTimeout("window.close();", 100);
|
|
|
|
}
|
2006-11-15 01:10:53 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
log("showing alert...");
|
|
|
|
window.alert(labels["eventPartStatModificationError"]);
|
|
|
|
}
|
|
|
|
document.modifyEventAjaxRequest = null;
|
|
|
|
}
|
2006-11-07 19:14:29 +01:00
|
|
|
}
|
|
|
|
|
2006-08-25 22:49:34 +02:00
|
|
|
function deleteEventCallback(http)
|
|
|
|
{
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2007-01-30 19:18:30 +01:00
|
|
|
var nodes = http.callbackData;
|
2006-10-12 23:05:32 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var node = $(nodes[i]);
|
2007-01-30 19:18:30 +01:00
|
|
|
if (node)
|
|
|
|
node.parentNode.removeChild(node);
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
2006-10-18 23:53:47 +02:00
|
|
|
if (eventsToDelete.length)
|
|
|
|
_batchDeleteEvents();
|
|
|
|
else {
|
|
|
|
document.deleteEventAjaxRequest = null;
|
|
|
|
refreshAppointments();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
2006-08-14 22:32:30 +02:00
|
|
|
}
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
function editDoubleClickedEvent(node)
|
|
|
|
{
|
2006-10-17 00:35:22 +02:00
|
|
|
_editEventId(node.getAttribute("id"),
|
|
|
|
node.getAttribute("owner"));
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-08-25 22:49:34 +02:00
|
|
|
function onSelectAll() {
|
|
|
|
var list = $("appointmentsList");
|
|
|
|
list.selectRowsMatchingClass("appointmentRow");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
function displayAppointment(event) {
|
|
|
|
_editEventId(this.getAttribute("aptCName"),
|
|
|
|
this.getAttribute("owner"));
|
2006-08-15 22:52:23 +02:00
|
|
|
|
2006-11-15 18:59:47 +01:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2006-09-05 20:43:20 +02:00
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
2006-08-15 22:52:23 +02:00
|
|
|
}
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
function onDaySelect(node)
|
|
|
|
{
|
2006-09-07 00:27:46 +02:00
|
|
|
var day = node.getAttribute("day");
|
2006-11-15 22:54:47 +01:00
|
|
|
var needRefresh = (listFilter == 'view_selectedday'
|
|
|
|
&& day != currentDay);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
var td = node.getParentWithTagName("td");
|
|
|
|
var table = td.getParentWithTagName("table");
|
|
|
|
|
|
|
|
// log ("table.selected: " + table.selected);
|
|
|
|
|
|
|
|
if (document.selectedDate)
|
2006-12-20 23:55:54 +01:00
|
|
|
document.selectedDate.deselect();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-12-20 23:55:54 +01:00
|
|
|
td.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
document.selectedDate = td;
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": day } );
|
2006-11-15 22:54:47 +01:00
|
|
|
if (needRefresh)
|
2006-08-22 00:36:33 +02:00
|
|
|
refreshAppointments();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDateSelectorGotoMonth(node)
|
|
|
|
{
|
|
|
|
var day = node.getAttribute("date");
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day, true);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarGotoDay(node)
|
|
|
|
{
|
|
|
|
var day = node.getAttribute("date");
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": day } );
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function gotoToday()
|
|
|
|
{
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay('');
|
2006-08-24 20:48:33 +02:00
|
|
|
changeCalendarDisplay();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
function setDateSelectorContent(content)
|
2006-08-19 00:40:04 +02:00
|
|
|
{
|
2006-08-24 20:48:33 +02:00
|
|
|
var div = $("dateSelectorView");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
div.innerHTML = content;
|
|
|
|
if (currentDay.length > 0)
|
|
|
|
restoreCurrentDaySelection(div);
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
function dateSelectorCallback(http)
|
|
|
|
{
|
2006-08-19 00:40:04 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.dateSelectorAjaxRequest = null;
|
2006-09-07 17:50:03 +02:00
|
|
|
var content = http.responseText;
|
|
|
|
setDateSelectorContent(content);
|
|
|
|
cachedDateSelectors[http.callbackData] = content;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
|
|
|
function appointmentsListCallback(http)
|
|
|
|
{
|
2006-08-24 20:48:33 +02:00
|
|
|
var div = $("appointmentsListView");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2006-10-11 20:12:02 +02:00
|
|
|
document.appointmentsListAjaxRequest = null;
|
2006-08-19 00:40:04 +02:00
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
var params = parseQueryParameters(http.callbackData);
|
|
|
|
sortKey = params["sort"];
|
|
|
|
sortOrder = params["desc"];
|
2006-11-13 23:31:41 +01:00
|
|
|
var list = $("appointmentsList");
|
|
|
|
list.addEventListener("selectionchange",
|
|
|
|
onAppointmentsSelectionChange, true);
|
2006-11-09 23:55:04 +01:00
|
|
|
configureSortableTableHeaders();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function tasksListCallback(http)
|
|
|
|
{
|
|
|
|
var div = $("tasksListView");
|
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.tasksListAjaxRequest = null;
|
2006-11-13 23:31:41 +01:00
|
|
|
var list = $("tasksList");
|
2006-11-15 01:10:53 +01:00
|
|
|
var scroll = list.scrollTop;
|
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
list = $("tasksList");
|
2006-11-13 23:31:41 +01:00
|
|
|
list.addEventListener("selectionchange",
|
|
|
|
onTasksSelectionChange, true);
|
2006-11-15 01:10:53 +01:00
|
|
|
list.scrollTop = scroll;
|
2006-10-11 20:12:02 +02:00
|
|
|
if (http.callbackData) {
|
|
|
|
var selectedNodesId = http.callbackData;
|
|
|
|
for (var i = 0; i < selectedNodesId.length; i++)
|
2006-12-20 23:55:54 +01:00
|
|
|
$(selectedNodesId[i]).select();
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
function restoreCurrentDaySelection(div)
|
|
|
|
{
|
|
|
|
var elements = div.getElementsByTagName("a");
|
|
|
|
var day = null;
|
2006-11-03 00:17:55 +01:00
|
|
|
var i = 9;
|
2006-08-19 00:40:04 +02:00
|
|
|
while (!day && i < elements.length)
|
|
|
|
{
|
|
|
|
day = elements[i].getAttribute("day");
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (day
|
2006-11-06 18:44:07 +01:00
|
|
|
&& day.substr(0, 6) == currentDay.substr(0, 6)) {
|
2006-08-19 00:40:04 +02:00
|
|
|
for (i = 0; i < elements.length; i++) {
|
|
|
|
day = elements[i].getAttribute("day");
|
|
|
|
if (day && day == currentDay) {
|
|
|
|
var td = elements[i].getParentWithTagName("td");
|
|
|
|
if (document.selectedDate)
|
2006-12-20 23:55:54 +01:00
|
|
|
document.selectedDate.deselect();
|
|
|
|
td.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
document.selectedDate = td;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
function changeDateSelectorDisplay(day, keepCurrentDay)
|
2006-08-19 00:40:04 +02:00
|
|
|
{
|
|
|
|
var url = ApplicationBaseURL + "dateselector";
|
|
|
|
if (day)
|
|
|
|
url += "?day=" + day;
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
if (day != currentDay) {
|
|
|
|
if (!keepCurrentDay)
|
|
|
|
currentDay = day;
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-02-13 23:01:02 +01:00
|
|
|
log (backtrace());
|
2006-09-07 17:50:03 +02:00
|
|
|
var month = day.substr(0, 6);
|
|
|
|
if (cachedDateSelectors[month]) {
|
2006-10-17 00:35:22 +02:00
|
|
|
// log ("restoring cached selector for month: " + month);
|
2006-09-07 17:50:03 +02:00
|
|
|
setDateSelectorContent(cachedDateSelectors[month]);
|
|
|
|
}
|
|
|
|
else {
|
2006-10-17 00:35:22 +02:00
|
|
|
// log ("loading selector for month: " + month);
|
2006-09-07 17:50:03 +02:00
|
|
|
if (document.dateSelectorAjaxRequest) {
|
|
|
|
document.dateSelectorAjaxRequest.aborted = true;
|
|
|
|
document.dateSelectorAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.dateSelectorAjaxRequest
|
|
|
|
= triggerAjaxRequest(url,
|
|
|
|
dateSelectorCallback,
|
|
|
|
month);
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function changeCalendarDisplay(time, newView)
|
2006-08-19 00:40:04 +02:00
|
|
|
{
|
2006-12-19 18:06:07 +01:00
|
|
|
var url = ApplicationBaseURL + ((newView) ? newView : currentView);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-01-30 14:50:52 +01:00
|
|
|
selectedCalendarCell = null;
|
|
|
|
|
2006-10-12 18:46:24 +02:00
|
|
|
var day = null;
|
|
|
|
var hour = null;
|
|
|
|
if (time) {
|
|
|
|
day = time['day'];
|
|
|
|
hour = time['hour'];
|
|
|
|
}
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
if (!day)
|
2006-09-07 00:27:46 +02:00
|
|
|
day = currentDay;
|
2006-08-19 00:40:04 +02:00
|
|
|
if (day)
|
|
|
|
url += "?day=" + day;
|
|
|
|
|
2006-11-06 18:44:07 +01:00
|
|
|
// if (newView)
|
2006-10-17 00:35:22 +02:00
|
|
|
// log ("switching to view: " + newView);
|
2006-08-24 20:48:33 +02:00
|
|
|
// log ("changeCalendarDisplay: " + url);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
if (document.dayDisplayAjaxRequest) {
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("aborting day ajaxrq");
|
2006-08-19 00:40:04 +02:00
|
|
|
document.dayDisplayAjaxRequest.aborted = true;
|
|
|
|
document.dayDisplayAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.dayDisplayAjaxRequest = triggerAjaxRequest(url,
|
2006-08-24 20:48:33 +02:00
|
|
|
calendarDisplayCallback,
|
|
|
|
{ "view": newView,
|
2006-10-11 20:12:02 +02:00
|
|
|
"day": day,
|
|
|
|
"hour": hour });
|
2006-08-24 20:48:33 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _ensureView(view) {
|
|
|
|
if (currentView != view)
|
|
|
|
changeCalendarDisplay(null, view);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
function onDayOverview()
|
|
|
|
{
|
|
|
|
return _ensureView("dayview");
|
|
|
|
}
|
|
|
|
|
2007-02-13 23:01:02 +01:00
|
|
|
function onMulticolumnDayOverview()
|
|
|
|
{
|
|
|
|
return _ensureView("multicolumndayview");
|
|
|
|
}
|
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
function onWeekOverview()
|
|
|
|
{
|
|
|
|
return _ensureView("weekview");
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMonthOverview()
|
|
|
|
{
|
|
|
|
return _ensureView("monthview");
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function scrollDayView(hour)
|
2006-10-04 00:59:07 +02:00
|
|
|
{
|
2006-10-11 20:12:02 +02:00
|
|
|
var rowNumber;
|
|
|
|
if (hour) {
|
|
|
|
if (hour.length == 3)
|
|
|
|
rowNumber = parseInt(hour.substr(0, 1));
|
|
|
|
else {
|
|
|
|
if (hour.substr(0, 1) == "0")
|
|
|
|
rowNumber = parseInt(hour.substr(1, 1));
|
|
|
|
else
|
|
|
|
rowNumber = parseInt(hour.substr(0, 2));
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
rowNumber = 8;
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
var daysView = $("daysView");
|
|
|
|
var hours = daysView.childNodesWithTag("div")[0].childNodesWithTag("div");
|
|
|
|
if (hours.length > 0)
|
|
|
|
daysView.parentNode.scrollTop = hours[rowNumber + 1].offsetTop;
|
2006-10-04 00:59:07 +02:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:53:59 +01:00
|
|
|
function onClickableCellsDblClick(event) {
|
|
|
|
newEvent(this, 'event');
|
2006-11-15 18:59:47 +01:00
|
|
|
|
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
2006-11-15 01:53:59 +01:00
|
|
|
}
|
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
function calendarDisplayCallback(http)
|
2006-08-19 00:40:04 +02:00
|
|
|
{
|
2006-08-24 20:48:33 +02:00
|
|
|
var div = $("calendarView");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
// log ("calendardisplaycallback: " + div);
|
2006-08-19 00:40:04 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2007-01-05 17:10:48 +01:00
|
|
|
document.dayDisplayAjaxRequest = null;
|
2006-08-19 00:40:04 +02:00
|
|
|
div.innerHTML = http.responseText;
|
2006-08-24 20:48:33 +02:00
|
|
|
if (http.callbackData["view"])
|
|
|
|
currentView = http.callbackData["view"];
|
|
|
|
if (http.callbackData["day"])
|
2006-09-07 00:27:46 +02:00
|
|
|
currentDay = http.callbackData["day"];
|
2006-10-11 20:12:02 +02:00
|
|
|
var hour = null;
|
|
|
|
if (http.callbackData["hour"])
|
2006-10-18 23:53:47 +02:00
|
|
|
hour = http.callbackData["hour"];
|
2006-11-15 22:54:47 +01:00
|
|
|
var contentView;
|
|
|
|
if (currentView == "monthview")
|
|
|
|
contentView = $("calendarContent");
|
|
|
|
else {
|
2006-11-03 00:17:55 +01:00
|
|
|
scrollDayView(hour);
|
2006-12-14 22:20:13 +01:00
|
|
|
// log("cbtest1");
|
2006-11-15 22:54:47 +01:00
|
|
|
contentView = $("daysView");
|
|
|
|
}
|
|
|
|
var appointments = document.getElementsByClassName("appointment", contentView);
|
|
|
|
for (var i = 0; i < appointments.length; i++) {
|
|
|
|
appointments[i].addEventListener("mousedown", listRowMouseDownHandler, true);
|
2006-12-19 20:17:35 +01:00
|
|
|
appointments[i].addEventListener("click", onCalendarSelectAppointment, false);
|
2006-11-15 22:54:47 +01:00
|
|
|
appointments[i].addEventListener("dblclick", displayAppointment, true);
|
|
|
|
}
|
|
|
|
var days = document.getElementsByClassName("day", contentView);
|
|
|
|
if (currentView == "monthview")
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
days[i].addEventListener("click", onCalendarSelectDay, true);
|
|
|
|
days[i].addEventListener("dblclick", onClickableCellsDblClick, false);
|
2006-11-15 18:59:47 +01:00
|
|
|
}
|
2006-11-15 22:54:47 +01:00
|
|
|
else
|
2006-11-15 18:59:47 +01:00
|
|
|
for (var i = 0; i < days.length; i++) {
|
2006-12-19 20:17:35 +01:00
|
|
|
days[i].addEventListener("click", onCalendarSelectDay, false);
|
2006-11-15 18:59:47 +01:00
|
|
|
var clickableCells = document.getElementsByClassName("clickableHourCell",
|
|
|
|
days[i]);
|
2006-11-15 22:54:47 +01:00
|
|
|
for (var j = 0; j < clickableCells.length; j++)
|
2006-11-15 18:59:47 +01:00
|
|
|
clickableCells[j].addEventListener("dblclick",
|
|
|
|
onClickableCellsDblClick, false);
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
// log("cbtest1");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
2006-08-31 01:13:18 +02:00
|
|
|
function assignCalendar(name)
|
2006-08-19 00:40:04 +02:00
|
|
|
{
|
2006-08-31 01:13:18 +02:00
|
|
|
var node = $(name);
|
|
|
|
|
|
|
|
node.calendar = new skycalendar(node);
|
|
|
|
node.calendar.setCalendarPage(ResourcesURL + "/skycalendar.html");
|
2006-08-19 00:40:04 +02:00
|
|
|
var dateFormat = node.getAttribute("dateFormat");
|
2006-08-31 01:13:18 +02:00
|
|
|
if (dateFormat)
|
|
|
|
node.calendar.setDateFormat(dateFormat);
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-08-31 01:13:18 +02:00
|
|
|
function popupCalendar(node)
|
|
|
|
{
|
|
|
|
var nodeId = node.getAttribute("inputId");
|
|
|
|
var input = $(nodeId);
|
|
|
|
input.calendar.popup();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onAppointmentContextMenu(event, element)
|
|
|
|
{
|
2006-12-19 18:06:07 +01:00
|
|
|
var topNode = $("appointmentsList");
|
2006-10-17 00:35:22 +02:00
|
|
|
// log(topNode);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-12-19 18:06:07 +01:00
|
|
|
var menu = $("appointmentsListMenu");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
menu.addEventListener("hideMenu", onAppointmentContextMenuHide, false);
|
2006-12-19 18:06:07 +01:00
|
|
|
onMenuClick(event, "appointmentsListMenu");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-12-19 18:06:07 +01:00
|
|
|
var topNode = $("appointmentsList");
|
2006-08-22 00:36:33 +02:00
|
|
|
var selectedNodes = topNode.getSelectedRows();
|
|
|
|
topNode.menuSelectedRows = selectedNodes;
|
|
|
|
for (var i = 0; i < selectedNodes.length; i++)
|
2006-12-20 23:55:54 +01:00
|
|
|
selectedNodes[i].deselect();
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
topNode.menuSelectedEntry = element;
|
2006-12-20 23:55:54 +01:00
|
|
|
element.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onAppointmentContextMenuHide(event)
|
|
|
|
{
|
2006-12-19 18:06:07 +01:00
|
|
|
var topNode = $("appointmentsList");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
if (topNode.menuSelectedEntry) {
|
2006-12-20 23:55:54 +01:00
|
|
|
topNode.menuSelectedEntry.deselect();
|
2006-08-19 00:40:04 +02:00
|
|
|
topNode.menuSelectedEntry = null;
|
|
|
|
}
|
|
|
|
if (topNode.menuSelectedRows) {
|
|
|
|
var nodeIds = topNode.menuSelectedRows;
|
|
|
|
for (var i = 0; i < nodeIds.length; i++) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var node = $(nodeIds[i]);
|
2006-12-20 23:55:54 +01:00
|
|
|
node.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
topNode.menuSelectedRows = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onAppointmentsSelectionChange() {
|
2006-11-13 23:31:41 +01:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
2006-10-12 23:05:32 +02:00
|
|
|
$("tasksList").addClassName("_unfocused");
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onTasksSelectionChange() {
|
2006-11-13 23:31:41 +01:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
2006-10-12 23:05:32 +02:00
|
|
|
$("appointmentsList").addClassName("_unfocused");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function _loadAppointmentHref(href) {
|
2006-08-24 23:14:18 +02:00
|
|
|
if (document.appointmentsListAjaxRequest) {
|
|
|
|
document.appointmentsListAjaxRequest.aborted = true;
|
|
|
|
document.appointmentsListAjaxRequest.abort();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
var url = ApplicationBaseURL + href;
|
2006-08-24 23:14:18 +02:00
|
|
|
document.appointmentsListAjaxRequest
|
2006-11-15 01:10:53 +01:00
|
|
|
= triggerAjaxRequest(url, appointmentsListCallback, href);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function _loadTasksHref(href) {
|
|
|
|
if (document.tasksListAjaxRequest) {
|
|
|
|
document.tasksListAjaxRequest.aborted = true;
|
|
|
|
document.tasksListAjaxRequest.abort();
|
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
url = ApplicationBaseURL + href;
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
var selectedIds = $("tasksList").getSelectedNodesId();
|
|
|
|
document.tasksListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, tasksListCallback, selectedIds);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onHeaderClick(event) {
|
2006-12-14 22:20:13 +01:00
|
|
|
// log("onHeaderClick: " + this.link);
|
2006-11-09 23:55:04 +01:00
|
|
|
_loadAppointmentHref(this.link);
|
|
|
|
|
|
|
|
event.preventDefault();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function refreshAppointments() {
|
2006-08-24 23:14:18 +02:00
|
|
|
return _loadAppointmentHref("aptlist?desc=" + sortOrder
|
|
|
|
+ "&sort=" + sortKey
|
|
|
|
+ "&day=" + currentDay
|
|
|
|
+ "&filterpopup=" + listFilter);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function refreshTasks() {
|
|
|
|
return _loadTasksHref("taskslist?hide-completed=" + hideCompletedTasks);
|
|
|
|
}
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
function refreshAppointmentsAndDisplay()
|
|
|
|
{
|
|
|
|
refreshAppointments();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
function onListFilterChange() {
|
2006-08-24 20:48:33 +02:00
|
|
|
var node = $("filterpopup");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
listFilter = node.value;
|
|
|
|
// log ("listFilter = " + listFilter);
|
|
|
|
|
|
|
|
return refreshAppointments();
|
|
|
|
}
|
2006-08-22 21:18:30 +02:00
|
|
|
|
|
|
|
function onAppointmentClick(event)
|
|
|
|
{
|
|
|
|
var node = event.target.getParentWithTagName("tr");
|
2006-09-07 00:27:46 +02:00
|
|
|
var day = node.getAttribute("day");
|
2006-10-11 20:12:02 +02:00
|
|
|
var hour = node.getAttribute("hour");
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": day, "hour": hour} );
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
2006-08-22 21:18:30 +02:00
|
|
|
|
|
|
|
return onRowClick(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectMonthInMenu(menu, month)
|
|
|
|
{
|
2006-10-17 00:35:22 +02:00
|
|
|
var entries = menu.childNodes[1].childNodesWithTag("LI");
|
2006-08-22 21:18:30 +02:00
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
2006-10-17 00:35:22 +02:00
|
|
|
var entryMonth = entry.getAttribute("month");
|
|
|
|
if (entryMonth == month)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectYearInMenu(menu, month)
|
|
|
|
{
|
|
|
|
var entries = menu.childNodes[1].childNodes;
|
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
|
|
|
if (entry instanceof HTMLLIElement) {
|
|
|
|
var entryMonth = entry.innerHTML;
|
|
|
|
if (entryMonth == month)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function popupMonthMenu(event, menuId)
|
|
|
|
{
|
|
|
|
var node = event.target;
|
|
|
|
|
|
|
|
if (event.button == 0) {
|
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
|
|
|
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(event, document.currentPopupMenu);
|
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
var popup = $(menuId);
|
2006-08-22 21:18:30 +02:00
|
|
|
var id = node.getAttribute("id");
|
|
|
|
if (id == "monthLabel")
|
|
|
|
selectMonthInMenu(popup, node.getAttribute("month"));
|
|
|
|
else
|
|
|
|
selectYearInMenu(popup, node.innerHTML);
|
|
|
|
|
|
|
|
var diff = (popup.offsetWidth - node.offsetWidth) /2;
|
|
|
|
|
|
|
|
popup.style.top = (node.offsetTop + 95) + "px";
|
|
|
|
popup.style.left = (node.offsetLeft - diff) + "px";
|
|
|
|
popup.style.visibility = "visible";
|
|
|
|
|
|
|
|
bodyOnClick = "" + document.body.getAttribute("onclick");
|
|
|
|
document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');");
|
|
|
|
document.currentPopupMenu = popup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMonthMenuItemClick(node)
|
|
|
|
{
|
|
|
|
var month = '' + node.getAttribute("month");
|
2006-08-24 20:48:33 +02:00
|
|
|
var year = '' + $("yearLabel").innerHTML;
|
2006-09-07 00:27:46 +02:00
|
|
|
|
|
|
|
changeDateSelectorDisplay(year+month+"01", true);
|
2006-08-22 21:18:30 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onYearMenuItemClick(node) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var month = '' + $("monthLabel").getAttribute("month");;
|
2006-08-22 21:18:30 +02:00
|
|
|
var year = '' + node.innerHTML;
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(year+month+"01", true);
|
2006-08-22 21:18:30 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-08-31 01:13:18 +02:00
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onSearchFormSubmit() {
|
2006-08-31 01:13:18 +02:00
|
|
|
log ("search not implemented");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onCalendarSelectAppointment() {
|
2006-09-07 00:27:46 +02:00
|
|
|
var list = $("appointmentsList");
|
|
|
|
list.deselectAll();
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
var aptCName = this.getAttribute("aptCName");
|
2007-01-30 14:50:52 +01:00
|
|
|
if (selectedCalendarCell)
|
|
|
|
selectedCalendarCell.deselect();
|
|
|
|
this.select();
|
|
|
|
selectedCalendarCell = this;
|
2006-10-11 20:12:02 +02:00
|
|
|
var row = $(aptCName);
|
2006-11-03 00:17:55 +01:00
|
|
|
if (row) {
|
|
|
|
var div = row.parentNode.parentNode.parentNode;
|
|
|
|
div.scrollTop = row.offsetTop - (div.offsetHeight / 2);
|
2006-12-20 23:55:54 +01:00
|
|
|
row.select();
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onCalendarSelectDay(event) {
|
2007-02-13 23:01:02 +01:00
|
|
|
var day;
|
|
|
|
if (currentView == "multicolumndayview")
|
|
|
|
day = this.parentNode.getAttribute("day");
|
|
|
|
else
|
|
|
|
day = this.getAttribute("day");
|
2006-11-15 22:54:47 +01:00
|
|
|
var needRefresh = (listFilter == 'view_selectedday'
|
|
|
|
&& day != currentDay);
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2006-11-03 00:17:55 +01:00
|
|
|
if (currentView == 'weekview')
|
2006-11-15 01:10:53 +01:00
|
|
|
changeWeekCalendarDisplayOfSelectedDay(this);
|
2006-11-03 00:17:55 +01:00
|
|
|
else if (currentView == 'monthview')
|
2006-11-15 01:10:53 +01:00
|
|
|
changeMonthCalendarDisplayOfSelectedDay(this);
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
|
2007-01-30 19:18:30 +01:00
|
|
|
if (listOfSelection) {
|
|
|
|
listOfSelection.addClassName("_unfocused");
|
|
|
|
listOfSelection = null;
|
|
|
|
}
|
|
|
|
|
2006-11-15 22:54:47 +01:00
|
|
|
if (needRefresh)
|
|
|
|
refreshAppointments();
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function changeWeekCalendarDisplayOfSelectedDay(node) {
|
2006-11-15 01:10:53 +01:00
|
|
|
var days = document.getElementsByClassName("day", node.parentNode);
|
2006-10-31 23:59:57 +01:00
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
for (var i = 0; i < days.length; i++)
|
|
|
|
if (days[i] != node)
|
|
|
|
days[i].removeClassName("selectedDay");
|
|
|
|
|
|
|
|
node.addClassName("selectedDay");
|
2006-10-31 23:59:57 +01:00
|
|
|
}
|
|
|
|
|
2006-11-03 00:17:55 +01:00
|
|
|
function findMonthCalendarSelectedCell(table) {
|
|
|
|
var tbody = table.tBodies[0];
|
|
|
|
var rows = tbody.rows;
|
|
|
|
|
|
|
|
var i = 1;
|
|
|
|
while (i < rows.length && !table.selectedCell) {
|
|
|
|
var cells = rows[i].cells;
|
|
|
|
var j = 0;
|
|
|
|
while (j < cells.length && !table.selectedCell) {
|
|
|
|
if (cells[j].hasClassName("selectedDay"))
|
|
|
|
table.selectedCell = cells[j];
|
|
|
|
else
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeMonthCalendarDisplayOfSelectedDay(node)
|
|
|
|
{
|
|
|
|
var tr = node.parentNode;
|
|
|
|
var table = tr.parentNode.parentNode;
|
|
|
|
|
|
|
|
if (!table.selectedCell)
|
|
|
|
findMonthCalendarSelectedCell(table);
|
|
|
|
|
|
|
|
if (table.selectedCell)
|
|
|
|
table.selectedCell.removeClassName("selectedDay");
|
|
|
|
table.selectedCell = node;
|
|
|
|
node.addClassName("selectedDay");
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function onHideCompletedTasks(node)
|
|
|
|
{
|
|
|
|
hideCompletedTasks = (node.checked ? 1 : 0);
|
|
|
|
|
|
|
|
return refreshTasks();
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateTaskStatus(node)
|
|
|
|
{
|
|
|
|
var taskId = node.parentNode.getAttribute("id");
|
2006-10-17 21:49:47 +02:00
|
|
|
var taskOwner = node.parentNode.getAttribute("owner");
|
2006-10-11 20:12:02 +02:00
|
|
|
var newStatus = (node.checked ? 1 : 0);
|
2006-10-17 21:49:47 +02:00
|
|
|
// log ("update task status: " + taskId);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
var http = createHTTPClient();
|
|
|
|
|
2006-10-17 21:49:47 +02:00
|
|
|
url = (UserFolderURL + "../" + taskOwner + "/Calendar/"
|
|
|
|
+ taskId + "/changeStatus?status=" + newStatus);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
if (http) {
|
2006-10-17 21:49:47 +02:00
|
|
|
// log ("url: " + url);
|
2006-10-11 20:12:02 +02:00
|
|
|
// TODO: add parameter to signal that we are only interested in OK
|
|
|
|
http.url = url;
|
|
|
|
http.open("GET", url, false /* not async */);
|
|
|
|
http.send("");
|
|
|
|
if (http.status == 200)
|
|
|
|
refreshTasks();
|
2006-10-17 21:49:47 +02:00
|
|
|
} else
|
|
|
|
log ("no http client?");
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
|
2006-10-17 17:50:43 +02:00
|
|
|
function updateCalendarStatus()
|
2006-10-14 01:37:27 +02:00
|
|
|
{
|
|
|
|
var list = new Array();
|
|
|
|
|
|
|
|
var clist = $("calendarsList");
|
2006-10-17 17:50:43 +02:00
|
|
|
var nodes = clist.childNodesWithTag("ul")[0].childNodesWithTag("li");
|
2006-10-14 01:37:27 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2006-10-17 17:50:43 +02:00
|
|
|
var input = nodes[i].childNodesWithTag("input")[0];
|
|
|
|
if (input.checked)
|
|
|
|
list.push(nodes[i].getAttribute("uid"));
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2006-10-17 17:50:43 +02:00
|
|
|
if (!list.length) {
|
|
|
|
list.push(nodes[0].getAttribute("uid"));
|
|
|
|
nodes[0].childNodesWithTag("input")[0].checked = true;
|
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
// ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
|
|
|
|
// + list.join(",") + "/Calendar/");
|
2006-10-14 01:37:27 +02:00
|
|
|
|
2006-12-19 18:06:07 +01:00
|
|
|
updateCalendarsList();
|
2006-10-14 01:37:27 +02:00
|
|
|
refreshAppointments();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function calendarUidsList()
|
|
|
|
{
|
|
|
|
var list = "";
|
|
|
|
|
2006-12-20 17:45:52 +01:00
|
|
|
var nodes = $("uixselector-calendarsList-display").childNodesWithTag("li");
|
2006-10-14 01:37:27 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var currentNode = nodes[i];
|
2006-10-17 00:35:22 +02:00
|
|
|
var input = currentNode.childNodesWithTag("input")[0];
|
|
|
|
if (!input.checked)
|
|
|
|
list += "-";
|
|
|
|
list += currentNode.getAttribute("uid") + ",";
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return list.substr(0, list.length - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// function updateCalendarContacts(contacts)
|
|
|
|
// {
|
|
|
|
// var list = contacts.split(",");
|
|
|
|
|
|
|
|
// var clist = $("calendarsList");
|
|
|
|
// var nodes = clist.childNodes[5].childNodes;
|
|
|
|
// for (var i = 0; i < nodes.length; i++) {
|
|
|
|
// var currentNode = nodes[i];
|
|
|
|
// if (currentNode instanceof HTMLLIElement) {
|
2006-10-16 20:51:53 +02:00
|
|
|
// var input = currentNode.childNodes[3];
|
2006-10-14 01:37:27 +02:00
|
|
|
// if (!input.checked)
|
|
|
|
// list += "-";
|
|
|
|
// list += currentNode.getAttribute("uid") + ",";
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
function inhibitMyCalendarEntry()
|
|
|
|
{
|
|
|
|
var clist = $("calendarsList");
|
|
|
|
var nodes = clist.childNodes[5].childNodes;
|
|
|
|
var done = false;
|
|
|
|
|
|
|
|
var i = 0;
|
|
|
|
while (!done && i < nodes.length) {
|
|
|
|
var currentNode = nodes[i];
|
|
|
|
if (currentNode instanceof HTMLLIElement) {
|
2006-10-16 20:51:53 +02:00
|
|
|
var input = currentNode.childNodes[3];
|
2006-10-14 01:37:27 +02:00
|
|
|
if (currentNode.getAttribute("uid") == UserLogin) {
|
|
|
|
done = true;
|
2006-12-15 23:23:38 +01:00
|
|
|
// currentNode.style.color = "#999;";
|
2006-10-14 01:37:27 +02:00
|
|
|
currentNode.style.fontWeight = "bold;";
|
2006-12-15 23:23:38 +01:00
|
|
|
// currentNode.setAttribute("onclick", "");
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-20 17:45:52 +01:00
|
|
|
function userCalendarEntry(user, color) {
|
|
|
|
var li = document.createElement("li");
|
|
|
|
li.setAttribute("uid", user);
|
|
|
|
li.addEventListener("mousedown", listRowMouseDownHandler, false);
|
|
|
|
li.addEventListener("click", onRowClick, false);
|
|
|
|
var colorBox = document.createElement("span");
|
|
|
|
colorBox.addClassName("colorBox");
|
|
|
|
if (color) {
|
|
|
|
log("color: " + color);
|
|
|
|
colorBox.style.backgroundColor = color + ";";
|
|
|
|
}
|
|
|
|
li.appendChild(colorBox);
|
|
|
|
var checkBox = document.createElement("input");
|
|
|
|
checkBox.addClassName("checkBox");
|
|
|
|
checkBox.type = "checkbox";
|
|
|
|
checkBox.addEventListener("change", updateCalendarStatus, false);
|
|
|
|
li.appendChild(checkBox);
|
|
|
|
var text = document.createTextNode(" " + user);
|
|
|
|
li.appendChild(text);
|
|
|
|
|
|
|
|
return li;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ensureSelfIfPresent() {
|
|
|
|
var ul = $("uixselector-calendarsList-display");
|
|
|
|
var list = ul.childNodesWithTag("li");
|
|
|
|
var selfEntry = userCalendarEntry(UserLogin, indexColor(0));
|
|
|
|
selfEntry.style.fontWeight = "bold;";
|
|
|
|
if (list.length < 1) {
|
|
|
|
ul.appendChild(selfEntry);
|
|
|
|
} else if (list[0].getAttribute("uid") != UserLogin) {
|
|
|
|
ul.insertBefore(selfEntry, list[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-17 17:50:43 +02:00
|
|
|
function updateCalendarsList(method)
|
2006-10-14 01:37:27 +02:00
|
|
|
{
|
2006-12-20 17:45:52 +01:00
|
|
|
ensureSelfIfPresent();
|
2006-10-14 01:37:27 +02:00
|
|
|
var url = (ApplicationBaseURL + "updateCalendars?ids="
|
|
|
|
+ calendarUidsList());
|
|
|
|
if (document.calendarsListAjaxRequest) {
|
|
|
|
document.calendarsListAjaxRequest.aborted = true;
|
|
|
|
document.calendarsListAjaxRequest.abort();
|
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
var http = createHTTPClient();
|
|
|
|
if (http) {
|
|
|
|
http.url = url;
|
|
|
|
http.open("GET", url, false);
|
|
|
|
http.send("");
|
|
|
|
|
|
|
|
if (method == "removal")
|
|
|
|
updateCalendarStatus();
|
2006-12-19 21:59:17 +01:00
|
|
|
|
|
|
|
http = createHTTPClient();
|
|
|
|
http.url = ApplicationBaseURL + "checkRights";
|
|
|
|
http.open("GET", http.url, false /* not async */);
|
|
|
|
http.send("");
|
|
|
|
if (http.status == 200
|
|
|
|
&& http.responseText.length > 0) {
|
|
|
|
rights = http.responseText.split(",");
|
|
|
|
var list = $("uixselector-calendarsList-display").childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var input = list[i].childNodesWithTag("input")[0];
|
|
|
|
if (rights[i] == "1") {
|
|
|
|
list[i].removeClassName("denied");
|
|
|
|
input.disabled = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
input.checked = false;
|
|
|
|
input.disabled = true;
|
|
|
|
list[i].addClassName("denied");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function addContact(tag, fullContactName, contactId, contactName, contactEmail)
|
|
|
|
{
|
2006-12-19 18:06:07 +01:00
|
|
|
var uids = $("uixselector-calendarsList-uidList");
|
2006-10-17 00:35:22 +02:00
|
|
|
// log("addContact");
|
2006-10-14 01:37:27 +02:00
|
|
|
if (contactId)
|
|
|
|
{
|
|
|
|
var re = new RegExp("(^|,)" + contactId + "($|,)");
|
|
|
|
|
|
|
|
if (!re.test(uids.value))
|
|
|
|
{
|
|
|
|
if (uids.value.length > 0)
|
|
|
|
uids.value += ',' + contactId;
|
|
|
|
else
|
|
|
|
uids.value = contactId;
|
2006-12-19 21:59:17 +01:00
|
|
|
var names = $("uixselector-calendarsList-display");
|
2006-12-19 18:06:07 +01:00
|
|
|
var listElems = names.childNodesWithTag("li");
|
2006-12-20 17:45:52 +01:00
|
|
|
var colorDef = indexColor(listElems.length);
|
|
|
|
names.appendChild(userCalendarEntry(contactId, colorDef));
|
2006-10-17 00:35:22 +02:00
|
|
|
|
|
|
|
var styles = document.getElementsByTagName("style");
|
|
|
|
styles[0].innerHTML += ('.ownerIs' + contactId + ' {'
|
2006-12-19 18:06:07 +01:00
|
|
|
+ ' background-color: '
|
2006-12-19 21:59:17 +01:00
|
|
|
+ colorDef
|
2006-10-17 00:35:22 +02:00
|
|
|
+ ' !important; }');
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-19 16:41:32 +02:00
|
|
|
|
|
|
|
function onChangeCalendar(list) {
|
|
|
|
var form = document.forms.editform;
|
|
|
|
var urlElems = form.getAttribute("action").split("/");
|
|
|
|
urlElems[urlElems.length-4]
|
|
|
|
= list.childNodesWithTag("option")[list.value].innerHTML;
|
|
|
|
form.setAttribute("action", urlElems.join("/"));
|
|
|
|
}
|
2006-10-23 23:37:53 +02:00
|
|
|
|
|
|
|
function validateBrowseURL(input) {
|
2006-12-14 22:20:13 +01:00
|
|
|
var button = $("browseURLBtn");
|
2006-10-23 23:37:53 +02:00
|
|
|
|
|
|
|
if (input.value.length) {
|
|
|
|
if (!button.enabled)
|
|
|
|
enableAnchor(button);
|
|
|
|
} else if (!button.disabled)
|
|
|
|
disableAnchor(button);
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function browseURL(anchor, event) {
|
2006-10-23 23:37:53 +02:00
|
|
|
if (event.button == 0) {
|
|
|
|
var input = $("url");
|
|
|
|
var url = input.value;
|
|
|
|
if (url.length)
|
|
|
|
window.open(url, '_blank');
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function initializeMenus() {
|
|
|
|
var menus = new Array("monthListMenu", "yearListMenu",
|
|
|
|
"appointmentsListMenu", "calendarsMenu", "searchMenu");
|
|
|
|
initMenusNamed(menus);
|
|
|
|
|
2006-12-22 17:48:11 +01:00
|
|
|
$("calendarsList").attachMenu("calendarsMenu");
|
2006-12-14 22:20:13 +01:00
|
|
|
|
|
|
|
var accessRightsMenuEntry = $("accessRightsMenuEntry");
|
|
|
|
accessRightsMenuEntry.addEventListener("mouseup",
|
|
|
|
onAccessRightsMenuEntryMouseUp,
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onAccessRightsMenuEntryMouseUp(event) {
|
|
|
|
var folders = $("uixselector-calendarsList-display");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
|
|
|
var uid = selected.getAttribute("uid");
|
2006-12-15 23:23:38 +01:00
|
|
|
log("application base url: " + ApplicationBaseURL);
|
2006-12-14 22:20:13 +01:00
|
|
|
if (uid == UserLogin)
|
2006-12-15 16:15:14 +01:00
|
|
|
url = ApplicationBaseURL + "acls";
|
2006-12-14 22:20:13 +01:00
|
|
|
else
|
2006-12-15 16:15:14 +01:00
|
|
|
url = UserFolderURL + "../" + uid + "/Calendar/acls";
|
2006-12-14 22:20:13 +01:00
|
|
|
|
|
|
|
openAclWindow(url, uid);
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function configureDragHandles() {
|
|
|
|
var handle = $("verticalDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.leftBlock=$("leftPanel");
|
|
|
|
handle.rightBlock=$("rightPanel");
|
|
|
|
}
|
|
|
|
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.upperBlock=$("appointmentsListView");
|
|
|
|
handle.lowerBlock=$("calendarView");
|
|
|
|
}
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
|
|
|
|
function initCalendarContactsSelector() {
|
|
|
|
var selector = $("calendarsList");
|
|
|
|
inhibitMyCalendarEntry();
|
|
|
|
updateCalendarStatus();
|
|
|
|
selector.changeNotification = updateCalendarsList;
|
2006-12-19 18:06:07 +01:00
|
|
|
|
|
|
|
var list = $("uixselector-calendarsList-display").childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var input = list[i].childNodesWithTag("input")[0];
|
2006-12-19 21:59:17 +01:00
|
|
|
input.addEventListener("change", updateCalendarStatus, false);
|
2006-12-19 18:06:07 +01:00
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function initCalendars() {
|
|
|
|
if (!document.body.hasClassName("popup"))
|
|
|
|
initCalendarContactsSelector();
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("load", initCalendars, false);
|