From 4e384a6eb7b3b01dcbeb85b1fdde4118b2988eb7 Mon Sep 17 00:00:00 2001 From: RandomByte Date: Sun, 8 Sep 2013 21:42:43 +0200 Subject: [PATCH] Moved Spotify's "Starred" playlist to the top of the playlist list as this is how Spotify does it in it's own clients and what users are used to. --- webclient/js/process_ws.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/webclient/js/process_ws.js b/webclient/js/process_ws.js index 4bf3578..88a13f8 100755 --- a/webclient/js/process_ws.js +++ b/webclient/js/process_ws.js @@ -65,11 +65,23 @@ function processGetPlaylists(resultArr) { if ((!resultArr) || (resultArr == '')) { return; } - var tmp = ''; + var tmp = '', + starredRegex = /spotify:user:.*:starred/g, + starred; + for (var i = 0; i < resultArr.length; i++) { var child = '
  • ' + resultArr[i].name + '
  • '; - tmp += child; + // Check if this is Spotify's "Starred" playlist + if(starredRegex.test(resultArr[i].uri)) + starred = child; + else + tmp += child; }; + + // 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();