summaryrefslogtreecommitdiffstats
path: root/static/functions/autocomplete.js
blob: 2e810abc18221cd4e6e9a7c79bfe0c5cd88dac23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var ARTIST_AUTOCOMPLETE_URL = 'artist.php?action=autocomplete';
var TAGS_AUTOCOMPLETE_URL = 'torrents.php?action=autocomplete_tags';

$(document).ready(function() {
	var url = new URL();

	$('#artistsearch').autocomplete({
		serviceUrl : ARTIST_AUTOCOMPLETE_URL,
		onSelect : function(suggestion) {
			window.location = 'artist.php?id=' + suggestion['data'];
		},
	});

	if (url.path == 'torrents' || url.path == 'upload' || url.path == 'artist') {
		$("#artist").autocomplete({
			serviceUrl : ARTIST_AUTOCOMPLETE_URL
		});
		$("#artistsimilar").autocomplete({
			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')) {
		$("#tags").autocomplete({
			serviceUrl : TAGS_AUTOCOMPLETE_URL,
			delimiter: ','
		});
		$("#tagname").autocomplete({
			serviceUrl : TAGS_AUTOCOMPLETE_URL,
		});
	}

});