Skip to content

Commit

Permalink
fix broken autocomplete of usernames when sharing tracks with group
Browse files Browse the repository at this point in the history
  • Loading branch information
lstein committed May 25, 2011
1 parent f4acbf2 commit 47f66b0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
20 changes: 20 additions & 0 deletions htdocs/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ function initAutocomplete() {
}
}
);


$$('.autocomplete.usersearch').each(function (div) {
var entry_id = div.id.replace(/_choices$/,'');
new Ajax.Autocompleter(
entry_id,
div.id,
document.URL,
{
frequency: 0.2,
parameters: 'action=autocomplete_user_search',
paramName: 'prefix',
minChars: 3,
updateElement: function(t) {
var username = t.innerHTML.match(/ \((.+)\)$/);
$(entry_id).value=username[1].stripTags();
}
}
)
});
}


4 changes: 2 additions & 2 deletions lib/Bio/Graphics/Browser2/Render/HTML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ sub render_track_sharing {
-onFocus => "this.clear()"
});
my $add_autocomplete = div({-id=>"${id}_choices",
-class=>'autocomplete'},'') if $self->setting('autocomplete');
-class=>'autocomplete usersearch'},'') if $self->setting('autocomplete');
my $add_link = " " . a(
{
-href => "javascript: void(0)",
Expand Down Expand Up @@ -2906,7 +2906,7 @@ sub format_autocomplete {

sub format_upload_autocomplete {
my $self = shift;
my $matches = shift;
my $matches = shift;
my $partial = shift;
my %names;
for my $f (@$matches) {
Expand Down
3 changes: 1 addition & 2 deletions lib/Bio/Graphics/Browser2/UserDB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ END
$select->execute($db_search,$db_search,$db_search) or die $select->errstr;
my @results;
while (my @a = $select->fetchrow_array) {
# push @results,(grep /$search/i,@a);
push @results, "$a[1] <$a[2]> ($a[0])";
push @results, ($a[2] && $a[2] !~ /unused/i ? "$a[1] <$a[2]> ($a[0])" : "$a[1] ($a[0])");
}
$select->finish;
return \@results;
Expand Down

0 comments on commit 47f66b0

Please sign in to comment.