2006-10-26 01:58:29 +02:00
|
|
|
var resultsDiv;
|
|
|
|
var searchField;
|
|
|
|
var running = false;
|
|
|
|
var address;
|
|
|
|
var delay = 500;
|
|
|
|
var requestField;
|
2006-10-26 18:43:50 +02:00
|
|
|
var awaitingFreeBusyRequests = new Array();
|
2007-03-18 16:00:34 +01:00
|
|
|
var additionalDays = 2;
|
|
|
|
|
|
|
|
var dayStartHour = 8;
|
|
|
|
var dayEndHour = 18;
|
|
|
|
|
|
|
|
var attendeesNames;
|
|
|
|
var attendeesEmails;
|
2006-10-26 01:58:29 +02:00
|
|
|
|
2006-11-13 19:46:00 +01:00
|
|
|
function onContactKeydown(event) {
|
|
|
|
if (event.keyCode == 9) {
|
2007-06-28 20:29:59 +02:00
|
|
|
preventDefault(event);
|
2006-11-13 19:46:00 +01:00
|
|
|
if (this.confirmedValue)
|
|
|
|
this.value = this.confirmedValue;
|
|
|
|
var row = this.parentNode.parentNode.nextSibling;
|
|
|
|
while (!(row instanceof HTMLTableRowElement))
|
|
|
|
row = row.nextSibling;
|
|
|
|
this.blur();
|
2007-05-28 18:12:06 +02:00
|
|
|
var input = $(row.cells[0]).childNodesWithTag("input")[0];
|
2006-11-13 19:46:00 +01:00
|
|
|
if (input.readOnly)
|
|
|
|
newAttendee(null);
|
|
|
|
else {
|
|
|
|
input.focus();
|
|
|
|
input.select();
|
|
|
|
input.focussed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!running) {
|
2006-11-06 18:44:07 +01:00
|
|
|
if (event.keyCode == 8
|
|
|
|
|| event.keyCode == 32
|
|
|
|
|| event.keyCode > 47) {
|
|
|
|
running = true;
|
2006-11-13 19:46:00 +01:00
|
|
|
requestField = this;
|
2007-03-18 16:00:34 +01:00
|
|
|
requestField.setAttribute("modified", "1");
|
2006-11-06 18:44:07 +01:00
|
|
|
setTimeout("triggerRequest()", delay);
|
2006-11-13 19:46:00 +01:00
|
|
|
}
|
|
|
|
else if (this.confirmedValue) {
|
2006-11-09 00:49:21 +01:00
|
|
|
if (event.keyCode == 13) {
|
2006-11-13 19:46:00 +01:00
|
|
|
this.setSelectionRange(this.value.length, this.value.length);
|
2006-11-09 00:49:21 +01:00
|
|
|
}
|
2006-11-06 18:44:07 +01:00
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function triggerRequest() {
|
|
|
|
if (document.contactLookupAjaxRequest) {
|
|
|
|
document.contactLookupAjaxRequest.aborted = yes;
|
|
|
|
document.contactLookupAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var urlstr = ( UserFolderURL + "Contacts/contactSearch?search="
|
|
|
|
+ requestField.value );
|
|
|
|
document.contactLookupAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
updateResults,
|
|
|
|
requestField);
|
|
|
|
}
|
|
|
|
|
2006-11-13 19:46:00 +01:00
|
|
|
function updateResults(http) {
|
2006-10-26 01:58:29 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
var searchField = http.callbackData;
|
|
|
|
var start = searchField.value.length;
|
|
|
|
var text = http.responseText.split(":");
|
|
|
|
if (text[0].length > 0)
|
|
|
|
searchField.uid = text[0];
|
|
|
|
else
|
|
|
|
searchField.uid = null;
|
|
|
|
searchField.hasfreebusy = false;
|
2007-05-09 21:15:18 +02:00
|
|
|
var completeEmail = text[1] + " <" + text[2] + ">";
|
2006-11-06 18:44:07 +01:00
|
|
|
if (text[1].substring(0, searchField.value.length).toUpperCase()
|
|
|
|
== searchField.value.toUpperCase())
|
2007-05-09 21:15:18 +02:00
|
|
|
searchField.value = completeEmail;
|
2006-11-06 18:44:07 +01:00
|
|
|
else {
|
2007-05-09 21:15:18 +02:00
|
|
|
searchField.value += ' >> ' + completeEmail;
|
2006-11-06 18:44:07 +01:00
|
|
|
}
|
2007-05-09 21:15:18 +02:00
|
|
|
searchField.confirmedValue = completeEmail;
|
2006-11-13 19:46:00 +01:00
|
|
|
if (searchField.focussed) {
|
|
|
|
var end = searchField.value.length;
|
|
|
|
searchField.setSelectionRange(start, end);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
searchField.value = text[1];
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
running = false;
|
|
|
|
document.contactLookupAjaxRequest = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-09 21:15:18 +02:00
|
|
|
function UIDLookupCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
var searchField = http.callbackData;
|
|
|
|
var start = searchField.value.length;
|
|
|
|
var text = http.responseText.split(":");
|
2007-05-10 21:02:16 +02:00
|
|
|
if (text[0].length > 0) {
|
|
|
|
searchField.uid = text[0];
|
|
|
|
displayFreeBusyForNode(searchField);
|
|
|
|
}
|
2007-05-09 21:15:18 +02:00
|
|
|
else
|
2007-05-10 21:02:16 +02:00
|
|
|
searchField.uid = null
|
2007-05-09 21:15:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function resetFreeBusyZone() {
|
2007-03-18 16:00:34 +01:00
|
|
|
var table = $("freeBusy");
|
2006-10-26 01:58:29 +02:00
|
|
|
var row = table.tHead.rows[2];
|
2006-10-30 23:43:13 +01:00
|
|
|
for (var i = 1; i < row.cells.length; i++) {
|
2007-05-28 18:12:06 +02:00
|
|
|
var nodes = $(row.cells[i]).childNodesWithTag("span");
|
2006-10-30 23:43:13 +01:00
|
|
|
for (var j = 0; j < nodes.length; j++)
|
|
|
|
nodes[j].removeClassName("busy");
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function redisplayFreeBusyZone() {
|
2007-03-18 16:00:34 +01:00
|
|
|
var table = $("freeBusy");
|
2006-10-26 01:58:29 +02:00
|
|
|
var row = table.tHead.rows[2];
|
2007-03-18 16:00:34 +01:00
|
|
|
var stDay = $("startTime_date").valueAsDate();
|
|
|
|
var etDay = $("endTime_date").valueAsDate();
|
|
|
|
|
2006-10-31 00:33:41 +01:00
|
|
|
var days = stDay.daysUpTo(etDay);
|
|
|
|
var addDays = days.length - 1;
|
2007-03-18 16:00:34 +01:00
|
|
|
var stHour = parseInt($("startTime_time_hour").value);
|
|
|
|
var stMinute = parseInt($("startTime_time_minute").value) / 15;
|
|
|
|
var etHour = parseInt($("endTime_time_hour").value);
|
|
|
|
var etMinute = parseInt($("endTime_time_minute").value) / 15;
|
2006-10-26 01:58:29 +02:00
|
|
|
if (stHour < 8) {
|
|
|
|
stHour = 8;
|
|
|
|
stMinute = 0;
|
|
|
|
}
|
2006-10-31 00:33:41 +01:00
|
|
|
if (stHour > 19) {
|
|
|
|
stHour = 19
|
2006-10-26 01:58:29 +02:00
|
|
|
stMinute = 0;
|
|
|
|
}
|
|
|
|
if (etHour < 8) {
|
|
|
|
etHour = 8;
|
|
|
|
etMinute = 0;
|
|
|
|
}
|
2006-10-31 00:33:41 +01:00
|
|
|
if (etHour > 19) {
|
|
|
|
etHour = 19;
|
2006-10-26 01:58:29 +02:00
|
|
|
etMinute = 0;
|
|
|
|
}
|
|
|
|
if (stHour > etHour) {
|
|
|
|
var swap = etHour;
|
|
|
|
etHour = stHour;
|
|
|
|
stHour = swap;
|
|
|
|
swap = etMinute;
|
|
|
|
etMinute = stMinute;
|
|
|
|
stMinute = etMinute;
|
2006-10-31 00:33:41 +01:00
|
|
|
} else {
|
|
|
|
if (stMinute > etMinute) {
|
|
|
|
var swap = etMinute;
|
|
|
|
etMinute = stMinute;
|
|
|
|
stMinute = swap;
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2006-10-31 00:33:41 +01:00
|
|
|
var deltaCells = (etHour - stHour) + (11 * addDays);
|
2006-10-26 01:58:29 +02:00
|
|
|
var deltaSpans = (deltaCells * 4 ) + (etMinute - stMinute);
|
|
|
|
var currentCellNbr = stHour - 7;
|
|
|
|
var currentCell = row.cells[currentCellNbr];
|
|
|
|
var currentSpanNbr = stMinute;
|
2007-05-28 18:12:06 +02:00
|
|
|
var spans = $(currentCell).childNodesWithTag("span");
|
2006-10-26 01:58:29 +02:00
|
|
|
resetFreeBusyZone();
|
|
|
|
while (deltaSpans > 0) {
|
|
|
|
var currentSpan = spans[currentSpanNbr];
|
|
|
|
currentSpan.addClassName("busy");
|
|
|
|
currentSpanNbr++;
|
|
|
|
if (currentSpanNbr > 3) {
|
|
|
|
currentSpanNbr = 0;
|
|
|
|
currentCellNbr++;
|
|
|
|
currentCell = row.cells[currentCellNbr];
|
2007-05-28 18:12:06 +02:00
|
|
|
spans = $(currentCell).childNodesWithTag("span");
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
deltaSpans--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function newAttendee(event) {
|
2007-03-18 16:00:34 +01:00
|
|
|
var table = $("freeBusy");
|
2006-11-13 19:46:00 +01:00
|
|
|
var tbody = table.tBodies[0];
|
2006-10-26 01:58:29 +02:00
|
|
|
var model = tbody.rows[tbody.rows.length - 1];
|
2007-05-28 18:12:06 +02:00
|
|
|
var newAttendeeRow = tbody.rows[tbody.rows.length - 2];
|
2006-10-26 01:58:29 +02:00
|
|
|
var newRow = model.cloneNode(true);
|
|
|
|
newRow.setAttribute("class", "");
|
|
|
|
tbody.insertBefore(newRow, newAttendeeRow);
|
2007-05-28 18:12:06 +02:00
|
|
|
//table.tBodies[0].appendChild(newRow);
|
|
|
|
var input = $(newRow.cells[0]).childNodesWithTag("input")[0];
|
|
|
|
input.setAttribute("autocomplete", "off");
|
2006-11-13 19:46:00 +01:00
|
|
|
input.serial = "pouet";
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe(input, "blur", checkAttendee.bindAsEventListener(input));
|
|
|
|
Event.observe(input, "keydown", onContactKeydown.bindAsEventListener(input));
|
2006-11-13 19:46:00 +01:00
|
|
|
input.focus();
|
|
|
|
input.focussed = true;
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function checkAttendee() {
|
2006-11-13 19:46:00 +01:00
|
|
|
this.focussed = false;
|
|
|
|
var th = this.parentNode.parentNode;
|
2006-10-26 01:58:29 +02:00
|
|
|
var tbody = th.parentNode;
|
2006-11-13 19:46:00 +01:00
|
|
|
if (this.value.trim().length == 0)
|
2006-10-26 01:58:29 +02:00
|
|
|
tbody.removeChild(th);
|
2006-11-13 19:46:00 +01:00
|
|
|
else if (!this.hasfreebusy) {
|
|
|
|
if (this.confirmedValue)
|
|
|
|
this.value = this.confirmedValue;
|
|
|
|
displayFreeBusyForNode(this);
|
|
|
|
this.hasfreebusy = true;
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
2006-10-26 18:43:50 +02:00
|
|
|
resetAttendeesValue();
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function displayFreeBusyForNode(node) {
|
2007-05-10 21:02:16 +02:00
|
|
|
if (document.contactFreeBusyAjaxRequest)
|
|
|
|
awaitingFreeBusyRequests.push(node);
|
|
|
|
else {
|
|
|
|
var nodes = node.parentNode.parentNode.cells;
|
|
|
|
if (node.uid) {
|
|
|
|
for (var i = 1; i < nodes.length; i++) {
|
|
|
|
nodes[i].removeClassName("noFreeBusy");
|
|
|
|
nodes[i].innerHTML = ('<span class="freeBusyZoneElement"></span>'
|
|
|
|
+ '<span class="freeBusyZoneElement"></span>'
|
|
|
|
+ '<span class="freeBusyZoneElement"></span>'
|
|
|
|
+ '<span class="freeBusyZoneElement"></span>');
|
|
|
|
}
|
|
|
|
if (document.contactFreeBusyAjaxRequest) {
|
|
|
|
document.contactFreeBusyAjaxRequest.aborted = true;
|
|
|
|
document.contactFreeBusyAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var sd = $('startTime_date').valueAsShortDateString();
|
|
|
|
var ed = $('endTime_date').valueAsShortDateString();
|
|
|
|
var urlstr = ( UserFolderURL + "../" + node.uid + "/freebusy.ifb/ajaxRead?"
|
|
|
|
+ "sday=" + sd + "&eday=" + ed + "&additional=" +
|
|
|
|
additionalDays );
|
|
|
|
document.contactFreeBusyAjaxRequest
|
|
|
|
= triggerAjaxRequest(urlstr,
|
|
|
|
updateFreeBusyData,
|
|
|
|
node);
|
|
|
|
} else {
|
|
|
|
for (var i = 1; i < nodes.length; i++) {
|
|
|
|
nodes[i].addClassName("noFreeBusy");
|
|
|
|
nodes[i].innerHTML = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function setSlot(tds, nbr, status) {
|
|
|
|
var tdnbr = Math.floor(nbr / 4);
|
|
|
|
var spannbr = nbr - (tdnbr * 4);
|
|
|
|
var days = 0;
|
|
|
|
if (tdnbr > 24) {
|
2006-10-26 02:41:03 +02:00
|
|
|
days = Math.floor(tdnbr / 24);
|
2006-10-26 01:58:29 +02:00
|
|
|
tdnbr -= (days * 24);
|
|
|
|
}
|
|
|
|
if (tdnbr > 7 && tdnbr < 19) {
|
2006-10-26 02:41:03 +02:00
|
|
|
var i = (days * 11 + tdnbr - 7);
|
|
|
|
var td = tds[i];
|
2007-05-28 18:12:06 +02:00
|
|
|
var spans = $(td).childNodesWithTag("span");
|
2006-10-26 18:43:50 +02:00
|
|
|
if (status == '2')
|
|
|
|
spans[spannbr].addClassName("maybe-busy");
|
|
|
|
else
|
|
|
|
spans[spannbr].addClassName("busy");
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function updateFreeBusyData(http) {
|
2006-10-26 01:58:29 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
var node = http.callbackData;
|
|
|
|
var slots = http.responseText.split(",");
|
|
|
|
var tds = node.parentNode.parentNode.cells;
|
|
|
|
for (var i = 0; i < slots.length; i++) {
|
|
|
|
if (slots[i] != '0')
|
|
|
|
setSlot(tds, i, slots[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.contactFreeBusyAjaxRequest = null;
|
2006-10-26 18:43:50 +02:00
|
|
|
if (awaitingFreeBusyRequests.length > 0)
|
|
|
|
displayFreeBusyForNode(awaitingFreeBusyRequests.shift());
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
}
|
2006-10-26 18:43:50 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function resetAttendeesValue() {
|
2007-03-18 16:00:34 +01:00
|
|
|
var table = $("freeBusy");
|
2006-10-26 18:43:50 +02:00
|
|
|
var inputs = table.getElementsByTagName("input");
|
|
|
|
for (var i = 0; i < inputs.length - 2; i++) {
|
|
|
|
var currentInput = inputs[i];
|
|
|
|
var uid = currentInput.getAttribute("uid");
|
|
|
|
if (uid) {
|
|
|
|
currentInput.uid = uid;
|
|
|
|
currentInput.setAttribute("uid", null);
|
|
|
|
}
|
2006-11-13 19:46:00 +01:00
|
|
|
currentInput.setAttribute("autocomplete", "off");
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe(currentInput, "keydown", onContactKeydown.bindAsEventListener(currentInput), false);
|
|
|
|
Event.observe(currentInput, "blur", checkAttendee.bindAsEventListener(currentInput), false);
|
2006-10-26 18:43:50 +02:00
|
|
|
}
|
2006-11-13 19:46:00 +01:00
|
|
|
inputs[inputs.length - 2].setAttribute("autocomplete", "off");
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe(inputs[inputs.length - 2], "click", newAttendee, false);
|
2006-10-26 18:43:50 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function resetAllFreeBusys() {
|
2007-03-18 16:00:34 +01:00
|
|
|
var table = $("freeBusy");
|
2006-10-26 18:43:50 +02:00
|
|
|
var inputs = table.getElementsByTagName("input");
|
|
|
|
|
|
|
|
for (var i = 0; i < inputs.length - 2; i++) {
|
|
|
|
var currentInput = inputs[i];
|
|
|
|
currentInput.hasfreebusy = false;
|
2007-05-10 21:02:16 +02:00
|
|
|
displayFreeBusyForNode(inputs[i]);
|
2006-10-26 18:43:50 +02:00
|
|
|
}
|
|
|
|
}
|
2006-10-30 23:43:13 +01:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function initializeWindowButtons() {
|
|
|
|
var okButton = $("okButton");
|
|
|
|
var cancelButton = $("cancelButton");
|
|
|
|
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe(okButton, "click", onEditorOkClick, false);
|
|
|
|
Event.observe(cancelButton, "click", onEditorCancelClick, false);
|
2007-03-19 17:29:56 +01:00
|
|
|
|
|
|
|
var buttons = $("freeBusyViewButtons").childNodesWithTag("a");
|
|
|
|
for (var i = 0; i < buttons.length; i++)
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe(buttons[i], "click", listRowMouseDownHandler, false);
|
2007-03-19 17:29:56 +01:00
|
|
|
buttons = $("freeBusyZoomButtons").childNodesWithTag("a");
|
|
|
|
for (var i = 0; i < buttons.length; i++)
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe(buttons[i], "click", listRowMouseDownHandler, false);
|
2007-03-19 17:29:56 +01:00
|
|
|
buttons = $("freeBusyButtons").childNodesWithTag("a");
|
|
|
|
for (var i = 0; i < buttons.length; i++)
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe(buttons[i], "click", listRowMouseDownHandler, false);
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
2006-11-07 17:13:03 +01:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function onEditorOkClick(event) {
|
2007-06-28 20:29:59 +02:00
|
|
|
preventDefault(event);
|
2006-11-07 17:13:03 +01:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
attendeesNames = new Array();
|
|
|
|
attendeesEmails = new Array();
|
2006-10-30 23:43:13 +01:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
var table = $("freeBusy");
|
|
|
|
var inputs = table.getElementsByTagName("input");
|
|
|
|
for (var i = 0; i < inputs.length - 2; i++) {
|
2007-05-09 21:15:18 +02:00
|
|
|
var name = extractEmailName(inputs[i].value);
|
|
|
|
if (!(name && name.length > 0))
|
|
|
|
name = inputs[i].uid;
|
2007-03-18 16:00:34 +01:00
|
|
|
var email = extractEmailAddress(inputs[i].value);
|
|
|
|
var pos = attendeesEmails.indexOf(email);
|
|
|
|
if (pos == -1)
|
|
|
|
pos = attendeesEmails.length;
|
|
|
|
attendeesNames[pos] = name;
|
|
|
|
attendeesEmails[pos] = email;
|
|
|
|
}
|
2006-10-30 23:43:13 +01:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
parent$("attendeesNames").value = attendeesNames.join(",");
|
|
|
|
parent$("attendeesEmails").value = attendeesEmails.join(",");
|
|
|
|
window.opener.refreshAttendees();
|
2006-10-31 00:33:41 +01:00
|
|
|
|
2007-03-19 17:07:11 +01:00
|
|
|
updateParentDateFields("startTime", "startTime");
|
|
|
|
updateParentDateFields("endTime", "endTime");
|
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
window.close();
|
2006-10-30 23:43:13 +01:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function onEditorCancelClick(event) {
|
2007-06-28 20:29:59 +02:00
|
|
|
preventDefault(event);
|
2007-03-18 16:00:34 +01:00
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
function synchronizeWithParent(srcWidgetName, dstWidgetName) {
|
|
|
|
var srcDate = parent$(srcWidgetName + "_date");
|
|
|
|
var dstDate = $(dstWidgetName + "_date");
|
|
|
|
dstDate.value = srcDate.value;
|
|
|
|
|
|
|
|
var srcHour = parent$(srcWidgetName + "_time_hour");
|
|
|
|
var dstHour = $(dstWidgetName + "_time_hour");
|
|
|
|
dstHour.value = srcHour.value;
|
2006-10-30 23:43:13 +01:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
var srcMinute = parent$(srcWidgetName + "_time_minute");
|
|
|
|
var dstMinute = $(dstWidgetName + "_time_minute");
|
|
|
|
dstMinute.value = srcMinute.value;
|
2006-10-30 23:43:13 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 17:07:11 +01:00
|
|
|
function updateParentDateFields(srcWidgetName, dstWidgetName) {
|
|
|
|
var srcDate = $(srcWidgetName + "_date");
|
|
|
|
var dstDate = parent$(dstWidgetName + "_date");
|
|
|
|
dstDate.value = srcDate.value;
|
|
|
|
|
|
|
|
var srcHour = $(srcWidgetName + "_time_hour");
|
|
|
|
var dstHour = parent$(dstWidgetName + "_time_hour");
|
|
|
|
dstHour.value = srcHour.value;
|
|
|
|
|
|
|
|
var srcMinute = $(srcWidgetName + "_time_minute");
|
|
|
|
var dstMinute = parent$(dstWidgetName + "_time_minute");
|
|
|
|
dstMinute.value = srcMinute.value;
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function initializeTimeWidgets() {
|
|
|
|
synchronizeWithParent("startTime", "startTime");
|
|
|
|
synchronizeWithParent("endTime", "endTime");
|
|
|
|
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe($("startTime_date"), "change", onTimeDateWidgetChange, false);
|
|
|
|
Event.observe($("startTime_time_hour"), "change", onTimeWidgetChange, false);
|
|
|
|
Event.observe($("startTime_time_minute"), "change", onTimeWidgetChange, false);
|
2007-03-18 16:00:34 +01:00
|
|
|
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe($("endTime_date"), "change", onTimeDateWidgetChange, false);
|
|
|
|
Event.observe($("endTime_time_hour"), "change", onTimeWidgetChange, false);
|
|
|
|
Event.observe($("endTime_time_minute"), "change", onTimeWidgetChange, false);
|
2006-10-30 23:43:13 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onTimeWidgetChange() {
|
2007-03-18 16:00:34 +01:00
|
|
|
redisplayFreeBusyZone();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onTimeDateWidgetChange(event) {
|
|
|
|
var table = $("freeBusy");
|
|
|
|
|
|
|
|
var rows = table.tHead.rows;
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
for (var j = rows[i].cells.length - 1; j > 0; j--) {
|
|
|
|
rows[i].deleteCell(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rows = table.tBodies[0].rows;
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
for (var j = rows[i].cells.length - 1; j > 0; j--) {
|
|
|
|
rows[i].deleteCell(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prepareTableHeaders();
|
|
|
|
prepareTableRows();
|
|
|
|
redisplayFreeBusyZone();
|
|
|
|
resetAttendeesValue();
|
|
|
|
resetAllFreeBusys();
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepareTableHeaders() {
|
|
|
|
var startTimeDate = $("startTime_date");
|
|
|
|
var startDate = startTimeDate.valueAsDate();
|
|
|
|
|
|
|
|
var endTimeDate = $("endTime_date");
|
|
|
|
var endDate = endTimeDate.valueAsDate();
|
|
|
|
endDate.setTime(endDate.getTime() + (additionalDays * 86400000));
|
|
|
|
|
|
|
|
var rows = $("freeBusy").tHead.rows;
|
|
|
|
var days = startDate.daysUpTo(endDate);
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
var header1 = document.createElement("th");
|
|
|
|
header1.colSpan = (dayEndHour - dayStartHour) + 1;
|
|
|
|
header1.appendChild(document.createTextNode(days[i].toLocaleDateString()));
|
|
|
|
rows[0].appendChild(header1);
|
|
|
|
for (var hour = dayStartHour; hour < (dayEndHour + 1); hour++) {
|
|
|
|
var header2 = document.createElement("th");
|
|
|
|
var text = hour + ":00";
|
|
|
|
if (hour < 10)
|
|
|
|
text = "0" + text;
|
|
|
|
header2.appendChild(document.createTextNode(text));
|
|
|
|
rows[1].appendChild(header2);
|
|
|
|
|
|
|
|
var header3 = document.createElement("th");
|
|
|
|
for (var span = 0; span < 4; span++) {
|
|
|
|
var spanElement = document.createElement("span");
|
2007-05-28 18:12:06 +02:00
|
|
|
$(spanElement).addClassName("freeBusyZoneElement");
|
2007-03-18 16:00:34 +01:00
|
|
|
header3.appendChild(spanElement);
|
|
|
|
}
|
|
|
|
rows[2].appendChild(header3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepareTableRows() {
|
|
|
|
var startTimeDate = $("startTime_date");
|
|
|
|
var startDate = startTimeDate.valueAsDate();
|
|
|
|
|
|
|
|
var endTimeDate = $("endTime_date");
|
|
|
|
var endDate = endTimeDate.valueAsDate();
|
|
|
|
endDate.setTime(endDate.getTime() + (additionalDays * 86400000));
|
|
|
|
|
|
|
|
var rows = $("freeBusy").tBodies[0].rows;
|
|
|
|
var days = startDate.daysUpTo(endDate);
|
2007-05-10 21:02:16 +02:00
|
|
|
for (var i = 0; i < days.length; i++)
|
|
|
|
for (var rowNbr = 0; rowNbr < rows.length; rowNbr++)
|
|
|
|
for (var hour = dayStartHour; hour < (dayEndHour + 1); hour++)
|
|
|
|
rows[rowNbr].appendChild(document.createElement("td"));
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function prepareAttendees() {
|
|
|
|
var value = parent$("attendeesNames").value;
|
|
|
|
if (value.length > 0) {
|
|
|
|
attendeesNames = parent$("attendeesNames").value.split(",");
|
|
|
|
attendeesEmails = parent$("attendeesEmails").value.split(",");
|
|
|
|
|
|
|
|
var body = $("freeBusy").tBodies[0];
|
|
|
|
for (var i = 0; i < attendeesNames.length; i++) {
|
|
|
|
var tr = body.insertRow(i);
|
|
|
|
var td = document.createElement("td");
|
|
|
|
td.addClassName("attendees");
|
|
|
|
var input = document.createElement("input");
|
|
|
|
var value = "";
|
|
|
|
if (attendeesNames[i].length > 0)
|
|
|
|
value += attendeesNames[i] + " ";
|
|
|
|
value += "<" + attendeesEmails[i] + ">";
|
|
|
|
input.value = value;
|
|
|
|
input.addClassName("textField");
|
|
|
|
input.setAttribute("modified", "0");
|
2007-05-10 21:02:16 +02:00
|
|
|
tr.appendChild(td);
|
|
|
|
td.appendChild(input);
|
|
|
|
displayFreeBusyForNode(input);
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attendeesNames = new Array();
|
|
|
|
attendeesEmails = new Array();
|
|
|
|
}
|
2006-10-30 23:43:13 +01:00
|
|
|
}
|
2006-11-13 19:46:00 +01:00
|
|
|
|
2007-05-10 21:02:16 +02:00
|
|
|
function initializeFreebusys() {
|
|
|
|
var inputs = $("freeBusy").getElementsByTagName("input");
|
|
|
|
var baseUrl = UserFolderURL + "Contacts/contactSearch?search=";
|
|
|
|
for (var i = 0; i < attendeesEmails.length; i++)
|
|
|
|
triggerAjaxRequest(baseUrl + attendeesEmails[i],
|
|
|
|
UIDLookupCallback, inputs[i]);
|
|
|
|
}
|
|
|
|
|
2006-11-13 19:46:00 +01:00
|
|
|
function onFreeBusyLoadHandler() {
|
2007-03-18 16:00:34 +01:00
|
|
|
initializeWindowButtons();
|
|
|
|
initializeTimeWidgets();
|
|
|
|
prepareAttendees();
|
|
|
|
prepareTableHeaders();
|
|
|
|
prepareTableRows();
|
|
|
|
redisplayFreeBusyZone();
|
|
|
|
resetAttendeesValue();
|
2007-05-10 21:02:16 +02:00
|
|
|
initializeFreebusys();
|
2006-11-13 19:46:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("load", onFreeBusyLoadHandler, false);
|