2.1 Moved ratings to stars

This commit is contained in:
Trevor Squillario 2012-09-30 20:02:04 -04:00
parent 94bfd67946
commit 549fe25b7f
7 changed files with 173 additions and 39 deletions

View file

@ -79,11 +79,12 @@
</select> </select>
<ul id="AutoAlbumContainer" class="simplelist mainlist noselect"> <ul id="AutoAlbumContainer" class="simplelist mainlist noselect">
<li class="index" id="auto">Auto Albums</li> <li class="index" id="auto">Auto Albums</li>
<li class="item" id="newest"><span>Recently Added</span></li>
<li class="item" id="random"><span>Random</span></li> <li class="item" id="random"><span>Random</span></li>
<li class="item" id="newest"><span>Recently Added</span></li>
<li class="item" id="starred"><span>Starred</span></li>
<li class="item" id="highest"><span>Top Rated</span></li> <li class="item" id="highest"><span>Top Rated</span></li>
<li class="item" id="recent"><span>Recently Played</span></li>
<li class="item" id="frequent"><span>Most Played</span></li> <li class="item" id="frequent"><span>Most Played</span></li>
<li class="item" id="recent"><span>Recently Played</span></li>
</ul> </ul>
<ul id="ArtistContainer" class="simplelist mainlist noselect"></ul> <ul id="ArtistContainer" class="simplelist mainlist noselect"></ul>
</div> </div>
@ -261,12 +262,15 @@
<span class="changes"></span> <span class="changes"></span>
</li> </li>
--> -->
<li class="log"><span class="version">9/30/2012 - 2.1</span>
<span class="changes">Moved ratings to stars (5 star ratings will reappear eventually)</span>
</li>
<li class="log"><span class="version">9/30/2012 - 2.0.9</span> <li class="log"><span class="version">9/30/2012 - 2.0.9</span>
<span class="changes">Added Dark Theme</span> <span class="changes">Added Dark Theme</span>
<span class="changes">Fixed issue with track duration display</span> <span class="changes">Fixed issue with track duration display</span>
</li> </li>
<li class="log"><span class="version">9/30/2012 - 2.0.8</span> <li class="log"><span class="version">9/30/2012 - 2.0.8</span>
<span class="changes">Removed "http://*/" from manifest.json</span> <span class="changes">Removed "http://*/" permission from manifest.json (This was what caused the permissions alert, more info <a href="http://developer.chrome.com/extensions/permission_warnings.html" target="_blank">here</a>)</span>
</li> </li>
<li class="log"><span class="version">9/29/2012 - 2.0.7</span> <li class="log"><span class="version">9/29/2012 - 2.0.7</span>
<span class="changes">Updated to SoundManager2 v297a-20120916</span> <span class="changes">Updated to SoundManager2 v297a-20120916</span>

View file

@ -86,7 +86,7 @@ function loadTabContent(tab) {
if (debug) { console.log("TAG PLAYLIST"); } if (debug) { console.log("TAG PLAYLIST"); }
loadPlaylists(); loadPlaylists();
loadFolders(); loadFolders();
loadGenres(); loadAutoPlaylists();
break; break;
case '#tabPodcasts': case '#tabPodcasts':
if (debug) { console.log("TAG PODCAST"); } if (debug) { console.log("TAG PODCAST"); }

View file

@ -151,8 +151,8 @@ function getGenres() {
}); });
$('#Genres').html(options.join('')); $('#Genres').html(options.join(''));
} }
function loadGenres(refresh) { function loadAutoPlaylists(refresh) {
if (debug) { console.log("LOAD GENRES"); } if (debug) { console.log("LOAD AUTO PLAYLISTS"); }
if (refresh) { if (refresh) {
$('#AutoPlaylistContainer').empty(); $('#AutoPlaylistContainer').empty();
} }
@ -163,7 +163,9 @@ function loadGenres(refresh) {
if (genres) { if (genres) {
genresArr = genres.split(','); genresArr = genres.split(',');
genresArr.unshift('Random'); genresArr.unshift('Random');
genresArr.unshift('Starred');
} else { } else {
genresArr.push('Starred');
genresArr.push('Random'); genresArr.push('Random');
} }
$.each(genresArr, function (i, genre) { $.each(genresArr, function (i, genre) {
@ -264,9 +266,10 @@ function getAlbumListBy(id) {
rowcolor = 'odd'; rowcolor = 'odd';
} }
// Only show albums, not songs (Rated songs will also be returned in API call, trying to display them will break Back button, disabled for now) // Only show albums, not songs (Rated songs will also be returned in API call, trying to display them will break Back button, disabled for now)
var albumhtml; var albumhtml, starred;
if (album.starred !== undefined) { starred = true; } else { starred = false; }
if (album.isDir === true) { if (album.isDir === true) {
albumhtml = generateAlbumHTML(rowcolor, album.id, album.parent, album.coverArt, album.title, album.artist, album.userRating); albumhtml = generateAlbumHTML(rowcolor, album.id, album.parent, album.coverArt, album.title, album.artist, album.userRating, starred);
} }
$(albumhtml).appendTo("#AlbumRows"); $(albumhtml).appendTo("#AlbumRows");
}); });
@ -292,14 +295,77 @@ function getRandomSongList(action, appendto, genre, folder) {
} }
if (folder !== undefined) { if (folder !== undefined) {
gstring = '&musicFolderId=' + folder; gstring = '&musicFolderId=' + folder;
} }
if (genre == 'Starred') {
getStarred(action, appendto, 'song');
} else {
$.ajax({
url: baseURL + '/getRandomSongs.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp&size=' + size + gstring,
method: 'GET',
dataType: 'jsonp',
timeout: 10000,
success: function (data) {
if (data["subsonic-response"].randomSongs.song !== undefined) {
if (appendto === '#TrackContainer') {
$("#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
var items = [];
if (data["subsonic-response"].randomSongs.song.length > 0) {
items = data["subsonic-response"].randomSongs.song;
} else {
items[0] = data["subsonic-response"].randomSongs.song;
}
var rowcolor;
var html;
$.each(items, function (i, item) {
if (i % 2 === 0) {
rowcolor = 'even';
} else {
rowcolor = 'odd';
}
var track, starred;
if (item.starred !== undefined) { starred = true; } else { starred = false; }
if (item.track === undefined) { track = "&nbsp;"; } else { track = item.track; }
var time = secondsToTime(item.duration);
html = generateSongHTML(rowcolor, item.id, item.parent, track, item.title, item.artist, item.album, item.coverArt, item.userRating, starred, time);
$(html).appendTo(appendto);
});
if (appendto === '#TrackContainer') {
updateMessage(items.length + ' Song(s)');
}
if (appendto === '#CurrentPlaylistContainer') {
updateMessage(items.length + ' Song(s) Added');
}
if (action === 'autoplay') {
autoPlay();
}
} else {
$(appendto).empty();
}
}
});
}
}
function getStarred(action, appendto, type) {
var size;
if ($.cookie('AutoPlaylistSize') === null) {
size = 25;
} else {
size = $.cookie('AutoPlaylistSize');
}
$.ajax({ $.ajax({
url: baseURL + '/getRandomSongs.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp&size=' + size + gstring, url: baseURL + '/getStarred.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp&size=' + size,
method: 'GET', method: 'GET',
dataType: 'jsonp', dataType: 'jsonp',
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
if (data["subsonic-response"].randomSongs.song !== undefined) { if (data["subsonic-response"].starred !== undefined) {
if (appendto === '#TrackContainer') { if (appendto === '#TrackContainer') {
$("#TrackContainer").empty(); $("#TrackContainer").empty();
} }
@ -309,10 +375,36 @@ function getRandomSongList(action, appendto, genre, folder) {
} }
// There is a bug in the API that doesn't return a JSON array for one artist // There is a bug in the API that doesn't return a JSON array for one artist
var items = []; var items = [];
if (data["subsonic-response"].randomSongs.song.length > 0) { switch (type) {
items = data["subsonic-response"].randomSongs.song; case 'artist':
} else { if (data["subsonic-response"].starred.artist !== undefined) {
items[0] = data["subsonic-response"].randomSongs.song; if (data["subsonic-response"].starred.artist.length > 0) {
items = data["subsonic-response"].starred.artist;
} else {
items[0] = data["subsonic-response"].starred.artist;
}
}
break;
case 'album':
if (data["subsonic-response"].starred.album !== undefined) {
if (data["subsonic-response"].starred.album.length > 0) {
items = data["subsonic-response"].starred.album;
} else {
items[0] = data["subsonic-response"].starred.album;
}
}
break;
case 'song':
if (data["subsonic-response"].starred.song !== undefined) {
if (data["subsonic-response"].starred.song.length > 0) {
items = data["subsonic-response"].starred.song;
} else {
items[0] = data["subsonic-response"].starred.song;
}
}
break;
default:
break;
} }
var rowcolor; var rowcolor;
@ -323,10 +415,22 @@ function getRandomSongList(action, appendto, genre, folder) {
} else { } else {
rowcolor = 'odd'; rowcolor = 'odd';
} }
var track; var track, starred;
if (item.starred !== undefined) { starred = true; } else { starred = false; }
if (item.track === undefined) { track = "&nbsp;"; } else { track = item.track; } if (item.track === undefined) { track = "&nbsp;"; } else { track = item.track; }
var time = secondsToTime(item.duration); var time = secondsToTime(item.duration);
html = generateSongHTML(rowcolor, item.id, item.parent, track, item.title, item.artist, item.album, item.coverArt, item.userRating, time); switch (type) {
case 'artist':
break;
case 'album':
html = generateRowHTML(item, appendto, rowcolor);
break;
case 'song':
html = generateRowHTML(item, appendto, rowcolor);
break;
default:
break;
}
$(html).appendTo(appendto); $(html).appendTo(appendto);
}); });
if (appendto === '#TrackContainer') { if (appendto === '#TrackContainer') {
@ -444,14 +548,17 @@ function search(type, query) {
} else { } else {
rowcolor = 'odd'; rowcolor = 'odd';
} }
var starred;
if (child.starred !== undefined) { starred = true; } else { starred = false; }
isDir = child.isDir; isDir = child.isDir;
if (isDir === true) { if (isDir === true) {
albumhtml = generateAlbumHTML(rowcolor, child.id, child.parent, child.coverArt, child.title, child.artist, child.userRating); albumhtml = generateAlbumHTML(rowcolor, child.id, child.parent, child.coverArt, child.title, child.artist, child.userRating, starred);
} else { } else {
var track; var track, starred;
if (child.starred !== undefined) { starred = true; } else { starred = false; }
if (child.track === undefined) { track = "&nbsp;"; } else { track = child.track; } if (child.track === undefined) { track = "&nbsp;"; } else { track = child.track; }
var time = secondsToTime(child.duration); var time = secondsToTime(child.duration);
albumhtml = generateSongHTML(rowcolor, child.id, child.parent, track, child.title, child.artist, child.album, child.coverArt, child.userRating, time); albumhtml = generateSongHTML(rowcolor, child.id, child.parent, track, child.title, child.artist, child.album, child.coverArt, child.userRating, starred, time);
} }
$(albumhtml).appendTo("#AlbumRows"); $(albumhtml).appendTo("#AlbumRows");
}); });
@ -777,10 +884,11 @@ function getPlaylist(id, action, appendto) {
} else { } else {
rowcolor = 'odd'; rowcolor = 'odd';
} }
var track; var track, starred;
if (child.starred !== undefined) { starred = true; } else { starred = false; }
if (child.track === undefined) { track = "&nbsp;"; } else { track = child.track; } if (child.track === undefined) { track = "&nbsp;"; } else { track = child.track; }
var time = secondsToTime(child.duration); var time = secondsToTime(child.duration);
html = generateSongHTML(rowcolor, child.id, child.parent, track, child.title, child.artist, child.album, child.coverArt, child.userRating, time); html = generateSongHTML(rowcolor, child.id, child.parent, track, child.title, child.artist, child.album, child.coverArt, child.userRating, starred, time);
$(html).appendTo(appendto); $(html).appendTo(appendto);
}); });
if (appendto === '#TrackContainer tbody') { if (appendto === '#TrackContainer tbody') {

View file

@ -1,15 +1,14 @@
function generateRowHTML(child, appendto, rowcolor) { function generateRowHTML(child, appendto, rowcolor) {
var albumhtml; var albumhtml, isDir, starred, i;
var isDir;
var i;
isDir = child.isDir; isDir = child.isDir;
if (child.starred !== undefined) { starred = true; } else { starred = false; }
if (isDir === true) { if (isDir === true) {
albumhtml = generateAlbumHTML(rowcolor, child.id, child.parent, child.coverArt, child.title, child.artist, child.userRating); albumhtml = generateAlbumHTML(rowcolor, child.id, child.parent, child.coverArt, child.title, child.artist, child.userRating, starred);
} else { } else {
var track; var track;
if (child.track === undefined) { track = "&nbsp;"; } else { track = child.track; } if (child.track === undefined) { track = "&nbsp;"; } else { track = child.track; }
var time = secondsToTime(child.duration); var time = secondsToTime(child.duration);
albumhtml = generateSongHTML(rowcolor, child.id, child.parent, track, child.title, child.artist, child.album, child.coverArt, child.userRating, time); albumhtml = generateSongHTML(rowcolor, child.id, child.parent, track, child.title, child.artist, child.album, child.coverArt, child.userRating, starred, time);
} }
return albumhtml; return albumhtml;
} }
@ -18,13 +17,13 @@ function generateAlbumHeaderHTML() {
html = '<tr><th></th><th></th><th>Album</th><th>Artist</th></tr>'; html = '<tr><th></th><th></th><th>Album</th><th>Artist</th></tr>';
return html; return html;
} }
function generateAlbumHTML(rowcolor, childid, parentid, coverart, title, artist, rating) { function generateAlbumHTML(rowcolor, childid, parentid, coverart, title, artist, rating, starred) {
var html; var html;
html = '<tr class=\"album ' + rowcolor + '\" childid=\"' + childid + '\" parentid=\"' + parentid + '\" userrating=\"' + rating + '\">'; html = '<tr class=\"album ' + rowcolor + '\" childid=\"' + childid + '\" parentid=\"' + parentid + '\" userrating=\"' + rating + '\">';
html += '<td class=\"itemactions\"><a class=\"add\" href=\"\" title=\"Add To Current Playlist\"></a>'; html += '<td class=\"itemactions\"><a class=\"add\" href=\"\" title=\"Add To Current Playlist\"></a>';
html += '<a class=\"play\" href=\"\" title=\"Play\"></a>'; html += '<a class=\"play\" href=\"\" title=\"Play\"></a>';
html += '<a class=\"download\" href=\"\" title=\"Download\"></a>'; html += '<a class=\"download\" href=\"\" title=\"Download\"></a>';
if (rating === 5) { if (starred) {
html += '<a class=\"favorite\" href=\"\" title=\"Favorite\"></a>'; html += '<a class=\"favorite\" href=\"\" title=\"Favorite\"></a>';
} else { } else {
html += '<a class=\"rate\" href=\"\" title=\"Add To Favorites\"></a>'; html += '<a class=\"rate\" href=\"\" title=\"Add To Favorites\"></a>';
@ -45,14 +44,14 @@ function generateSongHeaderHTML() {
html = '<tr><th></th><th>Track</th><th>Title</th><th>Artist</th><th>Album</th><th class=\"alignright\">Time</th></tr>'; html = '<tr><th></th><th>Track</th><th>Title</th><th>Artist</th><th>Album</th><th class=\"alignright\">Time</th></tr>';
return html; return html;
} }
function generateSongHTML(rowcolor, childid, parentid, track, title, artist, album, coverart, rating, time) { function generateSongHTML(rowcolor, childid, parentid, track, title, artist, album, coverart, rating, starred, time) {
var html; var html;
html = '<tr class=\"song ' + rowcolor + '\" childid=\"' + childid + '\" parentid=\"' + parentid + '\" userrating=\"' + rating + '\">'; html = '<tr class=\"song ' + rowcolor + '\" childid=\"' + childid + '\" parentid=\"' + parentid + '\" userrating=\"' + rating + '\">';
html += '<td class=\"itemactions\"><a class=\"add\" href=\"\" title=\"Add To Current Playlist\"></a>'; html += '<td class=\"itemactions\"><a class=\"add\" href=\"\" title=\"Add To Current Playlist\"></a>';
html += '<a class=\"remove\" href=\"\" title=\"Remove\"></a>'; html += '<a class=\"remove\" href=\"\" title=\"Remove\"></a>';
html += '<a class=\"play\" href=\"\" title=\"Play\"></a>'; html += '<a class=\"play\" href=\"\" title=\"Play\"></a>';
html += '<a class=\"download\" href=\"\" title=\"Download\"></a>'; html += '<a class=\"download\" href=\"\" title=\"Download\"></a>';
if (rating === 5) { if (starred) {
html += '<a class=\"favorite\" href=\"\" title=\"Favorite\"></a>'; html += '<a class=\"favorite\" href=\"\" title=\"Favorite\"></a>';
} else { } else {
html += '<a class=\"rate\" href=\"\" title=\"Add To Favorites\"></a>'; html += '<a class=\"rate\" href=\"\" title=\"Add To Favorites\"></a>';

View file

@ -167,6 +167,23 @@ function rateSong(songid, rating) {
} }
}); });
} }
function starItem(itemid, starred) {
var url;
if (starred) {
url = baseURL + '/star.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp&id=' + itemid;
} else {
url = baseURL + '/unstar.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp&id=' + itemid;
}
$.ajax({
url: url,
method: 'GET',
dataType: 'jsonp',
timeout: 10000,
success: function () {
updateMessage('Favorite Updated!');
}
});
}
function playPauseSong() { function playPauseSong() {
var el = '#PlayTrack'; var el = '#PlayTrack';
if ($(el).hasClass('playing')) { if ($(el).hasClass('playing')) {

View file

@ -174,14 +174,16 @@
}); });
$('tr.album a.rate').live('click', function (event) { $('tr.album a.rate').live('click', function (event) {
var itemid = $(this).parent().parent().attr('childid'); var itemid = $(this).parent().parent().attr('childid');
rateSong(itemid, 5); //rateSong(itemid, 5);
starItem(itemid, true);
$(this).removeClass('rate'); $(this).removeClass('rate');
$(this).addClass('favorite'); $(this).addClass('favorite');
return false; return false;
}); });
$('tr.album a.favorite').live('click', function (event) { $('tr.album a.favorite').live('click', function (event) {
var itemid = $(this).parent().parent().attr('childid'); var itemid = $(this).parent().parent().attr('childid');
rateSong(itemid, 0); //rateSong(itemid, 0);
starItem(itemid, false);
$(this).removeClass('favorite'); $(this).removeClass('favorite');
$(this).addClass('rate'); $(this).addClass('rate');
return false; return false;
@ -273,14 +275,16 @@
}); });
$('table.songlist tr.song a.rate').live('click', function (event) { $('table.songlist tr.song a.rate').live('click', function (event) {
var songid = $(this).parent().parent().attr('childid'); var songid = $(this).parent().parent().attr('childid');
rateSong(songid, 5); //rateSong(songid, 5);
starItem(songid, true);
$(this).removeClass('rate'); $(this).removeClass('rate');
$(this).addClass('favorite'); $(this).addClass('favorite');
return false; return false;
}); });
$('table.songlist tr.song a.favorite').live('click', function (event) { $('table.songlist tr.song a.favorite').live('click', function (event) {
var songid = $(this).parent().parent().attr('childid'); var songid = $(this).parent().parent().attr('childid');
rateSong(songid, 0); //rateSong(songid, 0);
starItem(songid, false);
$(this).removeClass('favorite'); $(this).removeClass('favorite');
$(this).addClass('rate'); $(this).addClass('rate');
return false; return false;
@ -539,14 +543,16 @@
}); });
$('#songdetails a.rate').live('click', function (event) { $('#songdetails a.rate').live('click', function (event) {
var itemid = $('#songdetails_song').attr('childid'); var itemid = $('#songdetails_song').attr('childid');
rateSong(itemid, 5); //rateSong(itemid, 5);
starItem(itemid, true);
$(this).removeClass('rate'); $(this).removeClass('rate');
$(this).addClass('favorite'); $(this).addClass('favorite');
return false; return false;
}); });
$('#songdetails a.favorite').live('click', function (event) { $('#songdetails a.favorite').live('click', function (event) {
var itemid = $('#songdetails_song').attr('childid'); var itemid = $('#songdetails_song').attr('childid');
rateSong(itemid, 0); //rateSong(itemid, 0);
starItem(itemid, false);
$(this).removeClass('favorite'); $(this).removeClass('favorite');
$(this).addClass('rate'); $(this).addClass('rate');
return false; return false;
@ -713,5 +719,5 @@
} }
}).disableSelection(); }).disableSelection();
}); // End document.ready }); // End document.ready

View file

@ -2,7 +2,7 @@
"manifest_version": 1, "manifest_version": 1,
"name": "MiniSub", "name": "MiniSub",
"description": "MiniSub - HTML5 Mini Player for Subsonic", "description": "MiniSub - HTML5 Mini Player for Subsonic",
"version": "2.0.9", "version": "2.1",
"app": { "app": {
"launch": { "launch": {
"local_path": "index.html" "local_path": "index.html"