2.1 Moved ratings to stars
This commit is contained in:
parent
94bfd67946
commit
549fe25b7f
7 changed files with 173 additions and 39 deletions
10
index.html
10
index.html
|
@ -79,11 +79,12 @@
|
|||
</select>
|
||||
<ul id="AutoAlbumContainer" class="simplelist mainlist noselect">
|
||||
<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="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="recent"><span>Recently 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 id="ArtistContainer" class="simplelist mainlist noselect"></ul>
|
||||
</div>
|
||||
|
@ -261,12 +262,15 @@
|
|||
<span class="changes"></span>
|
||||
</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>
|
||||
<span class="changes">Added Dark Theme</span>
|
||||
<span class="changes">Fixed issue with track duration display</span>
|
||||
</li>
|
||||
<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 class="log"><span class="version">9/29/2012 - 2.0.7</span>
|
||||
<span class="changes">Updated to SoundManager2 v297a-20120916</span>
|
||||
|
|
|
@ -86,7 +86,7 @@ function loadTabContent(tab) {
|
|||
if (debug) { console.log("TAG PLAYLIST"); }
|
||||
loadPlaylists();
|
||||
loadFolders();
|
||||
loadGenres();
|
||||
loadAutoPlaylists();
|
||||
break;
|
||||
case '#tabPodcasts':
|
||||
if (debug) { console.log("TAG PODCAST"); }
|
||||
|
|
144
js/libs/api.js
144
js/libs/api.js
|
@ -151,8 +151,8 @@ function getGenres() {
|
|||
});
|
||||
$('#Genres').html(options.join(''));
|
||||
}
|
||||
function loadGenres(refresh) {
|
||||
if (debug) { console.log("LOAD GENRES"); }
|
||||
function loadAutoPlaylists(refresh) {
|
||||
if (debug) { console.log("LOAD AUTO PLAYLISTS"); }
|
||||
if (refresh) {
|
||||
$('#AutoPlaylistContainer').empty();
|
||||
}
|
||||
|
@ -163,7 +163,9 @@ function loadGenres(refresh) {
|
|||
if (genres) {
|
||||
genresArr = genres.split(',');
|
||||
genresArr.unshift('Random');
|
||||
genresArr.unshift('Starred');
|
||||
} else {
|
||||
genresArr.push('Starred');
|
||||
genresArr.push('Random');
|
||||
}
|
||||
$.each(genresArr, function (i, genre) {
|
||||
|
@ -264,9 +266,10 @@ function getAlbumListBy(id) {
|
|||
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)
|
||||
var albumhtml;
|
||||
var albumhtml, starred;
|
||||
if (album.starred !== undefined) { starred = true; } else { starred = false; }
|
||||
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");
|
||||
});
|
||||
|
@ -292,14 +295,77 @@ function getRandomSongList(action, appendto, genre, folder) {
|
|||
}
|
||||
if (folder !== undefined) {
|
||||
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 = " "; } 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({
|
||||
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',
|
||||
dataType: 'jsonp',
|
||||
timeout: 10000,
|
||||
success: function (data) {
|
||||
if (data["subsonic-response"].randomSongs.song !== undefined) {
|
||||
if (data["subsonic-response"].starred !== undefined) {
|
||||
if (appendto === '#TrackContainer') {
|
||||
$("#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
|
||||
var items = [];
|
||||
if (data["subsonic-response"].randomSongs.song.length > 0) {
|
||||
items = data["subsonic-response"].randomSongs.song;
|
||||
} else {
|
||||
items[0] = data["subsonic-response"].randomSongs.song;
|
||||
switch (type) {
|
||||
case 'artist':
|
||||
if (data["subsonic-response"].starred.artist !== undefined) {
|
||||
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;
|
||||
|
@ -323,10 +415,22 @@ function getRandomSongList(action, appendto, genre, folder) {
|
|||
} else {
|
||||
rowcolor = 'odd';
|
||||
}
|
||||
var track;
|
||||
var track, starred;
|
||||
if (item.starred !== undefined) { starred = true; } else { starred = false; }
|
||||
if (item.track === undefined) { track = " "; } 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, 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);
|
||||
});
|
||||
if (appendto === '#TrackContainer') {
|
||||
|
@ -444,14 +548,17 @@ function search(type, query) {
|
|||
} else {
|
||||
rowcolor = 'odd';
|
||||
}
|
||||
var starred;
|
||||
if (child.starred !== undefined) { starred = true; } else { starred = false; }
|
||||
isDir = child.isDir;
|
||||
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 {
|
||||
var track;
|
||||
var track, starred;
|
||||
if (child.starred !== undefined) { starred = true; } else { starred = false; }
|
||||
if (child.track === undefined) { track = " "; } else { track = child.track; }
|
||||
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");
|
||||
});
|
||||
|
@ -777,10 +884,11 @@ function getPlaylist(id, action, appendto) {
|
|||
} else {
|
||||
rowcolor = 'odd';
|
||||
}
|
||||
var track;
|
||||
var track, starred;
|
||||
if (child.starred !== undefined) { starred = true; } else { starred = false; }
|
||||
if (child.track === undefined) { track = " "; } else { track = child.track; }
|
||||
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);
|
||||
});
|
||||
if (appendto === '#TrackContainer tbody') {
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
function generateRowHTML(child, appendto, rowcolor) {
|
||||
var albumhtml;
|
||||
var isDir;
|
||||
var i;
|
||||
var albumhtml, isDir, starred, i;
|
||||
isDir = child.isDir;
|
||||
if (child.starred !== undefined) { starred = true; } else { starred = false; }
|
||||
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 {
|
||||
var track;
|
||||
if (child.track === undefined) { track = " "; } else { track = child.track; }
|
||||
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;
|
||||
}
|
||||
|
@ -18,13 +17,13 @@ function generateAlbumHeaderHTML() {
|
|||
html = '<tr><th></th><th></th><th>Album</th><th>Artist</th></tr>';
|
||||
return html;
|
||||
}
|
||||
function generateAlbumHTML(rowcolor, childid, parentid, coverart, title, artist, rating) {
|
||||
function generateAlbumHTML(rowcolor, childid, parentid, coverart, title, artist, rating, starred) {
|
||||
var html;
|
||||
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 += '<a class=\"play\" href=\"\" title=\"Play\"></a>';
|
||||
html += '<a class=\"download\" href=\"\" title=\"Download\"></a>';
|
||||
if (rating === 5) {
|
||||
if (starred) {
|
||||
html += '<a class=\"favorite\" href=\"\" title=\"Favorite\"></a>';
|
||||
} else {
|
||||
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>';
|
||||
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;
|
||||
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 += '<a class=\"remove\" href=\"\" title=\"Remove\"></a>';
|
||||
html += '<a class=\"play\" href=\"\" title=\"Play\"></a>';
|
||||
html += '<a class=\"download\" href=\"\" title=\"Download\"></a>';
|
||||
if (rating === 5) {
|
||||
if (starred) {
|
||||
html += '<a class=\"favorite\" href=\"\" title=\"Favorite\"></a>';
|
||||
} else {
|
||||
html += '<a class=\"rate\" href=\"\" title=\"Add To Favorites\"></a>';
|
||||
|
|
|
@ -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() {
|
||||
var el = '#PlayTrack';
|
||||
if ($(el).hasClass('playing')) {
|
||||
|
|
|
@ -174,14 +174,16 @@
|
|||
});
|
||||
$('tr.album a.rate').live('click', function (event) {
|
||||
var itemid = $(this).parent().parent().attr('childid');
|
||||
rateSong(itemid, 5);
|
||||
//rateSong(itemid, 5);
|
||||
starItem(itemid, true);
|
||||
$(this).removeClass('rate');
|
||||
$(this).addClass('favorite');
|
||||
return false;
|
||||
});
|
||||
$('tr.album a.favorite').live('click', function (event) {
|
||||
var itemid = $(this).parent().parent().attr('childid');
|
||||
rateSong(itemid, 0);
|
||||
//rateSong(itemid, 0);
|
||||
starItem(itemid, false);
|
||||
$(this).removeClass('favorite');
|
||||
$(this).addClass('rate');
|
||||
return false;
|
||||
|
@ -273,14 +275,16 @@
|
|||
});
|
||||
$('table.songlist tr.song a.rate').live('click', function (event) {
|
||||
var songid = $(this).parent().parent().attr('childid');
|
||||
rateSong(songid, 5);
|
||||
//rateSong(songid, 5);
|
||||
starItem(songid, true);
|
||||
$(this).removeClass('rate');
|
||||
$(this).addClass('favorite');
|
||||
return false;
|
||||
});
|
||||
$('table.songlist tr.song a.favorite').live('click', function (event) {
|
||||
var songid = $(this).parent().parent().attr('childid');
|
||||
rateSong(songid, 0);
|
||||
//rateSong(songid, 0);
|
||||
starItem(songid, false);
|
||||
$(this).removeClass('favorite');
|
||||
$(this).addClass('rate');
|
||||
return false;
|
||||
|
@ -539,14 +543,16 @@
|
|||
});
|
||||
$('#songdetails a.rate').live('click', function (event) {
|
||||
var itemid = $('#songdetails_song').attr('childid');
|
||||
rateSong(itemid, 5);
|
||||
//rateSong(itemid, 5);
|
||||
starItem(itemid, true);
|
||||
$(this).removeClass('rate');
|
||||
$(this).addClass('favorite');
|
||||
return false;
|
||||
});
|
||||
$('#songdetails a.favorite').live('click', function (event) {
|
||||
var itemid = $('#songdetails_song').attr('childid');
|
||||
rateSong(itemid, 0);
|
||||
//rateSong(itemid, 0);
|
||||
starItem(itemid, false);
|
||||
$(this).removeClass('favorite');
|
||||
$(this).addClass('rate');
|
||||
return false;
|
||||
|
@ -713,5 +719,5 @@
|
|||
}
|
||||
}).disableSelection();
|
||||
|
||||
}); // End document.ready
|
||||
}); // End document.ready
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"manifest_version": 1,
|
||||
"name": "MiniSub",
|
||||
"description": "MiniSub - HTML5 Mini Player for Subsonic",
|
||||
"version": "2.0.9",
|
||||
"version": "2.1",
|
||||
"app": {
|
||||
"launch": {
|
||||
"local_path": "index.html"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue