2006-10-03 18:21:25 +02:00
|
|
|
var contactSelectorAction = 'mailer-contacts';
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function addContact(tag, fullContactName, contactId, contactName, contactEmail) {
|
2006-10-03 16:38:51 +02:00
|
|
|
if (!mailIsRecipient(contactEmail)) {
|
|
|
|
var neededOptionValue = 0;
|
|
|
|
if (tag == "cc")
|
|
|
|
neededOptionValue = 1;
|
|
|
|
else if (tag == "bcc")
|
|
|
|
neededOptionValue = 2;
|
|
|
|
|
|
|
|
var stop = false;
|
|
|
|
var counter = 0;
|
|
|
|
var currentRow = $('row_' + counter);
|
|
|
|
while (currentRow
|
|
|
|
&& !stop) {
|
2006-10-18 23:53:47 +02:00
|
|
|
var currentValue = currentRow.childNodesWithTag("span")[1].childNodesWithTag("input")[0].value;
|
2006-10-03 16:38:51 +02:00
|
|
|
if (currentValue == neededOptionValue) {
|
|
|
|
stop = true;
|
|
|
|
insertContact($("addr_" + counter), contactName, contactEmail);
|
|
|
|
}
|
|
|
|
counter++;
|
|
|
|
currentRow = $('row_' + counter);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stop) {
|
|
|
|
fancyAddRow(false, "");
|
2006-10-18 23:53:47 +02:00
|
|
|
$("row_" + counter).childNodesWithTag("span")[0].childNodesWithTag("select")[0].value
|
2006-10-03 16:38:51 +02:00
|
|
|
= neededOptionValue;
|
|
|
|
insertContact($("addr_" + counter), contactName, contactEmail);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mailIsRecipient(mailto) {
|
|
|
|
var isRecipient = false;
|
|
|
|
|
|
|
|
var counter = 0;
|
|
|
|
var currentRow = $('row_' + counter);
|
|
|
|
|
2006-10-03 18:30:11 +02:00
|
|
|
var email = extractEmailAddress(mailto).toUpperCase();
|
2006-10-03 16:38:51 +02:00
|
|
|
|
|
|
|
while (currentRow && !isRecipient) {
|
2006-10-03 18:30:11 +02:00
|
|
|
var currentValue = $("addr_"+counter).value.toUpperCase();
|
2006-10-03 16:38:51 +02:00
|
|
|
if (currentValue.indexOf(email) > -1)
|
|
|
|
isRecipient = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
counter++;
|
|
|
|
currentRow = $('row_' + counter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return isRecipient;
|
|
|
|
}
|
|
|
|
|
|
|
|
function insertContact(inputNode, contactName, contactEmail) {
|
|
|
|
var value = '' + inputNode.value;
|
|
|
|
|
|
|
|
var newContact = contactName;
|
|
|
|
if (newContact.length > 0)
|
|
|
|
newContact += ' <' + contactEmail + '>';
|
|
|
|
else
|
|
|
|
newContact = contactEmail;
|
|
|
|
|
|
|
|
if (value.length > 0)
|
|
|
|
value += ", ";
|
|
|
|
value += newContact;
|
|
|
|
|
|
|
|
inputNode.value = value;
|
2006-09-20 19:58:42 +02:00
|
|
|
}
|
2006-10-18 23:53:47 +02:00
|
|
|
|
|
|
|
function toggleAttachments() {
|
|
|
|
var div = $("attachmentsArea");
|
|
|
|
if (div.style.display)
|
|
|
|
div.style.display = "";
|
|
|
|
else
|
|
|
|
div.style.display = "block;";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateInlineAttachmentList(sender, attachments) {
|
|
|
|
var count = 0;
|
|
|
|
|
|
|
|
var div = $("attachmentsArea");
|
|
|
|
if (attachments)
|
|
|
|
count = attachments.length;
|
|
|
|
if (count)
|
|
|
|
{
|
|
|
|
var text = "";
|
|
|
|
for (var i = 0; i < count; i++) {
|
|
|
|
text = text + attachments[i];
|
|
|
|
text = text + '<br />';
|
|
|
|
}
|
|
|
|
|
|
|
|
var e = $('compose_attachments_list');
|
|
|
|
e.innerHTML = text;
|
|
|
|
if (!div.style.display)
|
|
|
|
div.style.display = "block;";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
div.style.display = "";
|
|
|
|
}
|