2006-08-19 00:40:04 +02:00
|
|
|
var activeAjaxRequests = 0;
|
|
|
|
|
|
|
|
var sortOrder = '';
|
|
|
|
var sortKey = '';
|
2006-08-22 00:36:33 +02:00
|
|
|
var listFilter = 'view_all';
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
function triggerAjaxRequest(url, callback, userdata) {
|
|
|
|
this.http = createHTTPClient();
|
|
|
|
|
|
|
|
activeAjaxRequests += 1;
|
|
|
|
document.animTimer = setTimeout("checkAjaxRequestsState();", 200);
|
|
|
|
|
|
|
|
if (http) {
|
|
|
|
http.onreadystatechange
|
|
|
|
= function() {
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("state changed (" + http.readyState + "): " + url);
|
2006-08-19 00:40:04 +02:00
|
|
|
try {
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& activeAjaxRequests > 0) {
|
|
|
|
if (!http.aborted) {
|
|
|
|
http.callbackData = userdata;
|
|
|
|
callback(http);
|
|
|
|
}
|
|
|
|
activeAjaxRequests -= 1;
|
|
|
|
checkAjaxRequestsState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( e ) {
|
|
|
|
activeAjaxRequests -= 1;
|
|
|
|
checkAjaxRequestsState();
|
|
|
|
alert('AJAX Request, Caught Exception: ' + e.description);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
http.url = url;
|
|
|
|
http.open("GET", url, true);
|
|
|
|
http.send("");
|
|
|
|
}
|
|
|
|
|
|
|
|
return http;
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkAjaxRequestsState()
|
|
|
|
{
|
|
|
|
if (activeAjaxRequests > 0
|
|
|
|
&& !document.busyAnim) {
|
|
|
|
var anim = document.createElement("img");
|
|
|
|
document.busyAnim = anim;
|
|
|
|
anim.setAttribute("src", ResourcesURL + '/busy.gif');
|
|
|
|
anim.style.position = "absolute;";
|
|
|
|
anim.style.top = "2.5em;";
|
|
|
|
anim.style.right = "1em;";
|
|
|
|
anim.style.visibility = "hidden;";
|
|
|
|
anim.style.zindex = "1;";
|
|
|
|
var folderTree = document.getElementById("toolbar");
|
|
|
|
folderTree.appendChild(anim);
|
|
|
|
anim.style.visibility = "visible;";
|
|
|
|
} else if (activeAjaxRequests == 0
|
|
|
|
&& document.busyAnim) {
|
|
|
|
document.busyAnim.parentNode.removeChild(document.busyAnim);
|
|
|
|
document.busyAnim = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var currentDay = '';
|
|
|
|
var currentView = 'day';
|
|
|
|
|
2006-08-14 22:32:30 +02:00
|
|
|
function newEvent(sender) {
|
2006-08-15 22:52:23 +02:00
|
|
|
var urlstr = ApplicationBaseURL + "new";
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
window.open(urlstr, "",
|
2006-08-14 22:32:30 +02:00
|
|
|
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0," +
|
|
|
|
"location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
|
|
|
|
|
|
|
function _editEventId(id) {
|
|
|
|
var urlstr = ApplicationBaseURL + id + "/edit";
|
|
|
|
|
|
|
|
var win = window.open(urlstr, "SOGo_edit_" + id,
|
|
|
|
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0," +
|
|
|
|
"location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
|
|
|
win.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
function editEvent() {
|
|
|
|
var list = document.getElementById("appointmentsList");
|
|
|
|
var nodes = list.getSelectedRowsId();
|
|
|
|
|
|
|
|
if (nodes.length > 0) {
|
|
|
|
var row = nodes[0];
|
|
|
|
_editEventId(row);
|
|
|
|
}
|
|
|
|
|
2006-08-14 22:32:30 +02:00
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
function editDoubleClickedEvent(node)
|
|
|
|
{
|
|
|
|
var id = node.getAttribute("id");
|
|
|
|
_editEventId(id);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-08-15 22:52:23 +02:00
|
|
|
function displayAppointment(sender) {
|
|
|
|
var aptId = sender.getAttribute("aptId");
|
|
|
|
var urlstr = ApplicationBaseURL + aptId + "/view";
|
|
|
|
|
|
|
|
var win = window.open(urlstr, "SOGo_view_" + aptId,
|
|
|
|
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0," +
|
|
|
|
"location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
|
|
|
win.focus();
|
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
|
|
|
|
2006-08-14 22:32:30 +02:00
|
|
|
function onContactRefresh(node)
|
|
|
|
{
|
|
|
|
var parentNode = node.parentNode;
|
|
|
|
var contacts = '';
|
|
|
|
var done = false;
|
|
|
|
|
|
|
|
var currentNode = parentNode.firstChild;
|
|
|
|
while (currentNode && !done)
|
|
|
|
{
|
|
|
|
if (currentNode.nodeType == 1
|
|
|
|
&& currentNode.getAttribute("type") == "hidden")
|
|
|
|
{
|
|
|
|
contacts = currentNode.value;
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
currentNode = currentNode.nextSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
log ('contacts: ' + contacts);
|
|
|
|
if (contacts.length > 0)
|
|
|
|
window.location = ApplicationBaseURL + '/show?userUIDString=' + contacts;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
function onDaySelect(node)
|
|
|
|
{
|
|
|
|
currentDay = node.getAttribute("day");
|
|
|
|
|
|
|
|
var td = node.getParentWithTagName("td");
|
|
|
|
var table = td.getParentWithTagName("table");
|
|
|
|
|
|
|
|
// log ("table.selected: " + table.selected);
|
|
|
|
|
|
|
|
if (document.selectedDate)
|
|
|
|
deselectNode(document.selectedDate);
|
|
|
|
|
|
|
|
selectNode(td);
|
|
|
|
document.selectedDate = td;
|
|
|
|
|
|
|
|
changeDayDisplay(currentDay, null);
|
2006-08-22 00:36:33 +02:00
|
|
|
if (listFilter == 'view_selectedday')
|
|
|
|
refreshAppointments();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDateSelectorGotoMonth(node)
|
|
|
|
{
|
|
|
|
var day = node.getAttribute("date");
|
|
|
|
|
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarGotoDay(node)
|
|
|
|
{
|
|
|
|
var day = node.getAttribute("date");
|
|
|
|
|
|
|
|
changeDayDisplay(day);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function gotoToday()
|
|
|
|
{
|
|
|
|
changeDayDisplay();
|
2006-08-22 00:36:33 +02:00
|
|
|
changeDateSelectorDisplay();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function dateSelectorCallback(http)
|
|
|
|
{
|
|
|
|
var div = document.getElementById("dateSelectorView");
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
log ("dateselectorcallback: " + div);
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.dateSelectorAjaxRequest = null;
|
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
if (currentDay.length > 0)
|
|
|
|
restoreCurrentDaySelection(div);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
|
|
|
function appointmentsListCallback(http)
|
|
|
|
{
|
|
|
|
var div = document.getElementById("appointmentsListView");
|
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("babla");
|
2006-08-19 00:40:04 +02:00
|
|
|
document.dateSelectorAjaxRequest = null;
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("babla");
|
2006-08-19 00:40:04 +02:00
|
|
|
div.innerHTML = http.responseText;
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("babla");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("received " + http.callbackData);
|
2006-08-19 00:40:04 +02:00
|
|
|
var params = parseQueryParameters(http.callbackData);
|
|
|
|
sortKey = params["sort"];
|
|
|
|
sortOrder = params["desc"];
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("sorting = " + sortKey + sortOrder);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
|
|
|
function restoreCurrentDaySelection(div)
|
|
|
|
{
|
|
|
|
var elements = div.getElementsByTagName("a");
|
|
|
|
var day = null;
|
|
|
|
var i = 7;
|
|
|
|
while (!day && i < elements.length)
|
|
|
|
{
|
|
|
|
day = elements[i].getAttribute("day");
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (day
|
|
|
|
&& day.substr(0, 6) == currentDay.substr(0, 6))
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
deselectNode(document.selectedDate);
|
|
|
|
selectNode(td);
|
|
|
|
document.selectedDate = td;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeDateSelectorDisplay(day, event)
|
|
|
|
{
|
|
|
|
var url = ApplicationBaseURL + "dateselector";
|
|
|
|
if (day)
|
|
|
|
url += "?day=" + day;
|
|
|
|
|
|
|
|
// if (currentDay.length > 0)
|
|
|
|
// url += '&selectedDay=' + currentDay;
|
2006-08-22 00:36:33 +02:00
|
|
|
log ("changeDateSelectorDisplay: " + url);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
if (document.dateSelectorAjaxRequest) {
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("aborting dateselector ajaxrq");
|
2006-08-19 00:40:04 +02:00
|
|
|
document.dateSelectorAjaxRequest.aborted = true;
|
|
|
|
document.dateSelectorAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
document.dateSelectorAjaxRequest = triggerAjaxRequest(url,
|
|
|
|
dateSelectorCallback,
|
|
|
|
null);
|
|
|
|
// log ('should go to ' + day);
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeDayDisplay(day, event)
|
|
|
|
{
|
|
|
|
var url = ApplicationBaseURL + "dayview";
|
|
|
|
|
|
|
|
if (day)
|
|
|
|
url += "?day=" + day;
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
log ("changeDayDisplay: " + url);
|
|
|
|
|
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,
|
|
|
|
dayDisplayCallback,
|
|
|
|
null);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function dayDisplayCallback(http)
|
|
|
|
{
|
|
|
|
var div = document.getElementById("calendarView");
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
log ("daydisplaycallback: " + div);
|
2006-08-19 00:40:04 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.dateSelectorAjaxRequest = null;
|
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
|
|
|
function popupCalendar(node)
|
|
|
|
{
|
|
|
|
var inputId = node.getAttribute("inputId");
|
|
|
|
var dateFormat = node.getAttribute("dateFormat");
|
|
|
|
|
|
|
|
var calendar = new skycalendar(document.getElementById(inputId));
|
|
|
|
calendar.setCalendarPage(ResourcesURL + "/skycalendar.html");
|
|
|
|
calendar.setDateFormat(dateFormat);
|
|
|
|
calendar.popup();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onAppointmentContextMenu(event, element)
|
|
|
|
{
|
|
|
|
var topNode = document.getElementById('appointmentsList');
|
|
|
|
log(topNode);
|
|
|
|
|
|
|
|
var menu = document.getElementById('appointmentsListMenu');
|
|
|
|
|
|
|
|
menu.addEventListener("hideMenu", onAppointmentContextMenuHide, false);
|
|
|
|
onMenuClick(event, 'appointmentsListMenu');
|
|
|
|
|
|
|
|
var topNode = document.getElementById('appointmentsList');
|
2006-08-22 00:36:33 +02:00
|
|
|
var selectedNodes = topNode.getSelectedRows();
|
|
|
|
topNode.menuSelectedRows = selectedNodes;
|
|
|
|
for (var i = 0; i < selectedNodes.length; i++)
|
|
|
|
deselectNode (selectedNodes[i]);
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
topNode.menuSelectedEntry = element;
|
|
|
|
selectNode(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onAppointmentContextMenuHide(event)
|
|
|
|
{
|
|
|
|
var topNode = document.getElementById('appointmentsList');
|
|
|
|
|
|
|
|
if (topNode.menuSelectedEntry) {
|
|
|
|
deselectNode(topNode.menuSelectedEntry);
|
|
|
|
topNode.menuSelectedEntry = null;
|
|
|
|
}
|
|
|
|
if (topNode.menuSelectedRows) {
|
|
|
|
var nodeIds = topNode.menuSelectedRows;
|
|
|
|
for (var i = 0; i < nodeIds.length; i++) {
|
|
|
|
var node = document.getElementById(nodeIds[i]);
|
|
|
|
selectNode (node);
|
|
|
|
}
|
|
|
|
topNode.menuSelectedRows = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onAppointmentsSelectionChange()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
function _loadAppointmentHref(href) {
|
|
|
|
if (this.document.appointmentsListAjaxRequest) {
|
|
|
|
this.document.appointmentsListAjaxRequest.aborted = true;
|
|
|
|
this.document.appointmentsListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
url = ApplicationBaseURL + href;
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("url: " + url);
|
2006-08-19 00:40:04 +02:00
|
|
|
this.document.appointmentsListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, appointmentsListCallback, href);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onHeaderClick(node)
|
|
|
|
{
|
|
|
|
var href = node.getAttribute("href");
|
|
|
|
|
|
|
|
return _loadAppointmentHref(href);
|
|
|
|
}
|
|
|
|
|
|
|
|
function refreshAppointments() {
|
2006-08-22 00:36:33 +02:00
|
|
|
var href = ("aptlist?desc=" + sortOrder
|
|
|
|
+ "&sort=" + sortKey
|
|
|
|
+ "&day=" + currentDay
|
|
|
|
+ "&filterpopup=" + listFilter);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return _loadAppointmentHref(href);
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
function onListFilterChange() {
|
|
|
|
var node = document.getElementById("filterpopup");
|
|
|
|
|
|
|
|
listFilter = node.value;
|
|
|
|
// log ("listFilter = " + listFilter);
|
|
|
|
|
|
|
|
return refreshAppointments();
|
|
|
|
}
|