From e2099ee62a379bc945b19ca5893cb30d6480b2df Mon Sep 17 00:00:00 2001 From: Trevor Squillario Date: Sat, 29 Sep 2012 15:15:00 -0400 Subject: [PATCH] 2.0.7 Release --- index.html | 16 ++++--- js/libs/api.js | 105 ++++++++++++++++++++++++++++-------------- js/libs/generators.js | 4 +- js/libs/player.js | 2 + js/libs/utils.js | 28 +++++++++++ js/ui-load.js | 4 +- js/ui-ready.js | 23 +++++---- style/Style.css | 11 +++-- 8 files changed, 135 insertions(+), 58 deletions(-) diff --git a/index.html b/index.html index bd188a5..895a411 100755 --- a/index.html +++ b/index.html @@ -129,7 +129,7 @@
-
  • Genre Playlists
+
  • Auto Playlists
    • Folder Playlists
      @@ -179,6 +179,7 @@


      +

      Keyboard Shortcuts

      @@ -194,9 +195,9 @@

      Options

      -
      +

      -
      +



      @@ -254,8 +255,11 @@ --> -
    • 9/25/2012 - 2.0.7 +
    • 9/29/2012 - 2.0.7 + Updated to SoundManager2 v297a-20120916 + Implemented updatePlaylist API method. Allows for larger playlists. Added support for Podcasts (Thanks to nithinphilips) + Added Genre support for Auto Playlists (Thanks to Concept211 & orangepeelbeef)
    • 8/13/2012 - 2.0.6 Minor bugfix @@ -375,8 +379,8 @@
        -
      • -
      • +
      • +
      diff --git a/js/libs/api.js b/js/libs/api.js index a3507b0..38ebb5b 100755 --- a/js/libs/api.js +++ b/js/libs/api.js @@ -1,3 +1,17 @@ +function ping() { + $.ajax({ + url: baseURL + '/ping.view?u=' + username + '&p=' + password + '&v=1.6.0&c=' + applicationName + '&f=jsonp', + method: 'GET', + dataType: 'jsonp', + timeout: 10000, + success: function (data) { + if (data["subsonic-response"].status == 'ok') { + version = data["subsonic-response"].version; + $('#SubsonicVersion').html(version); + } + } + }); +} function loadArtists(id, refresh) { if (debug) { console.log("LOAD ARTISTS"); } if (refresh) { @@ -27,9 +41,6 @@ function loadArtists(id, refresh) { if (data["subsonic-response"].status === 'ok') { var indexlist, indexname; - if (data["subsonic-response"].version != '') { - version = data["subsonic-response"].version; - } // There is a bug in the API that doesn't return a JSON array for one artist var indexes = []; if (data["subsonic-response"].indexes.index !== undefined) { @@ -147,20 +158,23 @@ function loadGenres(refresh) { } var content = $('#AutoPlaylistContainer').html(); if (content === "") { - var genres = $.cookie('GenrePlaylists'); + var genres = $.cookie('AutoPlaylists'); + var genresArr = []; if (genres) { - var genresArr = genres.split(','); - //
    • Alternative
    • - $.each(genresArr, function (i, genre) { - var html = ""; - html += '
    • '; - html += '' + genre + ''; - html += '
      '; - html += '
      '; - html += '
    • '; - $(html).appendTo("#AutoPlaylistContainer"); - }); + genresArr = genres.split(','); + genresArr.unshift('Random'); + } else { + genresArr.push('Random'); } + $.each(genresArr, function (i, genre) { + var html = ""; + html += '
    • '; + html += '' + genre + ''; + html += '
      '; + html += '
      '; + html += '
    • '; + $(html).appendTo("#AutoPlaylistContainer"); + }); } } function getAlbums(id, action, appendto) { @@ -263,7 +277,7 @@ function getAlbumListBy(id) { }); } function getRandomSongList(action, appendto, genre, folder) { - var size,gstring; + var size, gstring; gstring = ''; if ($.cookie('AutoPlaylistSize') === null) { size = 25; @@ -271,14 +285,14 @@ function getRandomSongList(action, appendto, genre, folder) { size = $.cookie('AutoPlaylistSize'); } if (genre !== undefined) { - gstring = '&genre=' + genre; + gstring = '&genre=' + genre; } if (genre === 'Random') { gstring = ''; } if (folder !== undefined) { gstring = '&musicFolderId=' + folder; - } + } $.ajax({ url: baseURL + '/getRandomSongs.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp&size=' + size + gstring, method: 'GET', @@ -290,6 +304,7 @@ function getRandomSongList(action, appendto, genre, folder) { $("#TrackContainer").empty(); } if (action === 'autoplay') { + $("#TrackContainer").empty(); $(appendto).empty(); } // There is a bug in the API that doesn't return a JSON array for one artist @@ -314,6 +329,9 @@ function getRandomSongList(action, appendto, genre, folder) { html = generateSongHTML(rowcolor, item.id, item.parent, track, item.title, item.artist, item.album, item.coverArt, item.userRating, time['m'], time['s']); $(html).appendTo(appendto); }); + if (appendto === '#TrackContainer') { + updateMessage(items.length + ' Song(s)'); + } if (appendto === '#CurrentPlaylistContainer') { updateMessage(items.length + ' Song(s) Added'); } @@ -613,20 +631,39 @@ function addToPlaylist(playlistid, from) { } }); if (count > 0) { - $.ajax({ - type: 'GET', - url: baseURL + '/createPlaylist.view?u=' + username + '&p=' + password, - dataType: 'jsonp', - timeout: 10000, - data: { v: version, c: applicationName, f: "jsonp", playlistId: playlistid, songId: currentsongs }, - success: function () { - $('table.songlist tr.song').each(function () { - $(this).removeClass('selected'); - }); - updateMessage('Playlist Updated!'); - }, - traditional: true // Fixes POST with an array in JQuery 1.4 - }); + var runningVersion = parseVersionString(version); + var minimumVersion = parseVersionString('1.8.0'); + if (checkVersion(runningVersion, minimumVersion)) { + $.ajax({ + type: 'GET', + url: baseURL + '/updatePlaylist.view?u=' + username + '&p=' + password, + dataType: 'jsonp', + timeout: 10000, + data: { v: version, c: applicationName, f: "jsonp", playlistId: playlistid, songIdToAdd: selected }, + success: function () { + $('table.songlist tr.song').each(function () { + $(this).removeClass('selected'); + }); + updateMessage('Playlist Updated!'); + }, + traditional: true // Fixes POST with an array in JQuery 1.4 + }); + } else { + $.ajax({ + type: 'GET', + url: baseURL + '/createPlaylist.view?u=' + username + '&p=' + password, + dataType: 'jsonp', + timeout: 10000, + data: { v: version, c: applicationName, f: "jsonp", playlistId: playlistid, songId: currentsongs }, + success: function () { + $('table.songlist tr.song').each(function () { + $(this).removeClass('selected'); + }); + updateMessage('Playlist Updated!'); + }, + traditional: true // Fixes POST with an array in JQuery 1.4 + }); + } } } }); @@ -747,7 +784,7 @@ function getPlaylist(id, action, appendto) { $(html).appendTo(appendto); }); if (appendto === '#TrackContainer tbody') { - updateMessage(playlist.name + ': ' + count + ' Songs'); + updateMessage(count + ' Song(s)'); } if (appendto === '#CurrentPlaylistContainer tbody') { updateMessage(children.length + ' Song(s) Added'); @@ -856,7 +893,7 @@ function getPodcast(id, action, appendto) { count++; }); if (appendto === '#PodcastContainer tbody') { - updateMessage(channel.title + ': ' + count + ' Songs'); + updateMessage(count + ' Song(s)'); } if (appendto === '#CurrentPlaylistContainer tbody') { updateMessage(count + ' Song(s) Added'); diff --git a/js/libs/generators.js b/js/libs/generators.js index c28cd80..380e6a2 100755 --- a/js/libs/generators.js +++ b/js/libs/generators.js @@ -68,7 +68,7 @@ function generateSongHTML(rowcolor, childid, parentid, track, title, artist, alb } else { coverartSrc = baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=jsonp&size=25&id=' + coverart; } - html += '' + album + ''; + html += '' + album + ''; html += '' + m + ':' + s + ''; html += ''; return html; @@ -95,7 +95,7 @@ function generatePodcastHTML(rowcolor, childid, parentid, track, title, descript } else { coverartSrc = baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=jsonp&size=25&id=' + coverart; } - html += '' + album + ''; + html += '' + album + ''; html += '' + m + ':' + s + ''; html += ''; return html; diff --git a/js/libs/player.js b/js/libs/player.js index 61c176a..ad46cfd 100644 --- a/js/libs/player.js +++ b/js/libs/player.js @@ -33,9 +33,11 @@ function playSong(el, songid, albumid) { $('#songdetails_rate').attr('class', 'rate'); } $('#songdetails_song').html(title); + $('#songdetails_song').attr('title', title); $('#songdetails_song').attr('parentid', albumid); $('#songdetails_song').attr('childid', songid); $('#songdetails_artist').html(artist + ' - ' + album); + $('#songdetails_artist').attr('title', artist + ' - ' + album); var coverartSrc, coverartFullSrc; if (coverart == undefined) { coverartSrc = 'images/albumdefault_50.jpg'; diff --git a/js/libs/utils.js b/js/libs/utils.js index 6b83628..7a665fe 100644 --- a/js/libs/utils.js +++ b/js/libs/utils.js @@ -184,3 +184,31 @@ function closeAllNotifications() { notifications[notification].cancel(); } } +function parseVersionString(str) { + if (typeof (str) != 'string') { return false; } + var x = str.split('.'); + // parse from string or default to 0 if can't parse + var maj = parseInt(x[0]) || 0; + var min = parseInt(x[1]) || 0; + var pat = parseInt(x[2]) || 0; + return { + major: maj, + minor: min, + patch: pat + } +} +function checkVersion(runningVersion, minimumVersion) { + if (runningVersion.major >= minimumVersion.major) { + if (runningVersion.minor >= minimumVersion.minor) { + if (runningVersion.patch >= minimumVersion.patch) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } +} \ No newline at end of file diff --git a/js/ui-load.js b/js/ui-load.js index ae981fd..d7f1600 100755 --- a/js/ui-load.js +++ b/js/ui-load.js @@ -62,8 +62,6 @@ function resizeSMSection(x) { $('#BottomContainer').css({ 'width': (newsmwidth - 16) + 'px' }); $.cookie('defaultsmwidth', newwidth, { expires: 365, path: '/' }); var ulwidth = newsmwidth + 6; - $('#AlbumContainer').css({ 'margin-left': ulwidth + 'px' }); - $('#TrackContainer').css({ 'margin-left': ulwidth + 'px' }); - $('#PodcastContainer').css({ 'margin-left': ulwidth + 'px' }); + $('#AlbumContainer, #TrackContainer, #PodcastContainer').css({ 'margin-left': ulwidth + 'px' }); } } diff --git a/js/ui-ready.js b/js/ui-ready.js index 828730f..2bfae34 100755 --- a/js/ui-ready.js +++ b/js/ui-ready.js @@ -2,7 +2,7 @@ //User config staff $('#Username').val($.cookie('username')); //$('#Password').val($.cookie('passwordenc')); - $('#GenrePlaylists').val($.cookie('GenrePlaylists')); + $('#AutoPlaylists').val($.cookie('AutoPlaylists')); $('#AutoAlbumSize').val($.cookie('AutoAlbumSize')); $('#AutoPlaylistSize').val($.cookie('AutoPlaylistSize')); $('#Server').val($.cookie('Server')); @@ -73,6 +73,7 @@ if ($.cookie('Notification_NowPlaying')) { updateNowPlaying(true); } + ping(); } // Tabs - Click Event @@ -391,9 +392,12 @@ } }); $('#action_CurrentSelectAll').click(function () { + var count = 0; $('#CurrentPlaylist tr.song').each(function () { $(this).addClass('selected'); + count++; }); + updateMessage(count + ' Song(s) Selected'); return false; }); $('#action_CurrentSelectNone').click(function () { @@ -424,8 +428,7 @@ return false; }); $('#PlaylistContainer li.item').live('click', function () { - $('#AutoPlaylistContainer li').removeClass('selected'); - $('#PlaylistContainer li').removeClass('selected'); + $('#AutoPlaylistContainer li, #FolderContainer li, #PlaylistContainer li').removeClass('selected'); $(this).addClass('selected'); getPlaylist($(this).attr("id"), '', '#TrackContainer tbody'); }); @@ -579,12 +582,12 @@ if (password != "") { $.cookie('passwordenc', 'enc:' + HexEncode(password), { expires: 365 }); } - var GenrePlaylists = $('#GenrePlaylists').val(); - if (GenrePlaylists != '') { $.cookie('GenrePlaylists', GenrePlaylists, { expires: 365 }); } + var AutoPlaylists = $('#AutoPlaylists').val(); + $.cookie('AutoPlaylists', AutoPlaylists, { expires: 365 }); var AutoAlbumSize = $('#AutoAlbumSize').val(); - if (AutoAlbumSize != '') { $.cookie('AutoAlbumSize', AutoAlbumSize, { expires: 365 }); } + $.cookie('AutoAlbumSize', AutoAlbumSize, { expires: 365 }); var AutoPlaylistSize = $('#AutoPlaylistSize').val(); - if (AutoPlaylistSize != '') { $.cookie('AutoPlaylistSize', AutoPlaylistSize, { expires: 365 }); } + $.cookie('AutoPlaylistSize', AutoPlaylistSize, { expires: 365 }); var server = $('#Server').val(); if (server != "") { $.cookie('Server', server, { expires: 365 }); @@ -597,14 +600,14 @@ }); $('#Genres').live('change', function () { var genre = $(this).val(); - var currentGenres = $('#GenrePlaylists').val(); + var currentGenres = $('#AutoPlaylists').val(); var newGenres; if (currentGenres == '') { newGenres = genre; } else { newGenres = currentGenres + ', ' + genre; } - $('#GenrePlaylists').val(newGenres); + $('#AutoPlaylists').val(newGenres); }); $('#HideAZ').live('click', function () { if ($('#HideAZ').is(':checked')) { @@ -700,5 +703,5 @@ } }).disableSelection(); -}); // End document.ready +}); // End document.ready diff --git a/style/Style.css b/style/Style.css index e484225..2c73a2e 100755 --- a/style/Style.css +++ b/style/Style.css @@ -38,7 +38,7 @@ h3.title #container { text-align: left; - min-height: 600px; + /*min-height: 600px;*/ min-width: 810px; } #nav @@ -174,7 +174,7 @@ a#logo:hover overflow: auto; background: #fff; border: 1px solid #cbcbcb; - margin-top: 5px; + margin-top: 4px; } .fullsection { @@ -487,7 +487,11 @@ table.songlist tr.song td.album table.songlist tr.song td.album a { color: #829FC0; - text-decoration: none; + text-decoration: none; + float: left; + overflow: hidden; + white-space: nowrap; + font-size: 12px; } table.songlist tr.song td.album a:hover { @@ -675,6 +679,7 @@ background-color: #8dbdd8; .subactions { height: 29px; + width: 620px; margin: 4px 0 0 0; padding: 0 0 0 5px; }