eabc7b5151
Monotone-Revision: a6c4bbb57d662ad1aae7751dd65e2e239aebf3a6 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-10-03T22:06:00 Monotone-Branch: ca.inverse.sogo
150 lines
4.3 KiB
JavaScript
150 lines
4.3 KiB
JavaScript
/*
|
|
Copyright (C) 2005 SKYRIX Software AG
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
OGo 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.
|
|
|
|
OGo 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.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
02111-1307, USA.
|
|
*/
|
|
|
|
var uixEmailUsr =
|
|
"([a-zA-Z0-9][a-zA-Z0-9_.-]*|\"([^\\\\\x80-\xff\015\012\"]|\\\\[^\x80-\xff])+\")";
|
|
var uixEmailDomain =
|
|
"([a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*[a-zA-Z0-9][a-zA-Z0-9._-]*\\.[a-zA-Z]{2,5}";
|
|
var uixEmailRegex = new RegExp("^"+uixEmailUsr+"\@"+uixEmailDomain+"$");
|
|
|
|
var displayNameChanged = false;
|
|
|
|
function unescapeCallbackParameter(s) {
|
|
if(!s || s.length == 0)
|
|
return s;
|
|
s = s.replace(/'/g, "'");
|
|
s = s.replace(/"/g, '"');
|
|
return s;
|
|
}
|
|
|
|
function copyContact(type, email, uid, sn,
|
|
cn, givenName, telephoneNumber, facsimileTelephoneNumber,
|
|
mobile, postalAddress, homePostalAddress,
|
|
departmentNumber, l)
|
|
{
|
|
// var type = arguments[0];
|
|
// var email = arguments[1];
|
|
// var uid = arguments[2];
|
|
// var sn = arguments[3];
|
|
// var givenName = arguments[4];
|
|
// var telephoneNumber = arguments[5];
|
|
// var facsimileTelephoneNumber = arguments[6];
|
|
// var mobile = arguments[7];
|
|
// var postalAddress = arguments[8];
|
|
// var homePostalAddress = arguments[9];
|
|
// var departmentNumber = arguments[10];
|
|
// var l = arguments[11];
|
|
var e;
|
|
e = $('cn');
|
|
e.setAttribute('value', unescapeCallbackParameter(cn));
|
|
e = $('email');
|
|
e.setAttribute('value', email);
|
|
e = $('sn');
|
|
e.setAttribute('value', unescapeCallbackParameter(sn));
|
|
e = $('givenName');
|
|
e.setAttribute('value', unescapeCallbackParameter(givenName));
|
|
e = $('telephoneNumber');
|
|
e.setAttribute('value', telephoneNumber);
|
|
e = $('facsimileTelephoneNumber');
|
|
e.setAttribute('value', facsimileTelephoneNumber);
|
|
e = $('mobile');
|
|
e.setAttribute('value', mobile);
|
|
e = $('postalAddress');
|
|
e.setAttribute('value', unescapeCallbackParameter(postalAddress));
|
|
e = $('homePostalAddress');
|
|
e.setAttribute('value', unescapeCallbackParameter(homePostalAddress));
|
|
e = $('departmentNumber');
|
|
e.setAttribute('value', unescapeCallbackParameter(departmentNumber));
|
|
e = $('l');
|
|
e.setAttribute('value', unescapeCallbackParameter(l));
|
|
};
|
|
|
|
function validateContactEditor() {
|
|
var e;
|
|
|
|
e = $('workMail');
|
|
if (e.value.length == 0)
|
|
return true;
|
|
if (uixEmailRegex.test(e.value) != true)
|
|
return confirm(labels.invalidemailwarn);
|
|
|
|
e = $('homeMail');
|
|
if (e.value.length == 0)
|
|
return true;
|
|
if (uixEmailRegex.test(e.value) != true)
|
|
return confirm(labels.invalidemailwarn);
|
|
|
|
return true;
|
|
}
|
|
|
|
function submitContact(thisForm) {
|
|
var action = $('jsaction');
|
|
action.setAttribute("name", "save:method");
|
|
action.setAttribute("value", "save");
|
|
|
|
if (validateContactEditor()) {
|
|
thisForm.submit();
|
|
if (window.opener.refreshContacts)
|
|
window.opener.setTimeout("refreshContacts(\""+ self.contactId +"\");", 200);
|
|
window.close();
|
|
}
|
|
}
|
|
|
|
function showCoords(node) {
|
|
node = $("givenName");
|
|
window.alert("x: " + node.cascadeLeftOffset()
|
|
+ ";y: " + node.cascadeTopOffset()
|
|
+ ";width: " + window.innerWidth
|
|
+ ";height: " + window.innerHeight);
|
|
}
|
|
|
|
function onFnKeyDown() {
|
|
var fn = $("fn");
|
|
fn.onkeydown = null;
|
|
displayNameChanged = true;
|
|
|
|
return true;
|
|
}
|
|
|
|
function onFnNewValue(event) {
|
|
if (!displayNameChanged) {
|
|
var sn = $("sn").value.trim();
|
|
var givenName = $("givenName").value.trim();
|
|
|
|
var fullName = givenName;
|
|
if (fullName && sn)
|
|
fullName += ' ';
|
|
fullName += sn;
|
|
|
|
$("fn").value = fullName;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
function initEditorForm(contactId) {
|
|
self.contactId = contactId;
|
|
displayNameChanged = ($("fn").value.length > 0);
|
|
$("fn").onkeydown = onFnKeyDown;
|
|
$("sn").onkeyup = onFnNewValue;
|
|
$("givenName").onkeyup = onFnNewValue;
|
|
}
|