Browse Source

Add autocomplete to artist fields in upload page

xoru 5 years ago
parent
commit
407e46abde
3 changed files with 10 additions and 5 deletions
  1. 2
    2
      classes/torrent_form.class.php
  2. 4
    0
      static/functions/autocomplete.js
  3. 4
    3
      static/functions/upload.js

+ 2
- 2
classes/torrent_form.class.php View File

@@ -242,13 +242,13 @@ Source: <input type="text" value="<?=Users::get_upload_sources()[0]?>" size="20"
242 242
         <td id="idolfields">
243 243
 <?      if (!empty($Torrent['Artists'])) {
244 244
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
245
-            <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?>/>
245
+            <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?><? Users::has_autocomplete_enabled('other'); ?>/>
246 246
             <? if ($Num == 0) { ?>
247 247
               <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
248 248
             <? }
249 249
             }
250 250
           } else { ?>
251
-            <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
251
+            <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?><? Users::has_autocomplete_enabled('other'); ?>/>
252 252
             <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
253 253
 <?        } ?>
254 254
         </td>

+ 4
- 0
static/functions/autocomplete.js View File

@@ -45,6 +45,10 @@ function initAutocomplete() {
45 45
       delimiter: ',',
46 46
       serviceUrl : TAGS_AUTOCOMPLETE_URL
47 47
     });
48
+    $("#idols_0" + SELECTOR).autocomplete({
49
+      deferRequestBy: 300,
50
+      serviceUrl : ARTIST_AUTOCOMPLETE_URL
51
+    });
48 52
   }
49 53
 
50 54
 };

+ 4
- 3
static/functions/upload.js View File

@@ -307,10 +307,11 @@ function AddArtistField() {
307 307
   x.appendChild(ArtistField);
308 308
   x.appendChild(document.createTextNode('\n'));
309 309
 
310
-  if ($("#idol").data("gazelle-autocomplete")) {
311
-    $(ArtistField).live('focus', function() {
310
+  if ($("#idols_0").data("gazelle-autocomplete")) {
311
+    $(ArtistField).on('focus', function() {
312 312
       $(ArtistField).autocomplete({
313
-        serviceUrl : 'artist.php?action=autocomplete'
313
+        deferRequestBy: 300,
314
+        serviceUrl : ARTIST_AUTOCOMPLETE_URL
314 315
       });
315 316
     });
316 317
   }

Loading…
Cancel
Save