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.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 = {
  7. path: window.location.pathname.split('/').reverse()[0].split(".")[0],
  8. query: window.location.search.slice(1).split('&').reduce((a,b)=>Object.assign(a,{[b.split('=')[0]]:b.split('=')[1]}),{})
  9. }
  10. $('#artistsearch' + SELECTOR).autocomplete({
  11. deferRequestBy: 300,
  12. onSelect : function(suggestion) {
  13. window.location = 'artist.php?id=' + suggestion['data'];
  14. },
  15. serviceUrl : ARTIST_AUTOCOMPLETE_URL,
  16. });
  17. if (url.path == 'torrents' || url.path == 'upload' || url.path == 'artist' || (url.path == 'requests' && url.query['action'] == 'new') || url.path == 'collages') {
  18. $("#artist" + SELECTOR).autocomplete({
  19. deferRequestBy: 300,
  20. serviceUrl : ARTIST_AUTOCOMPLETE_URL
  21. });
  22. $("#artistsimilar" + SELECTOR).autocomplete({
  23. deferRequestBy: 300,
  24. serviceUrl : ARTIST_AUTOCOMPLETE_URL
  25. });
  26. }
  27. if (url.path == 'torrents' || url.path == 'upload' || url.path == 'collages' || url.path == 'requests' || url.path == 'top10' || (url.path == 'requests' && url.query['action'] == 'new')) {
  28. $("#tags" + SELECTOR).autocomplete({
  29. deferRequestBy: 300,
  30. delimiter: ',',
  31. serviceUrl : TAGS_AUTOCOMPLETE_URL
  32. });
  33. $("#tagname" + SELECTOR).autocomplete({
  34. deferRequestBy: 300,
  35. delimiter: ',',
  36. serviceUrl : TAGS_AUTOCOMPLETE_URL
  37. });
  38. }
  39. };