2010-08-06 19:42:03 +02:00
|
|
|
/* generic.js - this file is part of SOGo
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-03-09 14:50:06 +01:00
|
|
|
Copyright (C) 2005 SKYRIX Software AG
|
|
|
|
Copyright (C) 2006-2010 Inverse
|
2008-08-28 16:48:45 +02:00
|
|
|
|
2010-08-06 19:42:03 +02:00
|
|
|
SOGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-08-06 19:42:03 +02:00
|
|
|
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-08-06 19:42:03 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with SOGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
var logConsole;
|
2006-08-31 01:02:53 +02:00
|
|
|
var logWindow = null;
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
var queryParameters;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
var menus = new Array();
|
2007-06-27 23:20:15 +02:00
|
|
|
var search = {};
|
2007-06-28 20:28:33 +02:00
|
|
|
var sorting = {};
|
2010-08-10 15:47:11 +02:00
|
|
|
var dialogs = {};
|
|
|
|
var dialogActive = false;
|
|
|
|
var dialogsStack = new Array();
|
2006-08-24 20:48:33 +02:00
|
|
|
|
2007-11-05 15:37:26 +01:00
|
|
|
var lastClickedRow = -1;
|
2010-08-26 16:14:10 +02:00
|
|
|
var lastClickedRowId = -1;
|
2007-10-02 17:29:16 +02:00
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
// logArea = null;
|
|
|
|
var allDocumentElements = null;
|
|
|
|
|
2009-04-22 23:02:11 +02:00
|
|
|
// Alarms
|
|
|
|
var nextAlarm = null;
|
|
|
|
var Alarms = new Array();
|
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
// Ajax requests counts
|
|
|
|
var activeAjaxRequests = 0;
|
|
|
|
var removeFolderRequestCount = 0;
|
|
|
|
|
2010-06-30 19:26:06 +02:00
|
|
|
// Email validation regexp
|
|
|
|
var emailRE = /^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i;
|
|
|
|
|
|
|
|
|
2008-06-20 15:53:29 +02:00
|
|
|
function createElement(tagName, id, classes,
|
2009-07-28 20:36:06 +02:00
|
|
|
attributes, htmlAttributes,
|
|
|
|
parentNode) {
|
|
|
|
var newElement = $(document.createElement(tagName));
|
|
|
|
if (id)
|
|
|
|
newElement.setAttribute("id", id);
|
|
|
|
if (classes) {
|
|
|
|
if (typeof(classes) == "string")
|
|
|
|
newElement.addClassName(classes);
|
|
|
|
else
|
|
|
|
for (var i = 0; i < classes.length; i++)
|
|
|
|
newElement.addClassName(classes[i]);
|
|
|
|
}
|
|
|
|
if (attributes)
|
|
|
|
for (var i in attributes)
|
|
|
|
newElement[i] = attributes[i];
|
|
|
|
if (htmlAttributes)
|
|
|
|
for (var i in htmlAttributes)
|
|
|
|
newElement.setAttribute(i, htmlAttributes[i]);
|
|
|
|
if (parentNode)
|
|
|
|
parentNode.appendChild(newElement);
|
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
return newElement;
|
2007-06-27 23:20:15 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function URLForFolderID(folderID) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var folderInfos = folderID.split(":");
|
|
|
|
var url;
|
|
|
|
if (folderInfos.length > 1) {
|
|
|
|
url = UserFolderURL + "../" + encodeURI(folderInfos[0]);
|
|
|
|
if (!(folderInfos[0].endsWith('/')
|
|
|
|
|| folderInfos[1].startsWith('/')))
|
|
|
|
url += '/';
|
|
|
|
url += folderInfos[1];
|
|
|
|
}
|
2010-04-19 18:31:29 +02:00
|
|
|
else {
|
|
|
|
var folderInfo = folderInfos[0];
|
|
|
|
if (ApplicationBaseURL.endsWith('/')
|
|
|
|
&& folderInfo.startsWith('/'))
|
|
|
|
folderInfo = folderInfo.substr(1);
|
|
|
|
url = ApplicationBaseURL + encodeURI(folderInfo);
|
|
|
|
}
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (url[url.length-1] == '/')
|
|
|
|
url = url.substr(0, url.length-1);
|
2007-03-29 20:02:48 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return url;
|
2007-03-29 20:02:48 +02:00
|
|
|
}
|
|
|
|
|
2006-10-03 18:17:22 +02:00
|
|
|
function extractEmailAddress(mailTo) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var email = "";
|
2006-07-11 20:11:54 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var emailre
|
|
|
|
= /(([a-zA-Z0-9\._-]+)*[a-zA-Z0-9_-]+@([a-zA-Z0-9\._-]+)*[a-zA-Z0-9_-]+)/;
|
|
|
|
if (emailre.test(mailTo)) {
|
|
|
|
emailre.exec(mailTo);
|
|
|
|
email = RegExp.$1;
|
|
|
|
}
|
2006-07-11 20:11:54 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return email;
|
2006-10-03 18:17:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function extractEmailName(mailTo) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var emailName = "";
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var tmpMailTo = mailTo.replace("<", "<");
|
|
|
|
tmpMailTo = tmpMailTo.replace(">", ">");
|
2010-09-02 21:11:20 +02:00
|
|
|
tmpMailTo = tmpMailTo.replace("&", "&");
|
2006-10-03 18:17:22 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var emailNamere = /([ ]+)?(.+)\ </;
|
|
|
|
if (emailNamere.test(tmpMailTo)) {
|
|
|
|
emailNamere.exec(tmpMailTo);
|
|
|
|
emailName = RegExp.$2;
|
|
|
|
}
|
2007-03-18 16:00:34 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return emailName;
|
2006-10-03 18:17:22 +02:00
|
|
|
}
|
|
|
|
|
2008-08-26 19:16:16 +02:00
|
|
|
function extractSubject(mailTo) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var subject = "";
|
2008-08-26 19:16:16 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var subjectre = /\?subject=([^&]+)/;
|
|
|
|
if (subjectre.test(mailTo)) {
|
|
|
|
subjectre.exec(mailTo);
|
|
|
|
subject = RegExp.$1;
|
|
|
|
}
|
2008-08-26 19:16:16 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return subject;
|
2008-08-26 19:16:16 +02:00
|
|
|
}
|
|
|
|
|
2006-10-03 18:17:22 +02:00
|
|
|
function sanitizeMailTo(dirtyMailTo) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var emailName = extractEmailName(dirtyMailTo);
|
|
|
|
var email = extractEmailAddress(dirtyMailTo);
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var mailto = "";
|
|
|
|
if (emailName && emailName.length > 0)
|
|
|
|
mailto = emailName + ' <' + email + '>';
|
|
|
|
else
|
|
|
|
mailto = email;
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return mailto;
|
2006-07-11 20:11:54 +02:00
|
|
|
}
|
|
|
|
|
2008-08-09 03:53:09 +02:00
|
|
|
function sanitizeWindowName(dirtyWindowName) {
|
2009-07-28 20:36:06 +02:00
|
|
|
// IE is picky about the characters used for the window name.
|
|
|
|
return dirtyWindowName.replace(/[\s\.\/\-\@]/g, "_");
|
2008-08-09 03:53:09 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function openUserFolderSelector(callback, type) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var urlstr = ApplicationBaseURL;
|
|
|
|
if (! urlstr.endsWith('/'))
|
|
|
|
urlstr += '/';
|
|
|
|
urlstr += ("../../" + UserLogin + "/Contacts/userFolders");
|
|
|
|
var w = window.open(urlstr, "_blank",
|
|
|
|
"width=322,height=250,resizable=1,scrollbars=0,location=0");
|
|
|
|
w.opener = window;
|
|
|
|
window.userFolderCallback = callback;
|
|
|
|
window.userFolderType = type;
|
|
|
|
w.focus();
|
2007-03-29 20:02:48 +02:00
|
|
|
}
|
|
|
|
|
2007-08-21 18:00:25 +02:00
|
|
|
function openContactWindow(url, wId) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (!wId)
|
|
|
|
wId = "_blank";
|
2009-10-28 18:48:22 +01:00
|
|
|
else
|
2009-07-28 20:36:06 +02:00
|
|
|
wId = sanitizeWindowName(wId);
|
2007-11-06 23:07:39 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var w = window.open(url, wId,
|
2009-11-04 23:13:20 +01:00
|
|
|
"width=450,height=530,resizable=0,location=0");
|
2009-07-28 20:36:06 +02:00
|
|
|
w.focus();
|
2007-08-21 18:00:25 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return w;
|
2007-08-21 18:00:25 +02:00
|
|
|
}
|
|
|
|
|
2007-09-24 23:26:23 +02:00
|
|
|
function openMailComposeWindow(url, wId) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var parentWindow = this;
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (!wId)
|
|
|
|
wId = "_blank";
|
2009-10-28 18:48:22 +01:00
|
|
|
else
|
2009-07-28 20:36:06 +02:00
|
|
|
wId = sanitizeWindowName(wId);
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (document.body.hasClassName("popup"))
|
|
|
|
parentWindow = window.opener;
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var w = parentWindow.open(url, wId,
|
|
|
|
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
|
|
|
|
+ "location=0,directories=0,status=0,menubar=0"
|
|
|
|
+ ",copyhistory=0");
|
2007-10-30 20:56:50 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
w.focus();
|
2006-10-19 21:23:58 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return w;
|
2006-10-19 21:23:58 +02:00
|
|
|
}
|
|
|
|
|
2007-05-15 05:46:16 +02:00
|
|
|
function openMailTo(senderMailTo) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var addresses = senderMailTo.split(",");
|
|
|
|
var sanitizedAddresses = new Array();
|
2010-09-03 00:03:50 +02:00
|
|
|
var subject = extractSubject(senderMailTo);
|
2009-07-28 20:36:06 +02:00
|
|
|
for (var i = 0; i < addresses.length; i++) {
|
|
|
|
var sanitizedAddress = sanitizeMailTo(addresses[i]);
|
|
|
|
if (sanitizedAddress.length > 0)
|
|
|
|
sanitizedAddresses.push(sanitizedAddress);
|
|
|
|
}
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var mailto = sanitizedAddresses.join(",");
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (mailto.length > 0)
|
|
|
|
openMailComposeWindow(ApplicationBaseURL
|
2010-09-02 21:11:20 +02:00
|
|
|
+ "../Mail/compose?mailto=" + encodeURIComponent(mailto)
|
|
|
|
+ ((subject.length > 0)?"?subject=" + encodeURIComponent(subject):""));
|
2006-09-16 00:27:59 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return false; /* stop following the link */
|
2006-09-16 00:27:59 +02:00
|
|
|
}
|
|
|
|
|
2008-01-08 21:29:51 +01:00
|
|
|
function deleteDraft(url) {
|
2009-07-28 20:36:06 +02:00
|
|
|
/* this is called by UIxMailEditor with window.opener */
|
|
|
|
new Ajax.Request(url, {
|
2010-08-06 19:42:03 +02:00
|
|
|
asynchronous: false,
|
|
|
|
method: 'post',
|
|
|
|
onFailure: function(transport) {
|
|
|
|
log("draftDeleteCallback: problem during ajax request: " + transport.status);
|
|
|
|
}
|
|
|
|
});
|
2008-01-08 21:29:51 +01:00
|
|
|
}
|
|
|
|
|
2009-06-02 21:45:07 +02:00
|
|
|
function refreshFolderByType(type) {
|
2009-07-28 20:36:06 +02:00
|
|
|
/* this is called by UIxMailEditor with window.opener */
|
2010-07-28 23:17:57 +02:00
|
|
|
if (typeof Mailer != 'undefined')
|
|
|
|
deleteCachedMailboxByType(type);
|
2009-06-02 21:45:07 +02:00
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
function createHTTPClient() {
|
2009-08-18 18:27:28 +02:00
|
|
|
return new XMLHttpRequest();
|
2007-06-06 22:52:07 +02:00
|
|
|
}
|
|
|
|
|
2010-10-11 22:09:57 +02:00
|
|
|
function createCASRecoveryIFrame(request) {
|
2010-09-03 00:03:50 +02:00
|
|
|
var urlstr = UserFolderURL;
|
|
|
|
if (!urlstr.endsWith('/'))
|
|
|
|
urlstr += '/';
|
|
|
|
urlstr += "recover";
|
|
|
|
|
|
|
|
var newIFrame = createElement("iframe", null, "hidden",
|
|
|
|
{ src: urlstr });
|
2010-10-11 22:09:57 +02:00
|
|
|
newIFrame.request = request;
|
2010-09-03 00:03:50 +02:00
|
|
|
newIFrame.observe("load", onCASRecoverIFrameLoaded);
|
|
|
|
document.body.appendChild(newIFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCASRecoverIFrameLoaded(event) {
|
|
|
|
if (this.request) {
|
|
|
|
var request = this.request;
|
2010-10-11 22:09:57 +02:00
|
|
|
if (request.attempt == 0) {
|
|
|
|
triggerAjaxRequest(request.url,
|
|
|
|
request.callback,
|
|
|
|
request.callbackData,
|
2010-10-14 20:22:46 +02:00
|
|
|
request.content,
|
2010-10-11 22:09:57 +02:00
|
|
|
request.paramHeaders,
|
|
|
|
1);
|
|
|
|
}
|
2010-10-14 20:22:46 +02:00
|
|
|
else {
|
|
|
|
var logoffUrl = UserFolderURL + "logoff";
|
|
|
|
window.location.href = logoffUrl;
|
|
|
|
}
|
2010-09-03 00:03:50 +02:00
|
|
|
this.request = null;
|
|
|
|
}
|
|
|
|
this.parentNode.removeChild(this);
|
|
|
|
}
|
|
|
|
|
2008-02-01 16:49:33 +01:00
|
|
|
function onAjaxRequestStateChange(http) {
|
2009-07-28 20:36:06 +02:00
|
|
|
try {
|
2010-08-12 19:34:32 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 0 && usesCASAuthentication) {
|
2010-08-12 19:42:33 +02:00
|
|
|
activeAjaxRequests--;
|
|
|
|
checkAjaxRequestsState();
|
2010-09-03 00:03:50 +02:00
|
|
|
createCASRecoveryIFrame(http);
|
2010-08-12 19:34:32 +02:00
|
|
|
}
|
|
|
|
else if (activeAjaxRequests > 0) {
|
2010-11-01 20:28:38 +01:00
|
|
|
if (!http.aborted && http.callback)
|
2010-08-12 19:34:32 +02:00
|
|
|
http.callback(http);
|
2010-08-12 19:42:33 +02:00
|
|
|
activeAjaxRequests--;
|
|
|
|
checkAjaxRequestsState();
|
2010-08-12 19:34:32 +02:00
|
|
|
http.onreadystatechange = Prototype.emptyFunction;
|
|
|
|
http.callback = Prototype.emptyFunction;
|
|
|
|
http.callbackData = null;
|
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
activeAjaxRequests--;
|
|
|
|
checkAjaxRequestsState();
|
|
|
|
http.onreadystatechange = Prototype.emptyFunction;
|
|
|
|
http.callback = Prototype.emptyFunction;
|
|
|
|
http.callbackData = null;
|
|
|
|
log("AJAX Request, Caught Exception: " + e.name);
|
|
|
|
log(e.message);
|
|
|
|
if (e.fileName) {
|
|
|
|
if (e.lineNumber)
|
|
|
|
log("at " + e.fileName + ": " + e.lineNumber);
|
|
|
|
else
|
|
|
|
log("in " + e.fileName);
|
|
|
|
}
|
|
|
|
log(backtrace());
|
|
|
|
log("request url was '" + http.url + "'");
|
|
|
|
}
|
2008-02-01 16:49:33 +01:00
|
|
|
}
|
|
|
|
|
2008-04-22 19:16:37 +02:00
|
|
|
/* taken from Lightning */
|
|
|
|
function getContrastingTextColor(bgColor) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var calcColor = bgColor.substring(1);
|
|
|
|
var red = parseInt(calcColor.substring(0, 2), 16);
|
|
|
|
var green = parseInt(calcColor.substring(2, 4), 16);
|
|
|
|
var blue = parseInt(calcColor.substring(4, 6), 16);
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
// Calculate the brightness (Y) value using the YUV color system.
|
|
|
|
var brightness = (0.299 * red) + (0.587 * green) + (0.114 * blue);
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
// Consider all colors with less than 56% brightness as dark colors and
|
|
|
|
// use white as the foreground color, otherwise use black.
|
|
|
|
return ((brightness < 144) ? "white" : "black");
|
2008-04-22 19:16:37 +02:00
|
|
|
}
|
|
|
|
|
2010-10-11 22:09:57 +02:00
|
|
|
function triggerAjaxRequest(url, callback, userdata, content, headers, attempt) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var http = createHTTPClient();
|
|
|
|
if (http) {
|
|
|
|
activeAjaxRequests++;
|
|
|
|
document.animTimer = setTimeout("checkAjaxRequestsState();", 250);
|
2010-03-09 14:50:06 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
http.open("POST", url, true);
|
|
|
|
http.url = url;
|
2010-08-12 19:34:32 +02:00
|
|
|
http.paramHeaders = headers;
|
2010-10-14 20:22:46 +02:00
|
|
|
http.content = content;
|
2009-07-28 20:36:06 +02:00
|
|
|
http.callback = callback;
|
|
|
|
http.callbackData = userdata;
|
2010-08-12 19:34:32 +02:00
|
|
|
http.onreadystatechange = function() { onAjaxRequestStateChange(http); };
|
2010-10-11 22:09:57 +02:00
|
|
|
|
|
|
|
if (typeof(attempt) == "undefined") {
|
|
|
|
attempt = 0;
|
|
|
|
}
|
|
|
|
http.attempt = attempt;
|
2009-07-28 20:36:06 +02:00
|
|
|
// = function() {
|
|
|
|
// // log ("state changed (" + http.readyState + "): " + url);
|
|
|
|
// };
|
|
|
|
if (headers) {
|
|
|
|
for (var i in headers) {
|
|
|
|
http.setRequestHeader(i, headers[i]);
|
|
|
|
}
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
http.send(content ? content : "");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
log("triggerAjaxRequest: error creating HTTP Client!");
|
|
|
|
}
|
|
|
|
|
|
|
|
return http;
|
2006-08-24 20:48:33 +02:00
|
|
|
}
|
|
|
|
|
2010-08-06 20:22:49 +02:00
|
|
|
function AjaxRequestsChain(callback, callbackData) {
|
|
|
|
this.requests = [];
|
|
|
|
this.counter = 0;
|
|
|
|
this.callback = callback;
|
|
|
|
this.callbackData = callbackData;
|
|
|
|
}
|
|
|
|
|
|
|
|
AjaxRequestsChain.prototype = {
|
|
|
|
requests: null,
|
|
|
|
counter: 0,
|
|
|
|
callback: null,
|
|
|
|
callbackData: null,
|
|
|
|
|
|
|
|
_step: function ARC__step() {
|
|
|
|
if (this.counter < this.requests.length) {
|
|
|
|
var request = this.requests[this.counter];
|
|
|
|
this.counter++;
|
|
|
|
var chain = this;
|
|
|
|
var origCallback = request[1];
|
|
|
|
request[1] = function ARC__step_callback(http) {
|
|
|
|
if (origCallback) {
|
|
|
|
http.callback = origCallback;
|
|
|
|
origCallback.apply(http, [http]);
|
|
|
|
}
|
|
|
|
chain._step();
|
|
|
|
};
|
|
|
|
triggerAjaxRequest.apply(window, request);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.callback.apply(this, [this.callbackData]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
start: function ARC_start() {
|
|
|
|
this._step();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-09-04 16:59:16 +02:00
|
|
|
function startAnimation(parent, nextNode) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var anim = $("progressIndicator");
|
|
|
|
if (!anim) {
|
|
|
|
anim = createElement("img", "progressIndicator", null,
|
|
|
|
{src: ResourcesURL + "/busy.gif"});
|
|
|
|
anim.setStyle({ visibility: "hidden" });
|
|
|
|
if (nextNode)
|
|
|
|
parent.insertBefore(anim, nextNode);
|
|
|
|
else
|
|
|
|
parent.appendChild(anim);
|
|
|
|
anim.setStyle({ visibility: "visible" });
|
|
|
|
}
|
2007-09-04 16:59:16 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return anim;
|
2007-09-04 16:59:16 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function checkAjaxRequestsState() {
|
2009-07-28 20:36:06 +02:00
|
|
|
var progressImage = $("progressIndicator");
|
|
|
|
if (activeAjaxRequests > 0
|
|
|
|
&& !progressImage) {
|
|
|
|
var toolbar = $("toolbar");
|
|
|
|
if (toolbar)
|
|
|
|
startAnimation(toolbar);
|
|
|
|
}
|
|
|
|
else if (!activeAjaxRequests
|
2010-08-06 19:42:03 +02:00
|
|
|
&& progressImage) {
|
2009-07-28 20:36:06 +02:00
|
|
|
progressImage.parentNode.removeChild(progressImage);
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
2006-08-24 20:48:33 +02:00
|
|
|
}
|
|
|
|
|
2008-08-28 22:42:55 +02:00
|
|
|
function isMac() {
|
2009-07-28 20:36:06 +02:00
|
|
|
return (navigator.platform.indexOf('Mac') > -1);
|
2008-08-28 22:42:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function isWindows() {
|
2009-07-28 20:36:06 +02:00
|
|
|
return (navigator.platform.indexOf('Win') > -1);
|
2008-08-28 22:42:55 +02:00
|
|
|
}
|
|
|
|
|
2007-10-02 17:29:16 +02:00
|
|
|
function isSafari3() {
|
2009-07-28 20:36:06 +02:00
|
|
|
return (navigator.appVersion.indexOf("Version") > -1);
|
2007-10-02 17:29:16 +02:00
|
|
|
}
|
|
|
|
|
2007-06-07 21:21:24 +02:00
|
|
|
function isSafari() {
|
2009-07-28 20:36:06 +02:00
|
|
|
//var agt = navigator.userAgent.toLowerCase();
|
|
|
|
//var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
|
2007-06-07 21:21:24 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return (navigator.vendor == "Apple Computer, Inc.") || (navigator.userAgent.toLowerCase().indexOf('konqueror') != -1);
|
2007-06-07 21:21:24 +02:00
|
|
|
}
|
|
|
|
|
2007-06-12 16:58:15 +02:00
|
|
|
function isHttpStatus204(status) {
|
2009-07-28 20:36:06 +02:00
|
|
|
return (status == 204 || // Firefox
|
|
|
|
(isSafari() && typeof(status) == 'undefined') || // Safari
|
|
|
|
status == 1223); // IE
|
2007-06-12 16:58:15 +02:00
|
|
|
}
|
|
|
|
|
2007-05-28 23:29:07 +02:00
|
|
|
function getTarget(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
event = event || window.event;
|
|
|
|
if (event.target)
|
2010-02-15 16:32:12 +01:00
|
|
|
return $(event.target); // W3C DOM
|
2009-07-28 20:36:06 +02:00
|
|
|
else
|
2010-02-15 16:32:12 +01:00
|
|
|
return $(event.srcElement); // IE
|
2007-05-28 23:29:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function preventDefault(event) {
|
2010-03-09 14:50:06 +01:00
|
|
|
if (event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (event.preventDefault)
|
|
|
|
event.preventDefault(); // W3C DOM
|
|
|
|
else
|
|
|
|
event.returnValue = false; // IE
|
2010-03-09 14:50:06 +01:00
|
|
|
}
|
2007-05-28 23:29:07 +02:00
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
function resetSelection(win) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var t = "";
|
|
|
|
if (win && win.getSelection) {
|
|
|
|
t = win.getSelection().toString();
|
|
|
|
win.getSelection().removeAllRanges();
|
|
|
|
}
|
|
|
|
return t;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function refreshOpener() {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (window.opener && !window.opener.closed) {
|
|
|
|
window.opener.location.reload();
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
/* selection mechanism */
|
|
|
|
|
2010-03-31 22:44:22 +02:00
|
|
|
function eventIsLeftClick(event) {
|
2010-08-06 19:42:03 +02:00
|
|
|
var isLeftClick = true;
|
2010-04-12 19:51:59 +02:00
|
|
|
if (isMac() && isSafari()) {
|
2010-08-06 19:42:03 +02:00
|
|
|
if (event.ctrlKey == 1) {
|
|
|
|
// Control-click is equivalent to right-click under Mac OS X
|
|
|
|
isLeftClick = false;
|
|
|
|
}
|
|
|
|
else if (event.metaKey == 1) {
|
|
|
|
// Command-click
|
2010-03-31 22:44:22 +02:00
|
|
|
isLeftClick = true;
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
|
|
|
else {
|
2010-03-31 22:44:22 +02:00
|
|
|
isLeftClick = Event.isLeftClick(event);
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
2010-04-12 19:51:59 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
isLeftClick = event.isLeftClick();
|
|
|
|
}
|
2010-03-31 22:44:22 +02:00
|
|
|
|
|
|
|
return isLeftClick;
|
|
|
|
}
|
|
|
|
|
2006-07-07 23:27:12 +02:00
|
|
|
function deselectAll(parent) {
|
2009-07-28 20:36:06 +02:00
|
|
|
for (var i = 0; i < parent.childNodes.length; i++) {
|
|
|
|
var node = parent.childNodes.item(i);
|
|
|
|
if (node.nodeType == 1)
|
|
|
|
$(node).deselect();
|
|
|
|
}
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function isNodeSelected(node) {
|
2009-07-28 20:36:06 +02:00
|
|
|
return $(node).hasClassName('_selected');
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function acceptMultiSelect(node) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var response = false;
|
|
|
|
var attribute = node.getAttribute('multiselect');
|
|
|
|
if (attribute && attribute.length > 0) {
|
|
|
|
log("node '" + node.getAttribute("id")
|
|
|
|
+ "' is still using old-stylemultiselect!");
|
|
|
|
response = (attribute.toLowerCase() == 'yes');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
response = node.multiselect;
|
2006-07-07 23:27:12 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return response;
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
|
|
|
|
2006-07-17 19:30:42 +02:00
|
|
|
function onRowClick(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var node = Event.element(event);
|
|
|
|
var rowIndex = null;
|
|
|
|
|
|
|
|
if (node.tagName != 'TD' && node.tagName != 'LI')
|
|
|
|
node = this;
|
|
|
|
|
|
|
|
if (node.tagName == 'TD') {
|
|
|
|
node = node.parentNode; // select TR
|
|
|
|
}
|
|
|
|
if (node.tagName == 'TR') {
|
2010-05-27 16:41:59 +02:00
|
|
|
var head = $(node).up('table').down('thead');
|
|
|
|
rowIndex = node.rowIndex;
|
|
|
|
if (head)
|
|
|
|
rowIndex -= head.getElementsByTagName('tr').length;
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
|
|
|
else if (node.tagName == 'LI') {
|
|
|
|
// Find index of clicked row
|
|
|
|
var list = node.parentNode;
|
|
|
|
if (list) {
|
|
|
|
var items = list.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
if (items[i] == node) {
|
|
|
|
rowIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// No parent; stop here
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
var initialSelection = $(node.parentNode).getSelectedNodesId();
|
2009-07-28 20:36:06 +02:00
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
if (initialSelection && initialSelection.length > 0
|
|
|
|
&& initialSelection.indexOf(node.id) >= 0
|
2010-03-31 22:44:22 +02:00
|
|
|
&& !eventIsLeftClick(event))
|
2009-07-28 20:36:06 +02:00
|
|
|
// Ignore non primary-click (ie right-click) inside current selection
|
|
|
|
return true;
|
|
|
|
|
2010-04-14 15:22:12 +02:00
|
|
|
if ((event.shiftKey == 1 || (isMac() && event.metaKey == 1) || (!isMac() && event.ctrlKey == 1))
|
2009-07-28 20:36:06 +02:00
|
|
|
&& (lastClickedRow >= 0)
|
|
|
|
&& (acceptMultiSelect(node.parentNode)
|
|
|
|
|| acceptMultiSelect(node.parentNode.parentNode))) {
|
|
|
|
if (event.shiftKey) {
|
|
|
|
$(node.parentNode).selectRange(lastClickedRow, rowIndex);
|
|
|
|
} else if (isNodeSelected(node)) {
|
|
|
|
$(node).deselect();
|
|
|
|
rowIndex = null;
|
|
|
|
} else {
|
|
|
|
$(node).selectElement();
|
|
|
|
}
|
|
|
|
// At this point, should empty content of 3-pane view
|
|
|
|
} else {
|
|
|
|
// Single line selection
|
|
|
|
$(node.parentNode).deselectAll();
|
|
|
|
$(node).selectElement();
|
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
if (initialSelection != $(node.parentNode).getSelectedNodesId()) {
|
2009-07-28 20:36:06 +02:00
|
|
|
// Selection has changed; fire mousedown event
|
|
|
|
var parentNode = node.parentNode;
|
|
|
|
if (parentNode.tagName == 'TBODY')
|
|
|
|
parentNode = parentNode.parentNode;
|
|
|
|
parentNode.fire("mousedown");
|
|
|
|
}
|
|
|
|
}
|
2010-08-26 16:14:10 +02:00
|
|
|
if (rowIndex != null) {
|
|
|
|
lastClickedRow = rowIndex;
|
|
|
|
lastClickedRowId = node.getAttribute("id");
|
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
|
|
|
|
return true;
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
2006-07-11 20:11:54 +02:00
|
|
|
|
|
|
|
/* popup menus */
|
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
function popupMenu(event, menuId, target) {
|
2009-07-28 20:36:06 +02:00
|
|
|
document.menuTarget = target;
|
|
|
|
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
|
|
|
|
var popup = $(menuId);
|
|
|
|
|
|
|
|
var deltaX = 0;
|
|
|
|
var deltaY = 0;
|
|
|
|
|
|
|
|
var pageContent = $("pageContent");
|
|
|
|
if (popup.parentNode.tagName != "BODY") {
|
|
|
|
var offset = pageContent.cascadeLeftOffset();
|
|
|
|
deltaX = -($(popup.parentNode).cascadeLeftOffset() - offset);
|
|
|
|
offset = pageContent.cascadeTopOffset();
|
|
|
|
deltaY = -($(popup.parentNode).cascadeTopOffset() - offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
var menuTop = Event.pointerY(event) + deltaY;
|
|
|
|
var menuLeft = Event.pointerX(event) + deltaX;
|
2010-03-31 22:59:07 +02:00
|
|
|
var heightDiff = ((window.height() + deltaY)
|
|
|
|
- (menuTop + popup.offsetHeight + 1));
|
2009-07-28 20:36:06 +02:00
|
|
|
if (heightDiff < 0)
|
|
|
|
menuTop += heightDiff;
|
|
|
|
|
2010-03-31 22:59:07 +02:00
|
|
|
var leftDiff = ((window.width() + deltaX)
|
2009-07-28 20:36:06 +02:00
|
|
|
- (menuLeft + popup.offsetWidth));
|
|
|
|
if (leftDiff < 0)
|
2010-03-31 22:59:07 +02:00
|
|
|
menuLeft -= (popup.offsetWidth + 1);
|
2009-07-28 20:36:06 +02:00
|
|
|
|
|
|
|
var isVisible = true;
|
2010-08-06 14:37:28 +02:00
|
|
|
if (popup.prepareVisibility) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (!popup.prepareVisibility())
|
|
|
|
isVisible = false;
|
2010-08-06 14:37:28 +02:00
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
|
|
|
|
Event.stop(event);
|
|
|
|
if (isVisible) {
|
|
|
|
popup.setStyle({ top: menuTop + "px",
|
2010-08-06 19:42:03 +02:00
|
|
|
left: menuLeft + "px",
|
|
|
|
visibility: "visible" });
|
2009-10-02 15:42:19 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
document.currentPopupMenu = popup;
|
2009-10-02 15:42:19 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
$(document.body).observe("click", onBodyClickMenuHandler);
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function getParentMenu(node) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var currentNode, menuNode;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
menuNode = null;
|
|
|
|
currentNode = node;
|
|
|
|
var menure = new RegExp("(^|\s+)menu(\s+|$)", "i");
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
while (menuNode == null
|
2010-08-06 19:42:03 +02:00
|
|
|
&& currentNode) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (menure.test(currentNode.className))
|
|
|
|
menuNode = currentNode;
|
|
|
|
else
|
|
|
|
currentNode = currentNode.parentNode;
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return menuNode;
|
2006-07-11 20:11:54 +02:00
|
|
|
}
|
|
|
|
|
2007-05-28 15:18:31 +02:00
|
|
|
function onBodyClickMenuHandler(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
document.body.stopObserving("click", onBodyClickMenuHandler);
|
|
|
|
document.body.stopObserving("mouseup", onBodyClickMenuHandler);
|
|
|
|
document.currentPopupMenu = null;
|
2007-05-28 15:18:31 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (event)
|
|
|
|
preventDefault(event);
|
2006-07-11 20:11:54 +02:00
|
|
|
}
|
|
|
|
|
2008-02-08 00:09:16 +01:00
|
|
|
function onMenuClickHandler(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (!this.hasClassName("disabled"))
|
|
|
|
this.menuCallback.apply(this, [event]);
|
2008-02-08 00:09:16 +01:00
|
|
|
}
|
|
|
|
|
2007-09-14 20:20:51 +02:00
|
|
|
function hideMenu(menuNode) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var onHide;
|
|
|
|
|
|
|
|
if (!menuNode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (menuNode.submenu) {
|
|
|
|
hideMenu(menuNode.submenu);
|
|
|
|
menuNode.submenu = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
menuNode.setStyle({ visibility: "hidden" });
|
|
|
|
if (menuNode.parentMenuItem) {
|
2010-03-09 14:50:06 +01:00
|
|
|
menuNode.parentMenuItem.stopObserving("mouseover",
|
|
|
|
onMouseEnteredSubmenu);
|
|
|
|
menuNode.stopObserving("mouseover",
|
|
|
|
onMouseEnteredSubmenu);
|
|
|
|
menuNode.parentMenuItem.stopObserving("mouseout",
|
|
|
|
onMouseLeftSubmenu);
|
|
|
|
menuNode.stopObserving("mouseout",
|
|
|
|
onMouseLeftSubmenu);
|
|
|
|
menuNode.parentMenu.stopObserving("mouseover",
|
|
|
|
onMouseEnteredParentMenu);
|
2009-07-28 20:36:06 +02:00
|
|
|
$(menuNode.parentMenuItem).removeClassName("submenu-selected");
|
|
|
|
menuNode.parentMenuItem.mouseInside = false;
|
|
|
|
menuNode.parentMenuItem = null;
|
|
|
|
menuNode.parentMenu.submenuItem = null;
|
|
|
|
menuNode.parentMenu.submenu = null;
|
|
|
|
menuNode.parentMenu = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$(menuNode).fire("mousedown");
|
2006-07-13 21:13:18 +02:00
|
|
|
}
|
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
function onMenuEntryClick(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var node = event.target;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
id = getParentMenu(node).menuTarget;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
/* query string */
|
|
|
|
|
|
|
|
function generateQueryString(queryDict) {
|
|
|
|
var s = "";
|
|
|
|
for (var key in queryDict) {
|
|
|
|
var value = queryDict[key];
|
|
|
|
if (typeof(value) == "string"
|
|
|
|
|| typeof(value) == "number") {
|
|
|
|
if (s.length == 0)
|
|
|
|
s = "?";
|
|
|
|
else
|
|
|
|
s = s + "&";
|
|
|
|
s = s + key + "=" + escape(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
function parseQueryParameters(url) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var parameters = new Array();
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var params = url.split("?")[1];
|
|
|
|
if (params) {
|
|
|
|
var pairs = params.split("&");
|
|
|
|
for (var i = 0; i < pairs.length; i++) {
|
|
|
|
var pair = pairs[i].split("=");
|
|
|
|
parameters[pair[0]] = pair[1];
|
|
|
|
}
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return parameters;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
function initLogConsole() {
|
2009-07-28 20:36:06 +02:00
|
|
|
var logConsole = $("logConsole");
|
|
|
|
if (logConsole) {
|
|
|
|
logConsole.highlighted = false;
|
|
|
|
logConsole.observe("dblclick", onLogDblClick, false);
|
|
|
|
logConsole.update();
|
|
|
|
Event.observe(window, "keydown", onBodyKeyDown);
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function onBodyKeyDown(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (event.keyCode == Event.KEY_ESC) {
|
|
|
|
toggleLogConsole();
|
|
|
|
preventDefault(event);
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2006-11-17 23:23:15 +01:00
|
|
|
function toggleLogConsole(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var logConsole = $("logConsole");
|
|
|
|
var display = '' + logConsole.style.display;
|
|
|
|
if (display.length == 0) {
|
|
|
|
logConsole.setStyle({ display: 'block' });
|
|
|
|
} else {
|
|
|
|
logConsole.setStyle({ display: '' });
|
|
|
|
}
|
|
|
|
if (event)
|
|
|
|
preventDefault(event);
|
2006-07-11 20:11:54 +02:00
|
|
|
}
|
|
|
|
|
2006-07-13 21:13:18 +02:00
|
|
|
function log(message) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (!logWindow) {
|
|
|
|
logWindow = window;
|
|
|
|
while (logWindow.opener)
|
|
|
|
logWindow = logWindow.opener;
|
|
|
|
}
|
2010-08-24 21:57:42 +02:00
|
|
|
if (logWindow && logWindow._logMessage) {
|
|
|
|
var logMessage = message;
|
|
|
|
setTimeout(function() { logWindow._logMessage(logMessage) }, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _logMessage(message) {
|
|
|
|
var logConsole = $("logConsole");
|
2009-07-28 20:36:06 +02:00
|
|
|
if (logConsole) {
|
2010-05-17 16:47:33 +02:00
|
|
|
if (message == "\c") {
|
|
|
|
while (logConsole.firstChild) {
|
|
|
|
logConsole.removeChild(logConsole.firstChild);
|
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2010-05-17 16:47:33 +02:00
|
|
|
if (message[message.length-1] == "\n") {
|
2010-08-09 18:46:45 +02:00
|
|
|
message = message.substr(0, message.length-1);
|
2010-05-17 16:47:33 +02:00
|
|
|
}
|
|
|
|
var lines = message.split("\n");
|
|
|
|
for (var i = 0; i < lines.length; i++) {
|
|
|
|
logConsole.appendChild(document.createTextNode(lines[i]));
|
|
|
|
logConsole.appendChild(createElement("br"));
|
|
|
|
}
|
2010-03-09 21:25:10 +01:00
|
|
|
logConsole.scrollTop += 300; /* abritrary number */
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
2006-07-13 21:13:18 +02:00
|
|
|
}
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
function logOnly(message) {
|
|
|
|
log("\c");
|
|
|
|
log(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onLogDblClick(event) {
|
|
|
|
log("\c");
|
|
|
|
}
|
|
|
|
|
2007-02-13 23:00:29 +01:00
|
|
|
function backtrace() {
|
2009-07-28 20:36:06 +02:00
|
|
|
var func = backtrace.caller;
|
|
|
|
var str = "backtrace:\n";
|
2007-02-13 23:00:29 +01:00
|
|
|
|
2010-03-09 14:50:06 +01:00
|
|
|
while (func) {
|
|
|
|
if (func.name) {
|
|
|
|
str += " " + func.name;
|
|
|
|
if (this)
|
|
|
|
str += " (" + this + ")";
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
2010-03-09 14:50:06 +01:00
|
|
|
else
|
|
|
|
str += "[anonymous]\n";
|
|
|
|
|
|
|
|
str += "\n";
|
|
|
|
func = func.caller;
|
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
str += "--\n";
|
2007-02-13 23:00:29 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return str;
|
2007-02-13 23:00:29 +01:00
|
|
|
}
|
|
|
|
|
2007-10-17 21:08:00 +02:00
|
|
|
function popupSubmenu(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (this.submenu && this.submenu != "" && !$(this).hasClassName("disabled")) {
|
|
|
|
var submenuNode = $(this.submenu);
|
|
|
|
var parentNode = getParentMenu(this);
|
|
|
|
if (parentNode.submenu)
|
|
|
|
hideMenu(parentNode.submenu);
|
|
|
|
submenuNode.parentMenuItem = this;
|
|
|
|
submenuNode.parentMenu = parentNode;
|
|
|
|
parentNode.submenuItem = this;
|
|
|
|
parentNode.submenu = submenuNode;
|
|
|
|
|
|
|
|
if (submenuNode.prepareVisibility)
|
2010-08-19 21:20:48 +02:00
|
|
|
submenuNode.prepareVisibility.apply(submenuNode, []);
|
2009-07-28 20:36:06 +02:00
|
|
|
|
|
|
|
var menuTop = (parentNode.offsetTop - 1
|
|
|
|
+ this.offsetTop);
|
|
|
|
|
|
|
|
if (window.height()
|
2010-08-06 19:42:03 +02:00
|
|
|
< (menuTop + submenuNode.offsetHeight)) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (submenuNode.offsetHeight < window.height())
|
|
|
|
menuTop = window.height() - submenuNode.offsetHeight;
|
|
|
|
else
|
|
|
|
menuTop = 0;
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
|
|
|
|
var menuLeft = (parentNode.offsetLeft + parentNode.offsetWidth - 3);
|
|
|
|
if (window.width()
|
|
|
|
< (menuLeft + submenuNode.offsetWidth))
|
|
|
|
menuLeft = parentNode.offsetLeft - submenuNode.offsetWidth + 3;
|
|
|
|
|
|
|
|
this.mouseInside = true;
|
|
|
|
this.observe("mouseover", onMouseEnteredSubmenu);
|
|
|
|
submenuNode.observe("mouseover", onMouseEnteredSubmenu);
|
|
|
|
this.observe("mouseout", onMouseLeftSubmenu);
|
|
|
|
submenuNode.observe("mouseout", onMouseLeftSubmenu);
|
|
|
|
parentNode.observe("mouseover", onMouseEnteredParentMenu);
|
|
|
|
$(this).addClassName("submenu-selected");
|
|
|
|
submenuNode.setStyle({ top: menuTop + "px",
|
2010-08-06 19:42:03 +02:00
|
|
|
left: menuLeft + "px",
|
|
|
|
visibility: "visible" });
|
2009-07-28 20:36:06 +02:00
|
|
|
preventDefault(event);
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
function onMouseEnteredParentMenu(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (this.submenuItem && !this.submenuItem.mouseInside)
|
|
|
|
hideMenu(this.submenu);
|
2007-10-17 21:08:00 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
function onMouseEnteredSubmenu(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
$(this).mouseInside = true;
|
2006-07-13 21:13:18 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
function onMouseLeftSubmenu(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
$(this).mouseInside = false;
|
2007-10-17 21:08:00 +02:00
|
|
|
}
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
/* search field */
|
2007-03-22 22:14:17 +01:00
|
|
|
function popupSearchMenu(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var menuId = this.getAttribute("menuid");
|
|
|
|
var offset = Position.cumulativeOffset(this);
|
2007-08-15 00:09:20 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
relX = Event.pointerX(event) - offset[0];
|
|
|
|
relY = Event.pointerY(event) - offset[1];
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (event.button == 0
|
|
|
|
&& relX < 24) {
|
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var popup = $(menuId);
|
|
|
|
offset = Position.positionedOffset(this);
|
|
|
|
popup.setStyle({ top: this.offsetHeight + "px",
|
2010-08-06 19:42:03 +02:00
|
|
|
left: (offset[0] + 3) + "px",
|
|
|
|
visibility: "visible" });
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
document.currentPopupMenu = popup;
|
|
|
|
$(document.body).observe("click", onBodyClickMenuHandler);
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function setSearchCriteria(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var searchValue = $("searchValue");
|
|
|
|
var searchCriteria = $("searchCriteria");
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (searchValue.ghostPhrase == searchValue.value)
|
|
|
|
searchValue.value = this.innerHTML;
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
searchValue.ghostPhrase = this.innerHTML;
|
|
|
|
searchCriteria.value = this.getAttribute('id');
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (this.parentNode.chosenNode)
|
|
|
|
this.parentNode.chosenNode.removeClassName("_chosen");
|
|
|
|
this.addClassName("_chosen");
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (this.parentNode.chosenNode != this) {
|
|
|
|
searchValue.lastSearch = "";
|
|
|
|
this.parentNode.chosenNode = this;
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
onSearchFormSubmit();
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function checkSearchValue(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var searchValue = $("searchValue");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (searchValue.value == searchValue.ghostPhrase)
|
|
|
|
searchValue.value = "";
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-06-27 23:20:15 +02:00
|
|
|
function configureSearchField() {
|
2009-07-28 20:36:06 +02:00
|
|
|
var searchValue = $("searchValue");
|
2007-10-18 19:18:53 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (searchValue) {
|
|
|
|
searchValue.observe("click", popupSearchMenu);
|
|
|
|
searchValue.observe("blur", onSearchBlur);
|
|
|
|
searchValue.observe("focus", onSearchFocus);
|
|
|
|
searchValue.observe("keydown", onSearchKeyDown);
|
|
|
|
searchValue.observe("mousedown", onSearchMouseDown);
|
|
|
|
}
|
2007-06-27 23:20:15 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 22:14:17 +01:00
|
|
|
function onSearchMouseDown(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var superNode = this.parentNode.parentNode.parentNode;
|
|
|
|
relX = (Event.pointerX(event) - superNode.offsetLeft - this.offsetLeft);
|
|
|
|
relY = (Event.pointerY(event) - superNode.offsetTop - this.offsetTop);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (relX < 24)
|
|
|
|
Event.stop(event);
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2009-10-02 15:42:19 +02:00
|
|
|
function onSearchFocus(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
ghostPhrase = this.ghostPhrase;
|
|
|
|
if (this.value == ghostPhrase) {
|
|
|
|
this.value = "";
|
|
|
|
this.setAttribute("modified", "");
|
|
|
|
} else {
|
|
|
|
this.selectElement();
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
this.setStyle({ color: "#535D6D" });
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 22:14:17 +01:00
|
|
|
function onSearchBlur(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (!this.value || this.value.blank()) {
|
|
|
|
this.setAttribute("modified", "");
|
2009-11-04 23:13:20 +01:00
|
|
|
this.setStyle({ color: "#909090" });
|
2009-07-28 20:36:06 +02:00
|
|
|
this.value = this.ghostPhrase;
|
2010-03-09 15:29:16 +01:00
|
|
|
if (this.timer)
|
|
|
|
clearTimeout(this.timer);
|
2009-07-28 20:36:06 +02:00
|
|
|
search["value"] = "";
|
|
|
|
if (this.lastSearch != "") {
|
|
|
|
this.lastSearch = "";
|
|
|
|
refreshCurrentFolder();
|
|
|
|
}
|
|
|
|
} else if (this.value == this.ghostPhrase) {
|
|
|
|
this.setAttribute("modified", "");
|
2009-11-04 23:13:20 +01:00
|
|
|
this.setStyle({ color: "#909090" });
|
2009-07-28 20:36:06 +02:00
|
|
|
} else {
|
|
|
|
this.setAttribute("modified", "yes");
|
2009-11-04 23:13:20 +01:00
|
|
|
this.setStyle({ color: "#535D6D" });
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2010-03-09 14:45:19 +01:00
|
|
|
function IsCharacterKey(keyCode) {
|
|
|
|
return (keyCode == 32 /* space */
|
|
|
|
|| (keyCode > 47 && keyCode < 58) /* digits */
|
|
|
|
|| (keyCode > 64 && keyCode < 91) /* letters */
|
|
|
|
|| (keyCode > 95 && keyCode < 112) /* numpad digits */
|
|
|
|
|| (keyCode > 186 && keyCode < 193)
|
2010-03-09 14:50:24 +01:00
|
|
|
|| (keyCode > 218 && keyCode < 223));
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2010-03-09 14:45:19 +01:00
|
|
|
function onSearchKeyDown(event) {
|
2009-10-02 15:42:19 +02:00
|
|
|
if (event.keyCode == Event.KEY_RETURN) {
|
2010-03-09 14:45:19 +01:00
|
|
|
if (this.timer)
|
|
|
|
clearTimeout(this.timer);
|
2009-07-28 20:36:06 +02:00
|
|
|
onSearchFormSubmit();
|
|
|
|
preventDefault(event);
|
|
|
|
}
|
2010-03-09 14:45:19 +01:00
|
|
|
else if (event.keyCode == Event.KEY_BACKSPACE
|
|
|
|
|| IsCharacterKey(event.keyCode)) {
|
|
|
|
if (this.timer)
|
|
|
|
clearTimeout(this.timer);
|
2010-03-08 22:42:10 +01:00
|
|
|
this.timer = setTimeout("onSearchFormSubmit()", 500);
|
2010-03-09 14:45:19 +01:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-08-15 00:09:20 +02:00
|
|
|
function onSearchFormSubmit(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var searchValue = $("searchValue");
|
|
|
|
var searchCriteria = $("searchCriteria");
|
2008-08-19 00:45:59 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (searchValue.value != searchValue.ghostPhrase
|
|
|
|
&& (searchValue.value != searchValue.lastSearch
|
|
|
|
|| searchValue.value.strip().length > 0)) {
|
|
|
|
search["criteria"] = searchCriteria.value;
|
|
|
|
search["value"] = searchValue.value;
|
|
|
|
searchValue.lastSearch = searchValue.value;
|
|
|
|
refreshCurrentFolder();
|
|
|
|
}
|
2007-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function initCriteria() {
|
2009-07-28 20:36:06 +02:00
|
|
|
var searchCriteria = $("searchCriteria");
|
|
|
|
var searchValue = $("searchValue");
|
|
|
|
var searchOptions = $("searchOptions");
|
|
|
|
|
|
|
|
if (searchValue) {
|
|
|
|
var firstOption = searchOptions.down("li");
|
|
|
|
if (firstOption) {
|
|
|
|
searchCriteria.value = firstOption.getAttribute('id');
|
|
|
|
searchValue.ghostPhrase = firstOption.innerHTML;
|
|
|
|
searchValue.lastSearch = "";
|
|
|
|
if (searchValue.value == '') {
|
|
|
|
searchValue.value = firstOption.innerHTML;
|
|
|
|
searchValue.setAttribute("modified", "");
|
2009-11-04 23:13:20 +01:00
|
|
|
searchValue.setStyle({ color: "#909090" });
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
|
|
|
// Set the checkmark to the first option
|
|
|
|
if (searchOptions.chosenNode)
|
|
|
|
searchOptions.chosenNode.removeClassName("_chosen");
|
|
|
|
firstOption.addClassName("_chosen");
|
|
|
|
searchOptions.chosenNode = firstOption;
|
|
|
|
}
|
|
|
|
searchValue.blur();
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
2007-01-03 22:08:56 +01:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
/* toolbar buttons */
|
2007-07-05 21:13:59 +02:00
|
|
|
function popupToolbarMenu(node, menuId) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
2007-07-05 21:13:59 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var popup = $(menuId);
|
2010-08-06 14:37:28 +02:00
|
|
|
if (popup.prepareVisibility) {
|
2009-07-28 20:36:06 +02:00
|
|
|
popup.prepareVisibility();
|
2010-08-06 14:37:28 +02:00
|
|
|
}
|
2008-01-08 21:29:51 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var offset = $(node).cumulativeOffset();
|
|
|
|
var top = offset.top + node.offsetHeight;
|
|
|
|
popup.setStyle({ top: top + "px",
|
2010-03-09 14:50:54 +01:00
|
|
|
left: offset.left + "px",
|
|
|
|
visibility: "visible" });
|
2007-07-05 21:13:59 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
document.currentPopupMenu = popup;
|
|
|
|
$(document.body).observe("mouseup", onBodyClickMenuHandler);
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
|
2006-08-14 22:31:49 +02:00
|
|
|
/* contact selector */
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function folderSubscriptionCallback(http) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
if (http.callbackData)
|
|
|
|
http.callbackData["method"](http.callbackData["data"]);
|
|
|
|
}
|
|
|
|
else
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("Unable to subscribe to that folder!"));
|
2009-07-28 20:36:06 +02:00
|
|
|
document.subscriptionAjaxRequest = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("folderSubscriptionCallback Ajax error");
|
2007-03-29 20:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function subscribeToFolder(refreshCallback, refreshCallbackData) {
|
2009-07-28 20:36:06 +02:00
|
|
|
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
|
2010-06-02 21:11:15 +02:00
|
|
|
refreshCallbackData["window"].alert(_("You cannot subscribe to a folder that you own!"));
|
2006-08-14 22:31:49 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function folderUnsubscriptionCallback(http) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
removeFolderRequestCount--;
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
if (http.callbackData)
|
|
|
|
http.callbackData["method"](http.callbackData["data"]);
|
|
|
|
}
|
|
|
|
else
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("Unable to unsubscribe from that folder!"));
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
2007-03-29 20:02:48 +02:00
|
|
|
}
|
2006-10-14 01:35:10 +02:00
|
|
|
|
2009-09-04 21:08:21 +02:00
|
|
|
function unsubscribeFromFolder(folderUrl, owner, refreshCallback,
|
2009-07-28 20:36:06 +02:00
|
|
|
refreshCallbackData) {
|
|
|
|
if (document.body.hasClassName("popup")) {
|
2009-09-04 21:08:21 +02:00
|
|
|
window.opener.unsubscribeFromFolder(folderUrl, owner, refreshCallback,
|
2009-07-28 20:36:06 +02:00
|
|
|
refreshCallbackData);
|
|
|
|
}
|
|
|
|
else {
|
2009-09-04 21:08:21 +02:00
|
|
|
if (owner.charAt(0) == '/')
|
2009-07-28 20:36:06 +02:00
|
|
|
owner = owner.substring(1);
|
|
|
|
if (owner != UserLogin) {
|
2009-09-04 21:08:21 +02:00
|
|
|
var url = folderUrl + "/unsubscribe";
|
2009-07-28 20:36:06 +02:00
|
|
|
removeFolderRequestCount++;
|
|
|
|
var rfCbData = { method: refreshCallback, data: refreshCallbackData };
|
|
|
|
triggerAjaxRequest(url, folderUnsubscriptionCallback, rfCbData);
|
|
|
|
}
|
|
|
|
else
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("You cannot unsubscribe from a folder that you own!"));
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function accessToSubscribedFolder(serverFolder) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var folder;
|
2007-09-15 00:01:02 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var parts = serverFolder.split(":");
|
|
|
|
if (parts.length > 1) {
|
|
|
|
var paths = parts[1].split("/");
|
|
|
|
folder = "/" + parts[0].asCSSIdentifier() + "_" + paths[2];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
folder = serverFolder;
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return folder;
|
2006-08-31 01:02:53 +02:00
|
|
|
}
|
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
function getSubscribedFolderOwner(serverFolder) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var owner;
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var parts = serverFolder.split(":");
|
|
|
|
if (parts.length > 1) {
|
|
|
|
owner = parts[0];
|
|
|
|
}
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return owner;
|
2007-10-23 16:39:29 +02:00
|
|
|
}
|
|
|
|
|
2007-12-06 21:50:20 +01:00
|
|
|
function getListIndexForFolder(items, owner, folderName) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var i;
|
|
|
|
var previousOwner = null;
|
|
|
|
|
2010-08-06 19:42:03 +02:00
|
|
|
for (i = 0; i < items.length; i++) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var currentFolderName = items[i].lastChild.nodeValue.strip();
|
|
|
|
var currentOwner = items[i].readAttribute('owner');
|
|
|
|
if (currentOwner == owner) {
|
|
|
|
previousOwner = currentOwner;
|
|
|
|
if (currentFolderName > folderName)
|
|
|
|
break;
|
|
|
|
}
|
2010-08-06 19:42:03 +02:00
|
|
|
else if (previousOwner ||
|
|
|
|
(currentOwner != UserLogin && currentOwner > owner)) {
|
2009-07-28 20:36:06 +02:00
|
|
|
break;
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
|
|
|
else if (currentOwner == "nobody") {
|
2009-07-28 20:36:06 +02:00
|
|
|
break;
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
2007-12-06 21:50:20 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function listRowMouseDownHandler(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
preventDefault(event);
|
|
|
|
return false;
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
2009-04-22 23:02:11 +02:00
|
|
|
function reverseSortByAlarmTime(a, b) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var x = parseInt(a[2]);
|
|
|
|
var y = parseInt(b[2]);
|
|
|
|
return (y - x);
|
2009-04-22 23:02:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function refreshAlarms() {
|
2009-07-28 20:36:06 +02:00
|
|
|
var url;
|
|
|
|
var now = new Date();
|
|
|
|
var utc = Math.floor(now.getTime()/1000);
|
2009-04-22 23:02:11 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (document.alarmsListAjaxRequest)
|
|
|
|
return false;
|
|
|
|
url = UserFolderURL + "Calendar/alarmslist?browserTime=" + utc;
|
2010-08-06 19:42:03 +02:00
|
|
|
document.alarmsListAjaxRequest
|
2009-07-28 20:36:06 +02:00
|
|
|
= triggerAjaxRequest(url, refreshAlarmsCallback);
|
2009-04-22 23:02:11 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return true;
|
2009-04-22 23:02:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function refreshAlarmsCallback(http) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.alarmsListAjaxRequest = null;
|
2010-03-09 14:50:06 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
Alarms = http.responseText.evalJSON(true);
|
|
|
|
Alarms.sort(reverseSortByAlarmTime);
|
|
|
|
triggerNextAlarm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("refreshAlarmsCallback Ajax error");
|
2009-04-22 23:02:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function triggerNextAlarm() {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (Alarms.length > 0) {
|
|
|
|
var next = Alarms.pop();
|
|
|
|
var now = new Date();
|
|
|
|
var utc = Math.floor(now.getTime()/1000);
|
|
|
|
var url = next[0] + '/' + next[1];
|
|
|
|
var alarmTime = parseInt(next[2]);
|
|
|
|
var delay = alarmTime;
|
2009-10-02 15:42:19 +02:00
|
|
|
if (alarmTime > 0) delay -= utc;
|
2009-07-28 20:36:06 +02:00
|
|
|
var d = new Date(alarmTime*1000);
|
|
|
|
log ("now = " + now.toUTCString());
|
|
|
|
log ("next event " + url + " in " + delay + " seconds (on " + d.toUTCString() + ")");
|
|
|
|
showAlarm.delay(delay, url);
|
|
|
|
}
|
2009-04-22 23:02:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function showAlarm(url) {
|
2009-07-28 20:36:06 +02:00
|
|
|
url = UserFolderURL + "Calendar/" + url + "/view?resetAlarm=yes";
|
|
|
|
if (document.viewAlarmAjaxRequest) {
|
|
|
|
document.viewAlarmAjaxRequest.aborted = true;
|
|
|
|
document.viewAlarmAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.viewAlarmAjaxRequest = triggerAjaxRequest(url, showAlarmCallback);
|
2009-04-22 23:02:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function showAlarmCallback(http) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
if (http.responseText.length) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
2010-06-02 21:11:15 +02:00
|
|
|
var msg = _("Reminder:") + " " + data["summary"] + "\n";
|
2009-07-28 20:36:06 +02:00
|
|
|
if (data["startDate"]) {
|
2010-06-02 21:11:15 +02:00
|
|
|
msg += _("Start:") + " " + data["startDate"];
|
2009-07-28 20:36:06 +02:00
|
|
|
if (parseInt(data["isAllDay"]) == 0)
|
|
|
|
msg += " - " + data["startTime"];
|
|
|
|
msg += "\n";
|
|
|
|
}
|
|
|
|
if (data["dueDate"]) {
|
2010-06-02 21:11:15 +02:00
|
|
|
msg += _("Due Date:") + " " + data["dueDate"];
|
2009-07-28 20:36:06 +02:00
|
|
|
if (data["dueTime"])
|
|
|
|
msg += " - " + data["dueTime"];
|
|
|
|
msg += "\n";
|
|
|
|
}
|
|
|
|
if (data["location"].length)
|
2010-06-02 21:11:15 +02:00
|
|
|
msg += "\n" + _("Location:") + " " + data["location"];
|
2009-07-28 20:36:06 +02:00
|
|
|
if (data["description"].length)
|
|
|
|
msg += "\n\n" + data["description"];
|
|
|
|
|
|
|
|
window.alert(msg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log("showAlarmCallback ajax error: no data received");
|
|
|
|
}
|
|
|
|
else {
|
2009-10-02 15:42:19 +02:00
|
|
|
log("showAlarmCallback ajax error (" + http.status + "): " + http.url);
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
triggerNextAlarm();
|
2009-04-22 23:02:11 +02:00
|
|
|
}
|
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
function initMenus() {
|
2009-07-28 20:36:06 +02:00
|
|
|
var menus = getMenus();
|
|
|
|
if (menus) {
|
|
|
|
for (var menuID in menus) {
|
|
|
|
var menuDIV = $(menuID);
|
|
|
|
if (menuDIV)
|
|
|
|
initMenu(menuDIV, menus[menuID]);
|
|
|
|
}
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
function initMenu(menuDIV, callbacks) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var uls = menuDIV.childNodesWithTag("ul");
|
|
|
|
for (var i = 0; i < uls.length; i++) {
|
|
|
|
var lis = $(uls[i]).childNodesWithTag("li");
|
|
|
|
for (var j = 0; j < lis.length; j++) {
|
|
|
|
var node = $(lis[j]);
|
|
|
|
node.observe("mousedown", listRowMouseDownHandler, false);
|
|
|
|
var callback;
|
|
|
|
if (i > 0)
|
|
|
|
callback = callbacks[i+j+1];
|
|
|
|
else
|
|
|
|
callback = callbacks[i+j];
|
|
|
|
if (callback) {
|
|
|
|
if (typeof(callback) == "string") {
|
|
|
|
if (callback == "-")
|
|
|
|
node.addClassName("separator");
|
|
|
|
else {
|
|
|
|
node.submenu = callback;
|
|
|
|
node.addClassName("submenu");
|
|
|
|
node.observe("mouseover", popupSubmenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
node.observe("mouseup", onBodyClickMenuHandler);
|
|
|
|
node.menuCallback = callback;
|
|
|
|
node.observe("click", onMenuClickHandler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
node.addClassName("disabled");
|
|
|
|
}
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2006-09-16 00:27:59 +02:00
|
|
|
function openExternalLink(anchor) {
|
2009-07-28 20:36:06 +02:00
|
|
|
return false;
|
2006-09-16 00:27:59 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function openAclWindow(url) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var w = window.open(url, "aclWindow",
|
|
|
|
"width=420,height=300,resizable=1,scrollbars=1,toolbar=0,"
|
|
|
|
+ "location=0,directories=0,status=0,menubar=0"
|
|
|
|
+ ",copyhistory=0");
|
|
|
|
w.opener = window;
|
|
|
|
w.focus();
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return w;
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-04-28 00:06:58 +02:00
|
|
|
function getUsersRightsWindowHeight() {
|
2009-07-28 20:36:06 +02:00
|
|
|
return usersRightsWindowHeight;
|
2007-04-28 00:06:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getUsersRightsWindowWidth() {
|
2009-07-28 20:36:06 +02:00
|
|
|
return usersRightsWindowWidth;
|
2007-04-28 00:06:58 +02:00
|
|
|
}
|
|
|
|
|
2007-05-04 17:57:23 +02:00
|
|
|
function getTopWindow() {
|
2009-07-28 20:36:06 +02:00
|
|
|
var topWindow = null;
|
|
|
|
var currentWindow = window;
|
|
|
|
while (!topWindow) {
|
|
|
|
if (currentWindow.document.body.hasClassName("popup")
|
|
|
|
&& currentWindow.opener)
|
|
|
|
currentWindow = currentWindow.opener;
|
|
|
|
else
|
|
|
|
topWindow = currentWindow;
|
|
|
|
}
|
2007-05-04 17:57:23 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return topWindow;
|
2007-05-04 17:57:23 +02:00
|
|
|
}
|
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
//function enableAnchor(anchor) {
|
|
|
|
// var classStr = '' + anchor.getAttribute("class");
|
|
|
|
// var position = classStr.indexOf("_disabled", 0);
|
|
|
|
// if (position > -1) {
|
|
|
|
// var disabledHref = anchor.getAttribute("disabled-href");
|
|
|
|
// if (disabledHref)
|
|
|
|
// anchor.setAttribute("href", disabledHref);
|
|
|
|
// var disabledOnclick = anchor.getAttribute("disabled-onclick");
|
|
|
|
// if (disabledOnclick)
|
|
|
|
// anchor.setAttribute("onclick", disabledOnclick);
|
|
|
|
// anchor.removeClassName("_disabled");
|
|
|
|
// anchor.setAttribute("disabled-href", null);
|
|
|
|
// anchor.setAttribute("disabled-onclick", null);
|
|
|
|
// anchor.disabled = 0;
|
|
|
|
// anchor.enabled = 1;
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
//function disableAnchor(anchor) {
|
|
|
|
// var classStr = '' + anchor.getAttribute("class");
|
|
|
|
// var position = classStr.indexOf("_disabled", 0);
|
|
|
|
// if (position < 0) {
|
|
|
|
// var href = anchor.getAttribute("href");
|
|
|
|
// if (href)
|
|
|
|
// anchor.setAttribute("disabled-href", href);
|
|
|
|
// var onclick = anchor.getAttribute("onclick");
|
|
|
|
// if (onclick)
|
|
|
|
// anchor.setAttribute("disabled-onclick", onclick);
|
|
|
|
// anchor.addClassName("_disabled");
|
|
|
|
// anchor.setAttribute("href", "#");
|
|
|
|
// anchor.setAttribute("onclick", "return false;");
|
|
|
|
// anchor.disabled = 1;
|
|
|
|
// anchor.enabled = 0;
|
|
|
|
// }
|
|
|
|
//}
|
2006-10-23 23:37:22 +02:00
|
|
|
|
2006-10-17 00:34:11 +02:00
|
|
|
function d2h(d) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var hD = "0123456789abcdef";
|
|
|
|
var h = hD.substr(d & 15, 1);
|
2007-01-30 22:41:24 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
while (d > 15) {
|
|
|
|
d >>= 4;
|
|
|
|
h = hD.substr(d & 15, 1) + h;
|
|
|
|
}
|
2007-01-30 22:41:24 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return h;
|
2006-10-17 00:34:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function indexColor(number) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var color;
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
if (number == 0)
|
|
|
|
color = "#ccf";
|
|
|
|
else {
|
|
|
|
var colorTable = new Array(1, 1, 1);
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
var currentValue = number;
|
|
|
|
var index = 0;
|
|
|
|
while (currentValue) {
|
|
|
|
if (currentValue & 1)
|
|
|
|
colorTable[index]++;
|
|
|
|
if (index == 3)
|
|
|
|
index = 0;
|
|
|
|
currentValue >>= 1;
|
|
|
|
index++;
|
|
|
|
}
|
2008-11-24 02:54:12 +01:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
color = ("#"
|
|
|
|
+ d2h((256 / colorTable[2]) - 1)
|
|
|
|
+ d2h((256 / colorTable[1]) - 1)
|
|
|
|
+ d2h((256 / colorTable[0]) - 1));
|
|
|
|
}
|
2006-10-17 00:34:11 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return color;
|
2006-10-17 00:34:11 +02:00
|
|
|
}
|
2006-11-09 00:48:11 +01:00
|
|
|
|
2007-05-28 15:18:31 +02:00
|
|
|
function onLoadHandler(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
queryParameters = parseQueryParameters('' + window.location);
|
|
|
|
if (!$(document.body).hasClassName("popup")) {
|
|
|
|
initLogConsole();
|
2009-09-18 15:36:40 +02:00
|
|
|
if ($("calendarBannerLink")) {
|
|
|
|
refreshAlarms();
|
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
}
|
|
|
|
initCriteria();
|
|
|
|
configureSearchField();
|
|
|
|
initMenus();
|
|
|
|
configureDragHandles();
|
|
|
|
configureLinkBanner();
|
|
|
|
var progressImage = $("progressIndicator");
|
|
|
|
if (progressImage)
|
|
|
|
progressImage.parentNode.removeChild(progressImage);
|
|
|
|
$(document.body).observe("contextmenu", onBodyClickContextMenu);
|
|
|
|
|
|
|
|
onFinalLoadHandler();
|
2007-05-28 15:18:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onBodyClickContextMenu(event) {
|
2010-06-05 06:45:00 +02:00
|
|
|
var target = $(event.target);
|
|
|
|
if (!(target
|
|
|
|
&& (target.tagName == "INPUT"
|
|
|
|
|| target.tagName == "TEXTAREA"
|
|
|
|
|| (target.tagName == "A"
|
|
|
|
&& target.hasClassName("clickableLink")))))
|
2009-07-28 20:36:06 +02:00
|
|
|
preventDefault(event);
|
2006-11-09 00:48:11 +01:00
|
|
|
}
|
|
|
|
|
2007-09-24 23:26:23 +02:00
|
|
|
function configureSortableTableHeaders(table) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var headers = $(table).getElementsByClassName("sortableTableHeader");
|
|
|
|
for (var i = 0; i < headers.length; i++) {
|
|
|
|
var header = $(headers[i]);
|
|
|
|
header.observe("selectstart", listRowMouseDownHandler);
|
|
|
|
header.stopObserving("click", onHeaderClick);
|
|
|
|
header.observe("click", onHeaderClick);
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
2006-11-15 23:52:41 +01:00
|
|
|
function onLinkBannerClick() {
|
2009-07-28 20:36:06 +02:00
|
|
|
activeAjaxRequests++;
|
|
|
|
checkAjaxRequestsState();
|
2006-11-15 23:52:41 +01:00
|
|
|
}
|
|
|
|
|
2007-06-19 19:59:59 +02:00
|
|
|
function onPreferencesClick(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var urlstr = UserFolderURL + "preferences";
|
|
|
|
var w = window.open(urlstr, "_blank",
|
2010-09-01 22:49:17 +02:00
|
|
|
"width=580,height=450,resizable=1,scrollbars=0,location=0");
|
2009-07-28 20:36:06 +02:00
|
|
|
w.opener = window;
|
|
|
|
w.focus();
|
2007-06-19 19:59:59 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
preventDefault(event);
|
2007-06-19 19:59:59 +02:00
|
|
|
}
|
|
|
|
|
2006-11-15 23:52:41 +01:00
|
|
|
function configureLinkBanner() {
|
2009-07-28 20:36:06 +02:00
|
|
|
var linkBanner = $("linkBanner");
|
|
|
|
if (linkBanner) {
|
|
|
|
var moduleLinks = [ "calendar", "contacts", "mail" ];
|
|
|
|
for (var i = 0; i < moduleLinks.length; i++) {
|
|
|
|
var link = $(moduleLinks[i] + "BannerLink");
|
|
|
|
if (link) {
|
|
|
|
link.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
link.observe("click", onLinkBannerClick);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
link = $("preferencesBannerLink");
|
|
|
|
if (link) {
|
|
|
|
link.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
link.observe("click", onPreferencesClick);
|
|
|
|
}
|
|
|
|
link = $("consoleBannerLink");
|
|
|
|
if (link) {
|
|
|
|
link.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
link.observe("click", toggleLogConsole);
|
|
|
|
}
|
|
|
|
}
|
2006-11-15 23:52:41 +01:00
|
|
|
}
|
|
|
|
|
2010-06-03 16:43:38 +02:00
|
|
|
function CurrentModule() {
|
|
|
|
var module = null;
|
|
|
|
if (ApplicationBaseURL) {
|
|
|
|
var parts = ApplicationBaseURL.split("/");
|
|
|
|
var last = parts.length - 1;
|
|
|
|
while (last > -1 && parts[last] == "") {
|
|
|
|
last--;
|
|
|
|
}
|
|
|
|
if (last > -1) {
|
|
|
|
module = parts[last];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
|
2009-06-11 21:55:13 +02:00
|
|
|
/* accessing another user's data */
|
|
|
|
function UserFolderURLForUser(user) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var folderArray = UserFolderURL.split("/");
|
|
|
|
var count;
|
|
|
|
if (UserFolderURL.endsWith('/'))
|
|
|
|
count = folderArray.length - 2;
|
|
|
|
else
|
|
|
|
count = folderArray.length - 1;
|
|
|
|
folderArray[count] = escape(user);
|
2009-06-11 21:55:13 +02:00
|
|
|
|
2009-07-28 20:36:06 +02:00
|
|
|
return folderArray.join("/");
|
2009-06-11 21:55:13 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
/* folder creation */
|
|
|
|
function createFolder(name, okCB, notOkCB) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (name) {
|
|
|
|
if (document.newFolderAjaxRequest) {
|
|
|
|
document.newFolderAjaxRequest.aborted = true;
|
|
|
|
document.newFolderAjaxRequest.abort();
|
|
|
|
}
|
2009-08-25 08:55:03 +02:00
|
|
|
var url = ApplicationBaseURL + "/createFolder?name=" + escape(name.utf8encode());
|
2009-07-28 20:36:06 +02:00
|
|
|
document.newFolderAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, createFolderCallback,
|
|
|
|
{name: name,
|
|
|
|
okCB: okCB,
|
|
|
|
notOkCB: notOkCB});
|
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function createFolderCallback(http) {
|
2009-07-28 20:36:06 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
var data = http.callbackData;
|
|
|
|
if (http.status == 201) {
|
|
|
|
if (data.okCB)
|
|
|
|
data.okCB(data.name, "/" + http.responseText, UserLogin);
|
|
|
|
}
|
2009-08-20 15:02:51 +02:00
|
|
|
else if (http.status == 409) {
|
2010-06-02 21:11:15 +02:00
|
|
|
alert (_("A folder by that name already exists."));
|
2009-08-20 15:02:51 +02:00
|
|
|
}
|
2009-07-28 20:36:06 +02:00
|
|
|
else {
|
|
|
|
if (data.notOkCB)
|
|
|
|
data.notOkCB(name);
|
|
|
|
else
|
|
|
|
log("ajax problem:" + http.status);
|
|
|
|
}
|
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
/* invitation delegation */
|
|
|
|
function delegateInvitation(componentUrl, callbackFunction, callbackData) {
|
|
|
|
var input = $("delegatedTo");
|
|
|
|
var delegatedTo = null;
|
2010-08-06 19:42:03 +02:00
|
|
|
if (input.readAttribute("uid") != null) {
|
2009-10-28 18:48:22 +01:00
|
|
|
delegatedTo = input.readAttribute("uid");
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
|
|
|
else if (input.value.blank()) {
|
2010-06-02 21:11:15 +02:00
|
|
|
alert(_("noEmailForDelegation"));
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
|
|
|
else {
|
2009-09-10 20:31:20 +02:00
|
|
|
delegatedTo = input.value;
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
2010-03-09 14:50:06 +01:00
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
if (delegatedTo) {
|
|
|
|
var receiveUpdates = false; //confirm("Do you want to keep receiving updates on the event?");
|
|
|
|
var urlstr = componentUrl + "/delegate";
|
|
|
|
var parameters = "to=" + delegatedTo + "&receiveUpdates=" + (receiveUpdates?"YES":"NO");
|
2010-08-06 19:44:36 +02:00
|
|
|
triggerAjaxRequest(urlstr, callbackFunction, callbackData, parameters,
|
|
|
|
{ "Content-type": "application/x-www-form-urlencoded" });
|
2009-09-10 20:31:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-09 16:18:47 +01:00
|
|
|
function onFinalLoadHandler(event) {
|
2009-07-28 20:36:06 +02:00
|
|
|
var safetyNet = $("javascriptSafetyNet");
|
|
|
|
if (safetyNet)
|
|
|
|
safetyNet.parentNode.removeChild(safetyNet);
|
2007-11-09 16:18:47 +01:00
|
|
|
}
|
|
|
|
|
2007-06-28 22:34:35 +02:00
|
|
|
function parent$(element) {
|
2009-07-28 20:36:06 +02:00
|
|
|
return this.opener.document.getElementById(element);
|
2007-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
/* stubs */
|
2007-06-28 22:34:35 +02:00
|
|
|
function refreshCurrentFolder() {
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function configureDragHandles() {
|
|
|
|
}
|
|
|
|
|
2007-05-28 21:19:17 +02:00
|
|
|
function getMenus() {
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onHeaderClick(event) {
|
|
|
|
}
|
2008-09-09 21:23:31 +02:00
|
|
|
|
2010-03-02 20:53:53 +01:00
|
|
|
function _(key) {
|
|
|
|
var value = key;
|
|
|
|
if (labels[key]) {
|
|
|
|
value = labels[key];
|
2009-09-11 22:25:06 +02:00
|
|
|
}
|
2010-03-02 20:53:53 +01:00
|
|
|
else {
|
|
|
|
var topWindow = null;
|
|
|
|
if (!topWindow) {
|
|
|
|
topWindow = window;
|
|
|
|
while (topWindow.opener)
|
|
|
|
topWindow = topWindow.opener;
|
|
|
|
}
|
2010-03-08 21:52:37 +01:00
|
|
|
if (topWindow && topWindow.clabels && topWindow.clabels[key])
|
2010-03-02 20:53:53 +01:00
|
|
|
value = topWindow.clabels[key];
|
2009-09-11 22:25:06 +02:00
|
|
|
}
|
2010-03-02 20:53:53 +01:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2009-10-02 15:42:19 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* AJAX IFRAME METHOD (AIM)
|
|
|
|
* http://www.webtoolkit.info/
|
|
|
|
*
|
|
|
|
**/
|
2010-03-09 14:50:06 +01:00
|
|
|
|
2009-10-02 15:42:19 +02:00
|
|
|
AIM = {
|
2010-08-06 19:42:03 +02:00
|
|
|
frame: function(c) {
|
2009-10-02 15:42:19 +02:00
|
|
|
var d = new Element ('div');
|
|
|
|
var n = d.identify ();
|
2010-09-03 00:03:50 +02:00
|
|
|
d.innerHTML = '<iframe class="hidden" src="about:blank" id="'
|
2010-08-06 19:42:03 +02:00
|
|
|
+ n + '" name="' + n + '" onload="AIM.loaded(\'' + n + '\')"></iframe>';
|
2009-10-02 15:42:19 +02:00
|
|
|
document.body.appendChild(d);
|
|
|
|
var i = $(n); // TODO: useful?
|
|
|
|
if (c && typeof(c.onComplete) == 'function')
|
|
|
|
i.onComplete = c.onComplete;
|
|
|
|
return n;
|
|
|
|
},
|
2010-03-09 14:50:06 +01:00
|
|
|
|
2010-08-06 19:42:03 +02:00
|
|
|
form: function(f, name) {
|
2009-10-02 15:42:19 +02:00
|
|
|
f.writeAttribute('target', name);
|
|
|
|
},
|
2010-03-09 14:50:06 +01:00
|
|
|
|
2010-08-06 19:42:03 +02:00
|
|
|
submit: function(f, c) {
|
2009-10-02 15:42:19 +02:00
|
|
|
AIM.form(f, AIM.frame(c));
|
|
|
|
if (c && typeof(c.onStart) == 'function')
|
|
|
|
return c.onStart();
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
},
|
2010-03-09 14:50:06 +01:00
|
|
|
|
2010-08-06 19:42:03 +02:00
|
|
|
loaded: function(id) {
|
2009-10-02 15:42:19 +02:00
|
|
|
var i = $(id);
|
2010-08-06 19:42:03 +02:00
|
|
|
if (i.contentDocument) {
|
2009-10-02 15:42:19 +02:00
|
|
|
var d = i.contentDocument;
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
|
|
|
else if (i.contentWindow) {
|
2009-10-02 15:42:19 +02:00
|
|
|
var d = i.contentWindow.document;
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
|
|
|
else {
|
2009-10-02 15:42:19 +02:00
|
|
|
var d = window.frames[id].document;
|
2010-08-06 19:42:03 +02:00
|
|
|
}
|
2009-10-02 15:42:19 +02:00
|
|
|
if (d.location.href == "about:blank")
|
|
|
|
return;
|
2010-03-09 14:50:06 +01:00
|
|
|
|
2010-08-23 22:58:41 +02:00
|
|
|
if (typeof(i.onComplete) == 'function') {
|
|
|
|
i.onComplete(Element.allTextContent(d.body));
|
|
|
|
}
|
2009-10-02 15:42:19 +02:00
|
|
|
}
|
2010-03-08 16:18:05 +01:00
|
|
|
};
|
|
|
|
|
2010-03-08 21:52:37 +01:00
|
|
|
function createDialog(id, title, legend, content, positionClass) {
|
|
|
|
if (!positionClass)
|
|
|
|
positionClass = "left";
|
|
|
|
var newDialog = createElement("div", id, ["dialog", positionClass]);
|
|
|
|
newDialog.setStyle({"display": "none"});
|
|
|
|
|
2010-08-04 19:59:43 +02:00
|
|
|
if (positionClass == "none") {
|
|
|
|
var bgDiv = $("bgDialogDiv");
|
|
|
|
if (bgDiv) {
|
|
|
|
bgDiv.show();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bgDiv = createElement("div", "bgDialogDiv", ["bgDialog"]);
|
|
|
|
document.body.appendChild(bgDiv);
|
2010-09-20 16:36:02 +02:00
|
|
|
//bgDiv.observe("click", disposeDialog);
|
2010-08-04 19:59:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-08 21:52:37 +01:00
|
|
|
var subdiv = createElement("div", null, null, null, null, newDialog);
|
|
|
|
if (title && title.length > 0) {
|
|
|
|
var titleh3 = createElement("h3", null, null, null, null, subdiv);
|
|
|
|
titleh3.appendChild(document.createTextNode(title));
|
|
|
|
}
|
|
|
|
if (legend && legend.length > 0) {
|
|
|
|
var legendP = createElement("p", null, null, null, null, subdiv);
|
|
|
|
legendP.appendChild(document.createTextNode(legend));
|
|
|
|
}
|
|
|
|
if (content)
|
|
|
|
subdiv.appendChild(content);
|
2010-08-19 16:19:24 +02:00
|
|
|
createElement("hr", null, null, null, null, subdiv);
|
2010-03-08 21:52:37 +01:00
|
|
|
|
|
|
|
return newDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
function createButton(id, caption, action) {
|
|
|
|
var newButton = createElement("a", id, "button", { "href": "#" });
|
|
|
|
if (caption && caption.length > 0) {
|
|
|
|
var span = createElement("span", null, null, null, null, newButton);
|
|
|
|
span.appendChild(document.createTextNode(caption));
|
|
|
|
}
|
|
|
|
if (action)
|
|
|
|
newButton.observe("click", action);
|
|
|
|
|
|
|
|
return newButton;
|
|
|
|
}
|
2010-08-04 19:59:43 +02:00
|
|
|
|
2010-08-10 15:47:11 +02:00
|
|
|
function showAlertDialog(label) {
|
|
|
|
var div = $("bgDialogDiv");
|
|
|
|
if (div && div.visible()) {
|
|
|
|
dialogsStack.push(label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_showAlertDialog(label);
|
|
|
|
}
|
|
|
|
}
|
2010-08-12 19:34:32 +02:00
|
|
|
|
2010-08-10 15:47:11 +02:00
|
|
|
function _showAlertDialog(label) {
|
2010-08-19 16:19:24 +02:00
|
|
|
var dialog = dialogs[label];
|
2010-08-10 15:47:11 +02:00
|
|
|
if (dialog) {
|
|
|
|
$("bgDialogDiv").show();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var fields = createElement("p");
|
|
|
|
fields.appendChild(createButton(null,
|
|
|
|
_("OK"),
|
2010-08-19 16:19:24 +02:00
|
|
|
disposeDialog));
|
2010-08-10 15:47:11 +02:00
|
|
|
dialog = createDialog(null,
|
|
|
|
_("Warning"),
|
|
|
|
label,
|
|
|
|
fields,
|
|
|
|
"none");
|
|
|
|
document.body.appendChild(dialog);
|
|
|
|
dialogs[label] = dialog;
|
|
|
|
}
|
|
|
|
dialog.show();
|
|
|
|
}
|
|
|
|
|
2010-09-20 16:36:02 +02:00
|
|
|
function showConfirmDialog(title, label, callbackYes, callbackNo) {
|
2010-10-08 22:25:54 +02:00
|
|
|
var dialog = dialogs[title+label];
|
2010-08-19 23:26:31 +02:00
|
|
|
if (dialog) {
|
|
|
|
$("bgDialogDiv").show();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var fields = createElement("p");
|
2010-09-20 16:36:02 +02:00
|
|
|
fields.appendChild(createButton(null, _("Yes"), callbackYes));
|
|
|
|
fields.appendChild(createButton(null, _("No"), callbackNo || disposeDialog));
|
2010-08-19 23:26:31 +02:00
|
|
|
dialog = createDialog(null,
|
|
|
|
title,
|
|
|
|
label,
|
|
|
|
fields,
|
|
|
|
"none");
|
|
|
|
document.body.appendChild(dialog);
|
2010-10-08 22:25:54 +02:00
|
|
|
dialogs[title+label] = dialog;
|
2010-08-19 23:26:31 +02:00
|
|
|
}
|
|
|
|
dialog.show();
|
|
|
|
}
|
|
|
|
|
2010-08-19 16:19:24 +02:00
|
|
|
function showPromptDialog(title, label, callback, defaultValue) {
|
2010-10-08 22:25:54 +02:00
|
|
|
var dialog = dialogs[title+label];
|
2010-08-19 16:19:24 +02:00
|
|
|
v = defaultValue?defaultValue:"";
|
|
|
|
if (dialog) {
|
|
|
|
$("bgDialogDiv").show();
|
|
|
|
dialog.down("input").value = v;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var fields = createElement("p", null, ["prompt"]);
|
|
|
|
fields.appendChild(document.createTextNode(label));
|
|
|
|
var input = createElement("input", null, "textField",
|
|
|
|
{ type: "text", "value": v },
|
|
|
|
{ previousValue: v });
|
|
|
|
fields.appendChild(input);
|
|
|
|
fields.appendChild(createButton(null,
|
|
|
|
_("OK"),
|
|
|
|
callback.bind(input)));
|
|
|
|
fields.appendChild(createButton(null,
|
|
|
|
"Cancel",
|
|
|
|
disposeDialog));
|
|
|
|
dialog = createDialog(null,
|
|
|
|
title,
|
|
|
|
null,
|
|
|
|
fields,
|
|
|
|
"none");
|
|
|
|
document.body.appendChild(dialog);
|
2010-10-08 22:25:54 +02:00
|
|
|
dialogs[title+label] = dialog;
|
2010-08-19 16:19:24 +02:00
|
|
|
}
|
|
|
|
dialog.show();
|
|
|
|
dialog.down("input").focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
function disposeDialog() {
|
2010-08-05 17:57:09 +02:00
|
|
|
$$("DIV.dialog").each(function(div) {
|
2010-08-06 19:42:03 +02:00
|
|
|
if (div.visible())
|
|
|
|
div.hide();
|
|
|
|
});
|
2010-08-05 17:57:09 +02:00
|
|
|
|
2010-08-10 15:47:11 +02:00
|
|
|
if (dialogsStack.length > 0) {
|
|
|
|
var label = dialogsStack.first();
|
|
|
|
dialogsStack.splice(0, 1);
|
|
|
|
_showAlertDialog.delay(0.1, label);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
$("bgDialogDiv").hide();
|
2010-08-04 19:59:43 +02:00
|
|
|
}
|
2010-03-08 21:52:37 +01:00
|
|
|
|
2010-03-08 16:18:05 +01:00
|
|
|
function readCookie(name) {
|
2010-03-08 21:52:37 +01:00
|
|
|
var foundCookie = null;
|
|
|
|
|
|
|
|
var prefix = name + "=";
|
|
|
|
var pairs = document.cookie.split(';');
|
|
|
|
for (var i = 0; !foundCookie && i < pairs.length; i++) {
|
|
|
|
var currentPair = pairs[i];
|
|
|
|
var start = 0;
|
|
|
|
while (currentPair.charAt(start) == " ")
|
|
|
|
start++;
|
|
|
|
if (start > 0)
|
|
|
|
currentPair = currentPair.substr(start);
|
|
|
|
if (currentPair.indexOf(prefix) == 0)
|
|
|
|
foundCookie = currentPair.substr(prefix.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
return foundCookie;
|
2010-03-08 16:18:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function readLoginCookie() {
|
|
|
|
var loginValues = null;
|
|
|
|
var cookie = readCookie("0xHIGHFLYxSOGo");
|
|
|
|
if (cookie && cookie.length > 8) {
|
2010-03-09 14:50:06 +01:00
|
|
|
var value = decodeURIComponent(cookie.substr(8));
|
|
|
|
loginValues = value.base64decode().split(":");
|
2010-03-08 16:18:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return loginValues;
|
|
|
|
}
|
|
|
|
|
2010-03-08 21:52:37 +01:00
|
|
|
/* logging widgets */
|
|
|
|
function SetLogMessage(containerId, message, msgType) {
|
|
|
|
var container = $(containerId);
|
|
|
|
if (container) {
|
|
|
|
if (!msgType)
|
|
|
|
msgType = "error";
|
|
|
|
var typeClass = msgType + "Message";
|
|
|
|
if (!container.typeClass || container.typeClass != typeClass) {
|
|
|
|
if (container.typeClass) {
|
|
|
|
container.removeClassName(container.typeClass);
|
|
|
|
}
|
|
|
|
container.typeClass = typeClass;
|
|
|
|
container.addClassName(typeClass);
|
|
|
|
}
|
2010-03-11 14:34:37 +01:00
|
|
|
if (container.message != message) {
|
2010-03-08 21:52:37 +01:00
|
|
|
while (container.lastChild) {
|
|
|
|
container.removeChild(container.lastChild);
|
|
|
|
}
|
2010-03-11 14:43:41 +01:00
|
|
|
if (message && message.length > 0) {
|
2010-03-08 21:52:37 +01:00
|
|
|
var sentences = message.split("\n");
|
|
|
|
container.appendChild(document.createTextNode(sentences[0]));
|
|
|
|
for (var i = 1; i < sentences.length; i++) {
|
|
|
|
container.appendChild(document.createElement("br"));
|
|
|
|
container.appendChild(document.createTextNode(sentences[i]));
|
|
|
|
}
|
|
|
|
}
|
2010-03-11 14:34:37 +01:00
|
|
|
container.message = message;
|
2010-03-08 21:52:37 +01:00
|
|
|
}
|
|
|
|
}
|
2009-10-02 15:42:19 +02:00
|
|
|
}
|
2009-09-03 19:53:38 +02:00
|
|
|
|
2009-03-06 22:12:42 +01:00
|
|
|
document.observe("dom:loaded", onLoadHandler);
|