mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-23 02:05:27 +02:00
99f2b07a11
New: Updated UI New: Mobile browser support Fixed: /favicon.ico will return the favicon now
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
'use strict';
|
|
define(
|
|
[
|
|
'jquery',
|
|
'underscore',
|
|
'typeahead'
|
|
], function ($, _) {
|
|
|
|
$.fn.autoComplete = function (resource) {
|
|
$(this).typeahead({
|
|
hint : true,
|
|
highlight : true,
|
|
minLength : 3,
|
|
items : 20
|
|
},
|
|
{
|
|
name: resource.replace('/'),
|
|
displayKey: '',
|
|
source : function (filter, callback) {
|
|
$.ajax({
|
|
url : window.NzbDrone.ApiRoot + resource,
|
|
dataType: 'json',
|
|
type : 'GET',
|
|
data : { query: filter },
|
|
success : function (data) {
|
|
|
|
var matches = [];
|
|
|
|
$.each(data, function(i, d) {
|
|
if (d.startsWith(filter)) {
|
|
matches.push({ value: d });
|
|
}
|
|
});
|
|
|
|
callback(matches);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
};
|
|
});
|