Skip to content

Commit

Permalink
Autocomplete/frontend: provide functions that hook into 'autocomplete…
Browse files Browse the repository at this point in the history
…_insert' actual search and result data

Reason:
In order to enable development of sophisticated autocomplete algorithms, they will need
to process all the data relevant to autocomplete - what was the search string and which
result was the correct one.

Example to illustrate the need:
Say we are talking about these two people of interest, who are in the address book, among others:
- person 1: Bostjan Skufca <[email protected]>
- person 2: Bostjan SkuBIC <[email protected]>

Our user is used to think about the first person by the first name, "Bostjan", as he is an old friend.
The second one is a colleague at work where people call themselves mostly by surnames, "Skubic" in this case.

Without this data provided to 'autocomplete_insert', there is no way for RC to learn that when our user
enters "bos" in the To: field he thinks about person #1 (Bostjan SkuFCA), and when he starts typing "sku"
he means person #2 (Bostjan SkuBIC).
  • Loading branch information
bostjan committed Apr 14, 2016
1 parent 05c7d49 commit 1791c3e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions program/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5182,7 +5182,7 @@ function rcube_webmail()
this.set_caret_pos(this.ksearch_input, p + insert.length);

if (trigger) {
this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert, data:this.env.contacts[id] });
this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert, data:this.env.contacts[id], search:this.ksearch_value, result_type:'contact' });
this.compose_type_activity++;
}
};
Expand All @@ -5191,7 +5191,7 @@ function rcube_webmail()
{
if (this.group2expand[id]) {
this.group2expand[id].input.value = this.group2expand[id].input.value.replace(this.group2expand[id].name, recipients);
this.triggerEvent('autocomplete_insert', { field:this.group2expand[id].input, insert:recipients });
this.triggerEvent('autocomplete_insert', { field:this.group2expand[id].input, insert:recipients, data:this.group2expand[id], search:this.ksearch_value, result_type:'group' });
this.group2expand[id] = null;
this.compose_type_activity++;
}
Expand Down

0 comments on commit 1791c3e

Please sign in to comment.