Monotone-Parent: 1ec7a369d9d6744a61fc1193f0d873bbeb9fd414

Monotone-Revision: e5f6b9bc1d05b57f7739042ee8e36516444f216e

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-07-11T18:11:54
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2006-07-11 18:11:54 +00:00
parent bc4c9e5e36
commit 169cd2ef29
2 changed files with 85 additions and 4 deletions

View File

@ -1,5 +1,14 @@
2006-07-11 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/WebServerResources/generic.js: added "sanitizeMailTo" which
takes any chunk of text as param, detects the user email and the
optional first and last names and return them in a well-formatted
way. Renamed "getSelection" to "getSelectedNodes" to avoid a
namespace conflict. Added "onMenuClick(node, event, menuId)" to
handle popup menus through "onclick" element attributes (node =
this, event = event and menuId = name of the menu DIV id to
popup).
* UI/Contacts/UIxContactEditorBase.m ([UIxContactEditorBase
-snapshot]): add an entry for "email" into the snapshot
dictionary if a "contactEmail" URL parameter was detected and if

View File

@ -44,13 +44,39 @@ 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) {
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);
email = RegExp.$1;
}
var namere = /(\w[\w\ _-]+)\ (&lt;|<)/;
if (namere.test(dirtyMailTo)) {
namere.exec(dirtyMailTo);
name = RegExp.$1;
}
var mailto = "";
if (name.length > 0)
mailto = name + ' <' + email + '>';
else
mailto = email;
return mailto;
}
/* escaping */
function escapeHTML(s) {
s = s.replace(/&/g, "&amp;");
s = s.replace(/</g, "&lt;");
s = s.replace(/>/g, "&gt;");
s = s.replace(/"/g, "&quot;");
s = s.replace(/\"/g, "&quot;");
return s;
}
function unescapeHTML(s) {
@ -215,7 +241,7 @@ function acceptMultiSelect(node) {
return (accept == 'yes');
}
function getSelection(parentNode) {
function getSelectedNodes(parentNode) {
var selArray = new Array();
for (var i = 0; i < parentNode.childNodes.length; i++) {
@ -233,7 +259,7 @@ function onRowClick(node, event) {
var text = document.getElementById('list');
text.innerHTML = '';
var startSelection = getSelection(node.parentNode);
var startSelection = getSelectedNodes(node.parentNode);
if (event.shiftKey == 1
&& acceptMultiSelect(node.parentNode)) {
if (isNodeSelected(node) == true) {
@ -245,10 +271,56 @@ function onRowClick(node, event) {
deselectAll(node.parentNode);
selectNode(node);
}
if (startSelection != getSelection(node.parentNode)) {
if (startSelection != getSelectedNodes(node.parentNode)) {
var code = '' + node.parentNode.getAttribute('onselectionchange');
if (code.length > 0) {
node.eval(code);
}
}
}
/* popup menus */
bodyOnClick = "";
acceptClick = false;
menuClickNode = null;
function onMenuClick(node, event, menuId)
{
event.cancelBubble = true;
event.returnValue = false;
if (event.button == 1)
acceptClick = false;
bodyOnClick = "" + document.body.getAttribute("onclick");
document.body.setAttribute("onclick", "onBodyClick('" + menuId + "'); return false;");
popup = document.getElementById(menuId);
popup.setAttribute("style", "visibility: visible; top: " + event.pageY
+ "px; left: " + event.pageX + "px;" );
menuClickNode = node;
return false;
}
function onBodyClick(menuId)
{
if (!acceptClick)
acceptClick = true;
else
{
popup = document.getElementById(menuId);
popup.setAttribute("style", "visibility: hidden");
document.body.setAttribute("onclick", bodyOnClick);
}
return false;
}
function onMenuEntryClick(node, event, menuId)
{
id = node.getAttribute("id");
window.alert("clicked " + menuClickNode.tagName);
return false;
}