From fe666ceee44a028b3d7df7d0abf0ed3da306d0d8 Mon Sep 17 00:00:00 2001
From: Nick Steel
Date: Tue, 23 Jun 2015 16:42:16 +0100
Subject: [PATCH] Recognise m3u backend and tidy processGetPlaylists
---
.../static/js/functionsvars.js | 2 ++
.../static/js/process_ws.js | 28 ++++++-------------
2 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/mopidy_musicbox_webclient/static/js/functionsvars.js b/mopidy_musicbox_webclient/static/js/functionsvars.js
index 1886bde..87143ca 100644
--- a/mopidy_musicbox_webclient/static/js/functionsvars.js
+++ b/mopidy_musicbox_webclient/static/js/functionsvars.js
@@ -81,6 +81,7 @@ var uriClassList = [
['spotify', 'fa-spotify'],
['spotifytunigo', 'fa-spotify'],
['local', 'fa-file-sound-o'],
+ ['m3u', 'fa-file-sound-o'],
['podcast', 'fa-rss-square'],
['dirble', 'fa-microphone'],
['tunein', 'fa-headphones'],
@@ -100,6 +101,7 @@ var uriHumanList = [
['spotify', 'Spotify'],
['spotifytunigo', 'Spotify Browse'],
['local', 'Local Files'],
+ ['m3u', 'Local Playlists'],
['grooveshark', 'Grooveshark'],
['podcast', 'Podcasts'],
['dirble', 'Dirble'],
diff --git a/mopidy_musicbox_webclient/static/js/process_ws.js b/mopidy_musicbox_webclient/static/js/process_ws.js
index 227170c..ca4f680 100644
--- a/mopidy_musicbox_webclient/static/js/process_ws.js
+++ b/mopidy_musicbox_webclient/static/js/process_ws.js
@@ -156,34 +156,22 @@ function processBrowseDir(resultArr) {
* process results of list of playlists of the user
*********************************************************/
function processGetPlaylists(resultArr) {
- /*- Donec id elit non mi porta
- Gravida at eget metus. Fusce dapibus.
- Tellus ac cursus commodo
- More »
- */
if ((!resultArr) || (resultArr == '')) {
return;
}
- var child, tmp = '',
- starredRegex = /spotify:user:.*:starred/g,
- iconClass, starred;
-
+ var tmp = '',
+ starredRegex = /spotify:user:.*:starred/g;
for (var i = 0; i < resultArr.length; i++) {
- iconClass = getMediaClass(resultArr[i].uri);
-
- // Check if this is Spotify's "Starred" playlist
+ var li_html = '';
if(starredRegex.test(resultArr[i].uri) && resultArr[i].name == "Starred") {
- starred = '★ Spotify Starred Tracks';
+ // Prepend the user's Spotify "Starred" playlist to the results (like Spotify official client).
+ tmp = li_html + '★ Spotify Starred Tracks' + tmp;
} else {
- child = ' ' + resultArr[i].name + '';
- tmp += child;
+ // Append everything else.
+ tmp = tmp + li_html + ' ' + resultArr[i].name + '';
}
};
-
- // Move Spotify "Starred" playlist to top as this is the way Spotify does it
- if(starred)
- tmp = starred + tmp;
-
- $('#playlistslist').empty();
$('#playlistslist').html(tmp);
scrollToTracklist();
showLoading(false);
@@ -234,7 +222,6 @@ function processArtistResults(resultArr) {
* process results of an album lookup
*********************************************************/
function processAlbumResults(resultArr) {
-// console.log(resultArr);
if (!resultArr || (resultArr.length == 0)) {
$('#h_albumname').text('Album not found...');
getCover('', '#albumviewcover, #coverpopupimage', 'extralarge');
@@ -242,6 +229,7 @@ function processAlbumResults(resultArr) {
return;
}
customTracklists[resultArr.uri] = resultArr;
+
albumTracksToTable(resultArr, ALBUM_TABLE, resultArr.uri);
var albumname = getAlbum(resultArr);
var artistname = getArtist(resultArr);