[RCD] Using the address book quick search JS from plugins

Chris Moules christopher at gms.lu
Wed Feb 20 10:04:48 CET 2013


Well I did spend a bit of time following the function calls in
app.js.src and that lead me to: program/steps/mail/autocomplete.inc

It looks like this search was not intended to be used outside of email
composition, which is OK but does not fit this use case.

As a simple but inelegant workaround, a simple regex on the data seems
to work:

rcmail.init_address_input_events(row_input, "");
row_input.blur(function() {
  row_input.val(function(e, val) {
    return val.replace(/.*<(\S*)>.*/, "$1");

Is there a better approach, that is obvious to anyone versed in this
part of Rouncdube, to solve this in a cleaner fashion?



On 19/02/13 14:02, Chris Moules wrote:
> Hello,
> I am looking at adding address book 'quick search'/auto-complete
> functionality, amongst other enhancements, to the advanced_search plugin
> for the email relevant fields (To, From, etc). This will allow for quick
> and easy entry of email addresses that are in the address book.
> Looking at the functionality in the compose, simply adding this JS
> snippit to the input seems to work:
> <code>
>  var ac_props;
>  rcmail.init_address_input_events(row_input, ac_props);
> </code>
> The problem being that this wraps the email address with "<>", prepends
> the display name and appends ", " to the data. Trying to just use this
> and filtering the email our with a regex in the backend is problematic
> due to the "<email>" being removed via the XSS HTML tag filtering
> protection. Disabling this is also not desirable.
> What I would like is to have the same type of functionality but choosing
> only to place the email address in the field. I have done a little
> digging through the JS code but did not quickly find something that
> matched my requirements.
> Can someone point me in the right direction or do I need to try to trace
> what is happening all through app.js.src. I would like to reuse as much
> of the core code as possible.
> Regards,
> Chris

More information about the dev mailing list