PageSourceSearch

https://pro.tko.radio/wp-content/plugins/tko-now-playing/js/audiodb-general.js?ver=1745048210

js tko.radio collected 2026-10-05 01:56:30 UTC 3,164 bytes, 80 lines download raw bytes

1/**
2 * js/audiodb-general.js
3 * Fetches “General” info (and cached image) for the General tab,
4 * and updates the popup header image to the locally cached file if available.
5 */
6(function($){
7  'use strict';
8
9  $(function(){
10    // Toggle console logging
11    var debug = false;
12
13    $('.tko-popup-tab[data-tab="general"]').on('click', function(){
14      var $popup = $(this).closest('.tko-popup');
15      var $body  = $popup.find('.tko-popup-body');
16      var title  = $popup.find('.popup-song-title').text();
17      var artist = $popup.find('.popup-artist-name').text();
18      var endpoint = TKO_NOWPLAYING.restUrl.replace(/\/nowplaying$/, '/audiodb/track');
19
20      if (debug) {
21        console.group('General Tab');
22        console.log('Fetching General info for:', artist, '-', title);
23      }
24
25      $body.html('<p>Loading general info…</p>');
26
27      $.getJSON(endpoint, { artist: artist, title: title })
28        .done(function(data){
29          if (debug) console.log('Response:', data);
30
31          // 1. Update header image: prefer localImageUrl, then full‑size, then thumb, then default
32          var info        = (data.track && data.track[0]) || {};
33          var localImg    = data.localImageUrl;
34          var fullUrl     = info.strTrackThumbFull || '';
35          var thumbUrl    = info.strTrackThumb     || '';
36          var imgUrl      = localImg || fullUrl || thumbUrl || TKO_NOWPLAYING.defaultImage;
37          $popup.find('.popup-artist-image').attr('src', imgUrl);
38
39          // 2. Format description line breaks
40          var rawDesc  = info.strDescriptionEN || 'No description available.';
41          var descHtml = rawDesc.replace(/\r?\n/g, '<br/>');
42
43          // 3. Format duration
44          var durText = 'N/A';
45          if (info.intDuration) {
46            var ms = parseInt(info.intDuration, 10);
47            var m  = Math.floor(ms/60000);
48            var s  = Math.floor((ms%60000)/1000);
49            durText = m + 'm ' + s + 's';
50          }
51
52          // 4. Build content HTML
53          if (info.strTrack) {
54            var html = '<ul>' +
55              '<li><strong>Album:</strong> '     + (info.strAlbum            || 'N/A') + '</li>' +
56              '<li><strong>Genre:</strong> '     + (info.strGenre            || 'N/A') + '</li>' +
57              '<li><strong>Style:</strong> '     + (info.strStyle            || 'N/A') + '</li>' +
58              '<li><strong>Duration:</strong> '  + durText                           + '</li>' +
59              '<li><strong>Description:</strong><br/>' + descHtml + '</li>' +
60            '</ul>';
61            $body.html(html);
62          } else {
63            $body.html('<p>No general info found for this track.</p>');
64          }
65
66          if (debug) console.groupEnd();
67        })
68        .fail(function(jqXHR, textStatus, errorThrown){
69          if (debug) {
70            console.error('Error fetching General info:', textStatus, errorThrown);
71            console.error('Response:', jqXHR.responseText);
72          }
73          $body.html('<p>Error loading data.</p>');
74        });
75    })
76
77    // Load General tab by default on popup open
78    .filter('.active').trigger('click');
79  });
80})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.