From 3b01b245188774f96afea920ea0b5b1a89bb2a44 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 3 Oct 2006 16:17:22 +0000 Subject: [PATCH] Monotone-Parent: 135b84772e9b73061c99a315779b92027642e9d9 Monotone-Revision: 223b824cc57f0722ab6922a3c8363bff6d1a1ef6 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-10-03T16:17:22 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 ++ UI/WebServerResources/generic.js | 81 ++++++++++++-------------------- 2 files changed, 34 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31aa5d5c5..16b961b4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2006-10-03 Wolfgang Sourdeau + * UI/WebServerResources/generic.js: generalized emailstring + handling functions. Generalized address book access functions. + * UI/Contacts/UIxContactsListViewBase.m ([UIxContactsListViewBase -isPopup]): return YES if the "popup" query parameter is set. diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 130ee14e1..bf51cb699 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -114,28 +114,38 @@ function ml_stripActionInURL(url) { /* emails */ -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 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+"$"); -function sanitizeMailTo(dirtyMailTo) { +function extractEmailAddress(mailTo) { var email = ""; - var name = ""; var emailre = /([a-zA-Z0-9]+[a-zA-Z0-9\._-]+[a-zA-Z0-9]+@[a-zA-Z0-9]+[a-zA-Z0-9\._-]+[a-zA-Z0-9]+)/g; - if (emailre.test(dirtyMailTo)) { - emailre.exec(dirtyMailTo); + if (emailre.test(mailTo)) { + emailre.exec(mailTo); email = RegExp.$1; } + return email; +} + +function extractEmailName(mailTo) { + var name = ""; + var namere = /(\w[\w\ _-]+)\ (<|<)/; - if (namere.test(dirtyMailTo)) { - namere.exec(dirtyMailTo); + if (namere.test(mailTo)) { + namere.exec(mailTo); name = RegExp.$1; } +} + +function sanitizeMailTo(dirtyMailTo) { + var name = extractEmailName(dirtyMailTo); + var email = extractEmailAddress(dirtyMailTo); var mailto = ""; if (name.length > 0) @@ -846,7 +856,7 @@ function onSearchFocus(searchValue) function onSearchBlur(searchValue) { var ghostPhrase = searchValue.getAttribute("ghost-phrase"); - log ("search blur: '" + searchValue.value + "'"); +// log ("search blur: '" + searchValue.value + "'"); if (!searchValue.value) { searchValue.setAttribute("modified", ""); searchValue.style.color = "#aaa"; @@ -888,12 +898,16 @@ function initCriteria() function onContactAdd(node) { - var selectorId = node.parentNode.parentNode.getAttribute("id"); - urlstr = ApplicationBaseURL + "../../" + UserLogin + "/Contacts/select?selectorId=" + selectorId; + var selectorUrl = ''; + if (node) + selectorUrl = ("?selectorId=" + + node.parentNode.parentNode.getAttribute("id")); + + urlstr = (ApplicationBaseURL + "../../" + UserLogin + "/Contacts/" + + contactSelectorAction + selectorUrl); var w = window.open(urlstr, "Addressbook", - "width=640,height=400,left=10,top=10,toolbar=no," + - "dependent=yes,menubar=no,location=no,resizable=yes," + - "scrollbars=yes,directories=no,status=no"); + "width=640,height=400,resizable=1,scrollbars=1,toolbar=0," + + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); w.focus(); return false; @@ -920,39 +934,6 @@ function onContactRemove(node) { return false; } -function addContact(selectorId, contactId, contactName) -{ - var uids = document.getElementById('uixselector-' + selectorId - + '-uidList'); - log ("contactId: " + contactId); - if (contactId) - { - var re = new RegExp("(^|,)" + contactId + "($|,)"); - - log ("uids: " + uids); - if (!re.test(uids.value)) - { - log ("no match... realling adding"); - if (uids.value.length > 0) - uids.value += ',' + contactId; - else - uids.value = contactId; - - log ('values: ' + uids.value); - var names = document.getElementById('uixselector-' + selectorId - + '-display'); - names.innerHTML += ('
  • ' - + contactName + '
  • '); - } - else - log ("match... ignoring contact"); - } - - return false; -} - /* tabs */ function initTabs() {