Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

autocomplete.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var ARTIST_AUTOCOMPLETE_URL = 'artist.php?action=autocomplete';
  2. var TAGS_AUTOCOMPLETE_URL = 'torrents.php?action=autocomplete_tags';
  3. var SELECTOR = '[data-gazelle-autocomplete="true"]';
  4. $(document).ready(initAutocomplete)
  5. function initAutocomplete() {
  6. var url = new URL();
  7. $('#artistsearch' + SELECTOR).autocomplete({
  8. deferRequestBy: 300,
  9. onSelect : function(suggestion) {
  10. window.location = 'artist.php?id=' + suggestion['data'];
  11. },
  12. serviceUrl : ARTIST_AUTOCOMPLETE_URL,
  13. });
  14. if (url.path == 'torrents' || url.path == 'upload' || url.path == 'artist' || (url.path == 'requests' && url.query['action'] == 'new') || url.path == 'collages') {
  15. $("#artist" + SELECTOR).autocomplete({
  16. deferRequestBy: 300,
  17. serviceUrl : ARTIST_AUTOCOMPLETE_URL
  18. });
  19. $("#artistsimilar" + SELECTOR).autocomplete({
  20. deferRequestBy: 300,
  21. serviceUrl : ARTIST_AUTOCOMPLETE_URL
  22. });
  23. }
  24. if (url.path == 'torrents' || url.path == 'upload' || url.path == 'collages' || url.path == 'requests' || url.path == 'top10' || (url.path == 'requests' && url.query['action'] == 'new')) {
  25. $("#tags" + SELECTOR).autocomplete({
  26. deferRequestBy: 300,
  27. delimiter: ',',
  28. serviceUrl : TAGS_AUTOCOMPLETE_URL
  29. });
  30. $("#tagname" + SELECTOR).autocomplete({
  31. deferRequestBy: 300,
  32. delimiter: ',',
  33. serviceUrl : TAGS_AUTOCOMPLETE_URL
  34. });
  35. }
  36. };