From 93274f899322fdc4704015d1d7a4dfb0dc917b7e Mon Sep 17 00:00:00 2001 From: Joel Pettersson Date: Wed, 11 Sep 2013 04:07:05 +0200 Subject: [PATCH] List tracks in jQuery table widget. Currently, the tracks are just listed in the table and no action can be taken on them. Eventually, the same popup menu as before or something equivalent should be added. --- webclient/index.html | 24 ++++++++++++++++++------ webclient/js/library.js | 33 +++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/webclient/index.html b/webclient/index.html index e5064c9..9cfd7cc 100755 --- a/webclient/index.html +++ b/webclient/index.html @@ -222,12 +222,24 @@ -
-

Tracks

- +
+
+

Tracks

+
+
+ + + + + + + + + + + +
TrackArtistTimeAlbum
+
diff --git a/webclient/js/library.js b/webclient/js/library.js index ded4f4b..a4237f3 100755 --- a/webclient/js/library.js +++ b/webclient/js/library.js @@ -22,9 +22,6 @@ function initSearch() { document.activeElement.blur(); $("input").blur(); - $('#artistresulttable').empty(); - $('#albumresulttable').empty(); - $('#trackresulttable').empty(); delete customTracklists['allresultscache']; delete customTracklists['artistresultscache']; delete customTracklists['albumresultscache']; @@ -41,10 +38,6 @@ function initSearch() { * process results of a search *********************************************************/ function processSearchResults(resultArr) { - $(SEARCH_TRACK_TABLE).empty(); - $(SEARCH_ARTIST_TABLE).empty(); - $(SEARCH_ALBUM_TABLE).empty(); - // Merge results from different backends. var results = {'tracks': [], 'artists': [], 'albums': []}; var emptyResult = true; @@ -134,10 +127,30 @@ function processSearchResults(resultArr) { // Inject list items, refresh listview and hide superfluous items. $(SEARCH_ALBUM_TABLE).html(child).listview('refresh').find('.overflow').hide(); - $('#expandsearch').show(); - // Track results - playlisttotable(results.tracks, SEARCH_TRACK_TABLE, 'trackresultscache'); + child = ''; + pattern = '{track}{artist}{time}{album}'; + + //playlisttotable(results.tracks, SEARCH_TRACK_TABLE, 'trackresultscache'); + for (var i = 0; i < results.tracks.length; ++i) { + tokens = { + 'track': results.tracks[i].name, + 'artist': '', + 'time': results.tracks[i].length, + 'album': results.tracks[i].album.name, + 'listuri': undefined, + 'trackuri': results.tracks[i].uri, + }; + + for (var j = 0; j < results.tracks[i].artists.length; ++j) { + tokens.artist += results.tracks[i].artists[j].name + ', '; + } + + child += theme(pattern, tokens); + } + + $(SEARCH_TRACK_TABLE).children('tbody').html(child); + $(SEARCH_TRACK_TABLE).table('refresh'); setSongInfo(); showLoading(false);