Forum
Samuel Plentz2009-12-12 22:00:36
I wish to have the following form for multiple recipients.

Like this:
Hello Peter, Paul and Linda

Instead of:
Hello Peter, Paul, Linda

So I suggest an optional "last-separator" between the last 2 names.

The syntax could be:
[[TO=type|separator|last-separator]]

In the case above it would be:
Hello [[TO=firstname|, | and ]]

Thanks for listening.
Samuel Plentz2009-12-24 14:11:39
I coded this feature and also the other one: (Use firstname when nickname was not set) by myself.
Here is what I changed in "wzQuicktextVar:358:get_to".

get_to: function(aVariables)
{
var data = this.process_to(aVariables);

if(aVariables[0]=='nickname'){ // NEW: use name if nickname is not available
for (var i = 0; i < data['firstname'].length; i++){
if(typeof data['nickname'][i]=='undefined'){
data['nickname'][i]=data['firstname'][i]
}
}
}

if (typeof data[aVariables[0]] != 'undefined')
{

if (aVariables.length < 2){
aVariables[1] = ", ";
aVariables[2] = " & ";
}
if (aVariables.length < 3)
aVariables[2] = aVariables[1];

var result=""; // NEW: there are 2 kinds of separators: [Item1][S1][Item2][S1][Item3][S2][Item4]
for (var i = 0; i < data[aVariables[0]].length; i++){
if (i==0) {
result=result+data[aVariables[0]][i];
} else if (i+1==data[aVariables[0]].length) {
result=result+aVariables[2].replace(/\n/g, "n").replace(/\t/g, "t")+data[aVariables[0]][i];
} else {
result=result+aVariables[1].replace(/\n/g, "n").replace(/\t/g, "t")+data[aVariables[0]][i];
}
}
return result;
}
else
return "";
}
1
Create post
You need to login before posting in the forum