var allDocumentElements = null;
/* a W3C compliant document.all */
-function getAllScopeElements(scope)
-{
+function getAllScopeElements(scope) {
var elements = new Array();
for (var i = 0; i < scope.childNodes.length; i++)
return elements;
}
-function getAllElements(scope)
-{
+function getAllElements(scope) {
var elements;
if (scope == null)
return url;
}
+function URLForFolderID(folderID) {
+ var folderInfos = folderID.split(":");
+ var url;
+ if (folderInfos.length > 1) {
+ url = UserFolderURL + "../" + folderInfos[0];
+ if (folderInfos[1][0] != '/')
+ url += '/';
+ url += folderInfos[1];
+ }
+ else
+ url = ApplicationBaseURL + folderInfos[0];
+
+ if (url[url.length-1] == '/')
+ url = url.substr(0, url.length-1);
+
+ return url;
+}
+
function extractEmailAddress(mailTo) {
var email = "";
function extractEmailName(mailTo) {
var emailName = "";
- var emailNamere = /(\w[\w\ _-]+)\ (<|<)/;
+ var emailNamere = /(.+)\ </;
if (emailNamere.test(mailTo)) {
emailNamere.exec(mailTo);
emailName = RegExp.$1;
}
+
+ return emailName;
}
function sanitizeMailTo(dirtyMailTo) {
return mailto;
}
+function openUserFolderSelector(callback, type) {
+ var urlstr = ApplicationBaseURL;
+ if (urlstr[urlstr.length-1] != '/')
+ urlstr += '/';
+ urlstr += ("../../" + UserLogin + "/Contacts/userFolders");
+ var w = window.open(urlstr, "User Selector",
+ "width=322,height=250,resizable=1,scrollbars=0");
+ w.opener = window;
+ w.userFolderCallback = callback;
+ w.userFolderType = type;
+ w.focus();
+}
+
function openMailComposeWindow(url) {
var w = window.open(url, null,
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
logConsole.innerHTML += message + '<br />' + "\n";
}
+function backtrace() {
+ var func = backtrace.caller;
+ var str = "backtrace:<br/>";
+
+ while (func)
+ {
+ if (func.name)
+ {
+ str += " " + func.name;
+ if (this)
+ str += " (" + this + ")";
+ }
+ else
+ str += "[anonymous]\n";
+
+ str += "<br/>";
+ func = func.caller;
+ }
+ str += "--\n";
+
+ return str;
+}
+
function dropDownSubmenu(event) {
var node = event.target;
var submenu = node.getAttribute("submenu");
}
/* search field */
-function popupSearchMenu(event, menuId) {
+function popupSearchMenu(event) {
var node = event.target;
+
+ var menuId = this.getAttribute("menuid");
relX = event.pageX - node.cascadeLeftOffset();
relY = event.pageY - node.cascadeTopOffset();
log ("onSearchChange()...");
}
-function onSearchMouseDown(event, searchValue) {
- superNode = searchValue.parentNode.parentNode.parentNode;
- relX = (event.pageX - superNode.offsetLeft - searchValue.offsetLeft);
- relY = (event.pageY - superNode.offsetTop - searchValue.offsetTop);
+function onSearchMouseDown(event) {
+ var superNode = this.parentNode.parentNode.parentNode;
+ relX = (event.pageX - superNode.offsetLeft - this.offsetLeft);
+ relY = (event.pageY - superNode.offsetTop - this.offsetTop);
- if (relY < 24) {
- event.cancelBubble = true;
- event.returnValue = false;
- }
+ if (relY < 24) {
+ event.cancelBubble = true;
+ event.returnValue = false;
+ }
}
-function onSearchFocus(searchValue) {
- ghostPhrase = searchValue.getAttribute("ghost-phrase");
- if (searchValue.value == ghostPhrase) {
- searchValue.value = "";
- searchValue.setAttribute("modified", "");
+function onSearchFocus() {
+ ghostPhrase = this.getAttribute("ghost-phrase");
+ if (this.value == ghostPhrase) {
+ this.value = "";
+ this.setAttribute("modified", "");
} else {
- searchValue.select();
+ this.select();
}
- searchValue.style.color = "#000";
+ this.style.color = "#000";
}
-function onSearchBlur(searchValue) {
- var ghostPhrase = searchValue.getAttribute("ghost-phrase");
-// log ("search blur: '" + searchValue.value + "'");
- if (!searchValue.value) {
- searchValue.setAttribute("modified", "");
- searchValue.style.color = "#aaa";
- searchValue.value = ghostPhrase;
- } else if (searchValue.value == ghostPhrase) {
- searchValue.setAttribute("modified", "");
- searchValue.style.color = "#aaa";
+function onSearchBlur(event) {
+ var ghostPhrase = this.getAttribute("ghost-phrase");
+// log ("search blur: '" + this.value + "'");
+ if (!this.value) {
+ this.setAttribute("modified", "");
+ this.style.color = "#aaa";
+ this.value = ghostPhrase;
+ } else if (this.value == ghostPhrase) {
+ this.setAttribute("modified", "");
+ this.style.color = "#aaa";
} else {
- searchValue.setAttribute("modified", "yes");
- searchValue.style.color = "#000";
+ this.setAttribute("modified", "yes");
+ this.style.color = "#000";
}
}
-function onSearchKeyDown(searchValue) {
- if (searchValue.timer)
- clearTimeout(searchValue.timer);
+function onSearchKeyDown(event) {
+ if (this.timer)
+ clearTimeout(this.timer);
- searchValue.timer = setTimeout("onSearchFormSubmit()", 1000);
+ this.timer = setTimeout("onSearchFormSubmit()", 1000);
}
function initCriteria() {
}
}
-/* contact selector */
-
-function onContactAdd(node)
-{
- var selector = null;
- var selectorURL = '?popup=YES';
- if (node) {
- selector = node.parentNode.parentNode;
- selectorURL += ("&selectorId=" + selector.getAttribute("id"));
- }
-
- urlstr = ApplicationBaseURL;
- if (urlstr[urlstr.length-1] != '/')
- urlstr += '/';
- urlstr += ("../../" + UserLogin + "/Contacts/"
- + contactSelectorAction + selectorURL);
-// log (urlstr);
- var w = window.open(urlstr, "Addressbook",
- "width=640,height=400,resizable=1,scrollbars=0");
- w.selector = selector;
- w.opener = this;
- w.focus();
-
- return false;
+/* toolbar buttons */
+function popupToolbarMenu(event, menuId) {
+ var toolbar = $("toolbar");
+ var node = event.target;
+ if (node.tagName != 'A')
+ node = node.getParentWithTagName("a");
+ node = node.childNodesWithTag("span")[0];
+
+ if (event.button == 0) {
+ event.cancelBubble = true;
+ event.returnValue = false;
+
+ if (document.currentPopupMenu)
+ hideMenu(event, document.currentPopupMenu);
+
+ var popup = document.getElementById(menuId);
+ var top = node.offsetTop + node.offsetHeight - 2;
+ popup.style.top = top + "px";
+ popup.style.left = node.cascadeLeftOffset() + "px";
+ popup.style.visibility = "visible";
+
+ bodyOnClick = "" + document.body.getAttribute("onclick");
+ document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');");
+ document.currentPopupMenu = popup;
+ }
}
-function onContactRemove(node) {
- var selector = node.parentNode.parentNode;
- var selectorId = selector.getAttribute("id");
- var hasChanged = false;
-
- var names = $('uixselector-' + selectorId + '-display');
- var nodes = names.getSelectedNodes();
- hasChanged = (nodes.length > 0);
- for (var i = 0; i < nodes.length; i++) {
- var currentNode = nodes[i];
- currentNode.parentNode.removeChild(currentNode);
- }
-
- var uids = $('uixselector-' + selectorId + '-uidList');
- nodes = node.parentNode.childNodes;
- var ids = new Array();
- for (var i = 0; i < nodes.length; i++)
- if (nodes[i] instanceof HTMLLIElement)
- ids.push(nodes[i].getAttribute("uid"));
- uids.value = ids.join(",");
-
- if (selector.changeNotification && hasChanged)
- selector.changeNotification("removal");
+/* contact selector */
- return false;
+function folderSubscriptionCallback(http) {
+ if (http.readyState == 4) {
+ if (http.status == 204) {
+ if (http.callbackData)
+ http.callbackData["method"](http.callbackData["data"]);
+ }
+ else
+ window.alert(labels["Unable to subscribe to that folder!"].decodeEntities());
+ document.subscriptionAjaxRequest = null;
+ }
+ else
+ log ("ajax fuckage");
+}
+
+function subscribeToFolder(refreshCallback, refreshCallbackData) {
+ var folderData = refreshCallbackData["folder"].split(":");
+ var username = folderData[0];
+ var folderPath = folderData[1];
+ if (username != UserLogin) {
+ var url = (UserFolderURL + "../" + username
+ + "/" + folderPath + "/subscribe");
+ if (document.subscriptionAjaxRequest) {
+ document.subscriptionAjaxRequest.aborted = true;
+ document.subscriptionAjaxRequest.abort();
+ }
+ var rfCbData = { method: refreshCallback, data: refreshCallbackData };
+ document.subscriptionAjaxRequest = triggerAjaxRequest(url,
+ folderSubscriptionCallback,
+ rfCbData);
+ }
+ else
+ window.alert(labels["You cannot subscribe to a folder that you own!"].decodeEntities());
+}
+
+function folderUnsubscriptionCallback(http) {
+ if (http.readyState == 4) {
+ if (http.status == 204) {
+ if (http.callbackData)
+ http.callbackData["method"](http.callbackData["data"]);
+ }
+ else
+ window.alert(labels["Unable to unsubscribe from that folder!"].decodeEntities());
+ document.unsubscriptionAjaxRequest = null;
+ }
+}
+
+function unsubscribeFromFolder(folder, refreshCallback, refreshCallbackData) {
+ if (document.body.hasClassName("popup")) {
+ window.opener.unsubscribeFromFolder(folder, refreshCallback, refreshCallbackData);
+ }
+ else {
+ var folderData = folder.split(":");
+ var username = folderData[0];
+ var folderPath = folderData[1];
+ if (username != UserLogin) {
+ var url = (UserFolderURL + "../" + username
+ + "/" + folderPath + "/unsubscribe");
+ if (document.unsubscriptionAjaxRequest) {
+ document.unsubscriptionAjaxRequest.aborted = true;
+ document.unsubscriptionAjaxRequest.abort();
+ }
+ var rfCbData = { method: refreshCallback, data: refreshCallbackData };
+ document.unsubscriptionAjaxRequest = triggerAjaxRequest(url,
+ folderUnsubscriptionCallback,
+ rfCbData);
+ }
+ else
+ window.alert(labels["You cannot unsubscribe from a folder that you own!"].decodeEntities());
+ }
}
function listRowMouseDownHandler(event) {
}
/* tabs */
-function initTabs()
-{
+function initTabs() {
var containers = document.getElementsByClassName("tabsContainer");
for (var x = 0; x < containers.length; x++) {
var container = containers[x];
return false;
}
-function openAclWindow(url, objectTitle) {
+function openAclWindow(url) {
var w = window.open(url, "aclWindow",
"width=300,height=300,resizable=1,scrollbars=1,toolbar=0,"
+ "location=0,directories=0,status=0,menubar=0"
+ ",copyhistory=0");
+ w.opener = window;
w.focus();
- w.title = "Poil: " + objectTitle;
return w;
}
function d2h(d) {
var hD = "0123456789abcdef";
- var h = hD.substr(d&15,1);
- while (d>15) {
- d>>=4;
- h=hD.substr(d&15,1)+h;
+ var h = hD.substr(d & 15, 1);
+
+ while (d > 15) {
+ d >>= 4;
+ h = hD.substr(d & 15, 1) + h;
}
+
return h;
}
var linkBanner = $("linkBanner");
if (linkBanner) {
var anchors = linkBanner.childNodesWithTag("a");
- for (var i = 0; i < 4; i++) {
+ for (var i = 0; i < 2; i++) {
anchors[i].addEventListener("mousedown", listRowMouseDownHandler,
false);
anchors[i].addEventListener("click", onLinkBannerClick, false);
}
- if (anchors.length > 5)
- anchors[5].addEventListener("click", toggleLogConsole, true);
+ if (anchors.length > 3)
+ anchors[3].addEventListener("click", toggleLogConsole, true);
}
}
function onHeaderClick(event) {
window.alert("generic headerClick");
}
+
+function parent$(element) {
+ return window.opener.document.getElementById(element);
+}