Gazelle/static/functions/autocomplete.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-07-01 08:01:00 +00:00
var ARTIST_AUTOCOMPLETE_URL = 'artist.php?action=autocomplete';
var TAGS_AUTOCOMPLETE_URL = 'torrents.php?action=autocomplete_tags';
2013-07-03 08:01:01 +00:00
var SELECTOR = '[data-gazelle-autocomplete="true"]';
2013-07-01 08:01:00 +00:00
$(document).ready(function() {
var url = new URL();
2011-09-30 08:00:12 +00:00
2013-07-03 08:01:01 +00:00
$('#artistsearch' + SELECTOR).autocomplete({
2013-07-01 08:01:00 +00:00
serviceUrl : ARTIST_AUTOCOMPLETE_URL,
onSelect : function(suggestion) {
window.location = 'artist.php?id=' + suggestion['data'];
},
});
2011-09-30 08:00:12 +00:00
2013-07-16 08:00:49 +00:00
if (url.path == 'torrents' || url.path == 'upload' || url.path == 'artist' || (url.path == 'requests' && url.query['action'] == 'new') || url.path == 'collages') {
2013-07-03 08:01:01 +00:00
$("#artist" + SELECTOR).autocomplete({
2013-07-01 08:01:00 +00:00
serviceUrl : ARTIST_AUTOCOMPLETE_URL
});
2013-07-03 08:01:01 +00:00
$("#artistsimilar" + SELECTOR).autocomplete({
2013-07-01 08:01:00 +00:00
serviceUrl : ARTIST_AUTOCOMPLETE_URL
});
}
if (url.path == 'torrents' || url.path == 'upload' || url.path == 'collages' || url.path == 'requests' || url.path == 'top10' || (url.path == 'requests' && url.query['action'] == 'new')) {
2013-07-03 08:01:01 +00:00
$("#tags" + SELECTOR).autocomplete({
2013-07-01 08:01:00 +00:00
serviceUrl : TAGS_AUTOCOMPLETE_URL,
delimiter: ','
});
2013-07-03 08:01:01 +00:00
$("#tagname" + SELECTOR).autocomplete({
2013-07-01 08:01:00 +00:00
serviceUrl : TAGS_AUTOCOMPLETE_URL,
2011-09-30 08:00:12 +00:00
});
}
2013-07-02 08:01:37 +00:00
2013-07-01 08:01:00 +00:00
});