mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-02 14:46:31 +00:00
37 lines
819 B
JavaScript
37 lines
819 B
JavaScript
|
|
||
|
|
||
|
var remoteRepos = new Bloodhound({
|
||
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("full_name"),
|
||
|
|
||
|
identify: function(obj) { return obj.full_name; },
|
||
|
prefetch: '/api/user/repos/remote'
|
||
|
});
|
||
|
|
||
|
|
||
|
function reposWithDefaults(q, sync) {
|
||
|
if (q === "") {
|
||
|
sync(remoteRepos.all())
|
||
|
} else {
|
||
|
remoteRepos.search(q, sync);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$('.typeahead').typeahead({
|
||
|
hint: true,
|
||
|
highlight: true,
|
||
|
minLength: 0
|
||
|
},
|
||
|
{
|
||
|
name: "repos",
|
||
|
display: "full_name",
|
||
|
source: reposWithDefaults,
|
||
|
templates: {
|
||
|
suggestion: function(obj) {
|
||
|
return "<div><div><img src='"+obj.avatar_url+"' width='32px' height='32px' /></div><div>"+ obj.full_name +"</div></div>";
|
||
|
}
|
||
|
}
|
||
|
}).bind('typeahead:select', function(ev, suggestion) {
|
||
|
window.location.href="/"+suggestion.full_name;
|
||
|
});
|