diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index 00b0e706b..fd7e4002f 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -144,18 +144,24 @@ function openContactsFolderAtIndex(element) { function contactsListCallback(http) { - var div = $('contactsListContent'); + var div = $("contactsListContent"); - if (http.readyState == 4 - && http.status == 200) { - document.contactsListAjaxRequest = null; - div.innerHTML = http.responseText; - var selected = http.callbackData; - if (selected) { - for (var i = 0; i < selected.length; i++) - selectNode($(selected[i])); + if (http.readyState == 4) { + if (http.status == 200) { + document.contactsListAjaxRequest = null; + div.innerHTML = http.responseText; + var selected = http.callbackData; + if (selected) { + for (var i = 0; i < selected.length; i++) + selectNode($(selected[i])); + } + configureSortableTableHeaders(); + } else if (http.status == 403) { + window.alert(labels.error_ab_access_denied.decodeEntities()); + openContactsFolder("/personal", null, false); + var cf = $("contactFolders"); + cf.deselectAll(); } - configureSortableTableHeaders(); } else log ("ajax fuckage"); diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index fb21b69f8..836f2ca04 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -855,8 +855,7 @@ function calendarUidsList() { var list = ""; - var clist = $("calendarsList"); - var nodes = clist.childNodes[5].childNodesWithTag("li"); + var nodes = $("uixselector-calendarsList-display").childNodesWithTag("li"); for (var i = 0; i < nodes.length; i++) { var currentNode = nodes[i]; var input = currentNode.childNodesWithTag("input")[0]; @@ -907,8 +906,44 @@ function inhibitMyCalendarEntry() } } +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]); + } +} + function updateCalendarsList(method) { + ensureSelfIfPresent(); var url = (ApplicationBaseURL + "updateCalendars?ids=" + calendarUidsList()); if (document.calendarsListAjaxRequest) { @@ -963,21 +998,9 @@ function addContact(tag, fullContactName, contactId, contactName, contactEmail) else uids.value = contactId; var names = $("uixselector-calendarsList-display"); - names.innerHTML += ('