2.2.2 Re-enable drag and drop, ogg support, misc bug fixes

This commit is contained in:
Trevor Squillario 2012-10-25 16:45:45 -04:00
parent 2ea9027235
commit 1265cb8449
10 changed files with 107 additions and 75 deletions

View file

@ -1,7 +1,8 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="UTF-8">
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
<title>Subsonic - MiniSub</title>
<link href="images/subsonic_32x32.ico" rel="shortcut icon" />
<link rel="icon" href="images/subsonic_48x48.png" sizes="48x48"/>
@ -187,7 +188,8 @@
<label for="Password">Password <span class="red">*</span></label><br />
<input type="password" id="Password" name="Password" class="large"/><br />
<label for="Server">Server <span class="red">*</span></label><br />
<input type="text" id="Server" name="Server" class="xlarge" title="Subsonic Server URL Ex: http://host:port/subsonic"/><br />
<input type="text" id="Server" name="Server" class="xlarge" title="Subsonic Server URL Ex: http://host:port/subsonic"/>
<!--<a href="#" class="button" id="action_RequestURL" title="Request Permission for Server URL">Enable URL</a><br />-->
<label for="SubsonicVersion">Subsonic API: <span id="SubsonicVersion"></span></label><br />
</div>
<div class="subsection floatleft">
@ -277,6 +279,11 @@
<span class="changes">- </span>
</li>
-->
<li class="log"><span class="version">10/25/2012 - 2.2.2</span>
<span class="changes">- Re-enabled Drag and Drop sorting on Current Playlist</span>
<span class="changes">- Started passing the contentType directly (hopefully supporting Ogg, as well as others depending on your browser)</span>
<span class="changes">- Taking a lot of crap for the "Access your data on all websites", sorry I have no other choice! (<a href="https://groups.google.com/a/chromium.org/d/msg/chromium-apps/Q1M1HoLpOCo/hFBCS07acCMJ" target="_blank">Chromium Apps Forum Post</a>)</span>
</li>
<li class="log"><span class="version">10/15/2012 - 2.2.0</span>
<span class="changes">- Column sorting for all headers in all tables! (Thanks to <a href="https://github.com/joequery/Stupid-Table-Plugin" target="_blank">joequery</a>)</span>
<span class="changes">- Fancy Webkit styled scrollbars for those of you with browsers that don't suck (Works with Dark theme)</span>

View file

@ -10,7 +10,7 @@ var passwordenc;
var server;
var smwidth;
var volume = 50;
var currentVersion = '2.2.1';
var currentVersion = '2.2.2';
function getCookie(value) {
if ($.cookie(value)) {

View file

@ -309,6 +309,7 @@ function toggleAlbumListNextPrev(el, on, type, offset) {
}
}
function getRandomSongList(action, appendto, genre, folder) {
if (debug) { console.log('action:' + action + ', appendto:' + appendto + ', genre:' + genre + ', folder:' + folder); }
var size, gstring;
gstring = '';
if (getCookie('AutoPlaylistSize')) {
@ -316,14 +317,13 @@ function getRandomSongList(action, appendto, genre, folder) {
} else {
size = 25;
}
if (genre !== undefined && genre != '') {
if (genre != '' && genre != 'Random') {
gstring = '&genre=' + genre;
}
if (genre == 'Random') {
gstring = '';
}
if (folder !== undefined && folder != '') {
gstring = '&musicFolderId=' + folder;
}
if (typeof folder == 'number' && folder == 0) {
gstring = '&musicFolderId=' + folder;
} else if (folder != '') {
gstring = '&musicFolderId=' + folder;
}
if (genre == 'Starred') {
getStarred(action, appendto, 'song');
@ -372,10 +372,9 @@ function getRandomSongList(action, appendto, genre, folder) {
}
if (appendto === '#CurrentPlaylistContainer tbody') {
updateMessage(items.length + ' Song(s) Added');
updateStatus('#status_Current', countCurrentPlaylist('#CurrentPlaylistContainer'));
}
if (action == '' && genre == '' && folder == '') {
nextPlay();
} else if (action == 'autoplay') {
if (action == 'autoplay' || action == 'autoplayappend') {
autoPlay();
}
} else {
@ -526,7 +525,7 @@ function updateNowPlaying(showPopup) {
if (msg.coverArt === undefined) {
coverartSrc = 'images/albumdefault_50.jpg';
} else {
coverartSrc = baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=json&size=50&id=' + msg.coverArt;
coverartSrc = baseURL + '/getCoverArt.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=json&size=50&id=' + msg.coverArt;
}
if (getCookie('Notification_NowPlaying')) {
var sid = msg.username + '-' + msg.id;
@ -1165,7 +1164,7 @@ function loadVideos(refresh) {
if (video.coverArt === undefined) {
coverartSrc = 'images/albumdefault_25.jpg';
} else {
coverartSrc = baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=json&size=25&id=' + video.coverArt;
coverartSrc = baseURL + '/getCoverArt.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=json&size=25&id=' + video.coverArt;
}
var time = secondsToTime(video.duration);
html += '<td class=\"album\"><img src=\"' + coverartSrc + '\" />' + video.album + '</td>';

View file

@ -1,16 +1,17 @@
function generateRowHTML(child, appendto, rowcolor) {
var albumhtml, isDir, starred, duration, i;
var html, isDir, starred, duration, artist, i;
isDir = child.isDir;
if (child.starred !== undefined) { starred = true; } else { starred = false; }
if (child.duration !== undefined) { duration = child.duration; } else { duration = ''; }
if (child.artist !== undefined) { artist = child.artist; } else { artist = ''; }
if (isDir === true) {
albumhtml = generateAlbumHTML(rowcolor, child.id, child.parent, child.coverArt, child.title, child.artist, child.userRating, starred);
html = generateAlbumHTML(rowcolor, child.id, child.parent, child.coverArt, child.title, artist, child.userRating, starred);
} else {
var track;
if (child.track === undefined) { track = "&nbsp;"; } else { track = child.track; }
albumhtml = generateSongHTML(rowcolor, child.id, child.parent, track, child.title, '', child.artist, child.album, child.coverArt, child.userRating, starred, duration);
html = generateSongHTML(rowcolor, child.id, child.parent, track, child.title, '', artist, child.album, child.coverArt, child.userRating, starred, duration);
}
return albumhtml;
return html;
}
function generateAlbumHeaderHTML() {
var html;
@ -32,7 +33,7 @@ function generateAlbumHTML(rowcolor, childid, parentid, coverart, title, artist,
if (coverart == undefined) {
html += '<td class=\"albumart\"><img src=\"images/albumdefault_50.jpg\" /></td>';
} else {
html += '<td class=\"albumart\"><img src=\"' + baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=json&size=50&id=' + coverart + '\" /></td>';
html += '<td class=\"albumart\"><img src=\"' + baseURL + '/getCoverArt.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=json&size=50&id=' + coverart + '\" /></td>';
}
html += '<td class=\"album\">' + title + '</td>';
html += '<td class=\"artist\">' + artist + '</td>';
@ -74,7 +75,7 @@ function generateSongHTML(rowcolor, childid, parentid, track, title, description
if (coverart == undefined) {
coverartSrc = 'images/albumdefault_25.jpg';
} else {
coverartSrc = baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=json&size=25&id=' + coverart;
coverartSrc = baseURL + '/getCoverArt.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=json&size=25&id=' + coverart;
}
html += '<td class=\"album\" data-order-by=\"' + album + '\"><a href="#" class=\"albumlink\"><img src=\"' + coverartSrc + '\" />' + album + '</a></td>';
html += '<td class=\"time\">' + time + '</td>';

View file

@ -1,4 +1,5 @@
var scrobbled = false;
var timerid = 0;
function playSong(el, songid, albumid, position, loadonly) {
ajaxUrl = baseURL + '/getMusicDirectory.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=json&id=' + albumid;
if (debug) { console.log(ajaxUrl) }
@ -8,7 +9,7 @@ function playSong(el, songid, albumid, position, loadonly) {
dataType: 'json',
timeout: 10000,
success: function (data) {
var title, artist, album, rating, starred;
var title, artist, album, rating, starred, contenttype;
if (data["subsonic-response"].directory.child !== undefined) {
// There is a bug in the API that doesn't return a JSON array for one artist
var children = [];
@ -20,10 +21,11 @@ function playSong(el, songid, albumid, position, loadonly) {
$.each(children, function (i, child) {
if (child.id == songid) {
title = child.title.toString();
artist = child.artist;
if (child.artist !== undefined) { artist = child.artist.toString(); } else { artist = ''; }
album = child.album;
coverart = child.coverArt;
rating = child.userRating;
if (child.contentType !== undefined) { contenttype = child.contentType; } else { contenttype = 'audio/mp3'; }
if (child.starred !== undefined) { starred = true; } else { starred = false; }
}
});
@ -44,8 +46,8 @@ function playSong(el, songid, albumid, position, loadonly) {
coverartSrc = 'images/albumdefault_56.jpg';
coverartFullSrc = '';
} else {
coverartSrc = baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=json&size=56&id=' + coverart;
coverartFullSrc = baseURL + '/getCoverArt.view?v=' + version + '&c=' + applicationName + '&f=json&id=' + coverart;
coverartSrc = baseURL + '/getCoverArt.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=json&size=56&id=' + coverart;
coverartFullSrc = baseURL + '/getCoverArt.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=json&id=' + coverart;
}
$('#coverartimage').attr('href', coverartFullSrc);
$('#coverartimage img').attr('src', coverartSrc);
@ -66,7 +68,7 @@ function playSong(el, songid, albumid, position, loadonly) {
id: 'audio',
url: baseURL + '/stream.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&id=' + songid + '&salt=' + salt,
stream: true,
type: 'audio/mp3',
type: contenttype,
multiShot: false,
whileloading: function () {
//if (debug) { console.log('loaded:' + this.bytesLoaded + ' total:' + this.bytesTotal); }
@ -129,9 +131,7 @@ function playSong(el, songid, albumid, position, loadonly) {
var next = $('#CurrentPlaylistContainer tr.playing').next();
if (!changeTrack(next)) {
if (getCookie('AutoPilot')) {
//var genre = $(this).data('genre');
//var folder = $(this).data('folder');
getRandomSongList('', '#CurrentPlaylistContainer tbody', '', '');
getRandomSongList('autoplayappend', '#CurrentPlaylistContainer tbody', '', '');
}
}
},
@ -147,6 +147,19 @@ function playSong(el, songid, albumid, position, loadonly) {
seekAndPlay('audio', p);
soundManager.setVolume('audio', volume);
}
if (getCookie('SaveTrackPosition')) {
if (timerid != 0) {
clearInterval(timerid);
}
timerid = window.setInterval(function () {
if (getCookie('SaveTrackPosition')) {
var sm = soundManager.getSoundById('audio');
if (sm !== undefined) {
saveTrackPosition();
}
}
}, 5000);
}
var submenu = $('div#submenu_CurrentPlaylist');
if (submenu.is(":visible")) {
submenu.fadeOut();
@ -288,36 +301,37 @@ function changeTrack(next) {
return false;
}
}
function autoPlay() {
if (debug) { console.log('Auto Play'); }
var song = $('#CurrentPlaylistContainer tr.playing');
nextSong = $('#CurrentPlaylistContainer tr.playing').next();
if (song.length == 0) {
song = $('#CurrentPlaylistContainer tr.song:first');
play = true;
} else if (song.length == 1) {
play = false;
//$('#NextTrack').click();
}
var songid = $(song).attr('childid');
var albumid = $(song).attr('parentid');
playSong(song, songid, albumid, 0, false);
}
function nextPlay() {
function autoPlay(loadonly) {
if (debug) { console.log('Next Play'); }
var song = $('#CurrentPlaylistContainer tr.playing');
var nextSong = $('#CurrentPlaylistContainer tr.playing').next();
if (song.length == 0) {
song = $('#CurrentPlaylistContainer tr.song:first');
var songid = $(song).attr('childid');
var albumid = $(song).attr('parentid');
playSong(song, songid, albumid, 0, false);
} else if (nextSong.length == 1) {
song = $('#CurrentPlaylistContainer tr.playing').next();
var songid = $(song).attr('childid');
var albumid = $(song).attr('parentid');
playSong(song, songid, albumid, 0, false);
if (loadonly) {
// No songs currently playing, so get first and do not play
song = $('#CurrentPlaylistContainer tr.song:first');
var songid = $(song).attr('childid');
var albumid = $(song).attr('parentid');
playSong(song, songid, albumid, 0, true);
} else {
// No songs currently playing, so get first and play
song = $('#CurrentPlaylistContainer tr.song:first');
var songid = $(song).attr('childid');
var albumid = $(song).attr('parentid');
playSong(song, songid, albumid, 0, false);
}
} else {
//song = $('#CurrentPlaylistContainer tr.playing').next();
if (nextSong.length == 1) {
// Get next song after currently playing
song = $('#CurrentPlaylistContainer tr.playing').next();
var songid = $(song).attr('childid');
var albumid = $(song).attr('parentid');
playSong(song, songid, albumid, 0, false);
} else {
// Otherwise get
song = $('#CurrentPlaylistContainer tr.playing');
var songid = $(song).attr('childid');
var albumid = $(song).attr('parentid');
playSong(song, songid, albumid, 0, false);
}
}
}

View file

@ -20,6 +20,8 @@ function HexEncode(n) {
r[t] = i[n.charCodeAt(t)];
return r.join("")
}
String.prototype.hexDecode = function () { var r = ''; for (var i = 0; i < this.length; i += 2) { r += unescape('%' + this.substr(i, 2)); } return r; }
String.prototype.hexEncode = function () { var r = ''; var i = 0; var h; while (i < this.length) { h = this.charCodeAt(i++).toString(16); while (h.length < 2) { h = h; } r += h; } return r; }
function findKeyForCode(code) {
var map = { 'keymap': [
{ 'key': 'a', 'code': 65 },
@ -293,3 +295,14 @@ function parseDate(date) {
var date = months[month] + " " + dateParts[2] + ", " + dateParts[0];
return date;
}
function askPermission() {
chrome.permissions.request({
origins: [getCookie('Server')]
}, function (granted) {
if (granted) {
return true;
} else {
return false;
}
});
}

View file

@ -18,16 +18,6 @@
$(el).hide();
}
});
if (getCookie('SaveTrackPosition')) {
window.setInterval(function () {
if (getCookie('SaveTrackPosition')) {
var sm = soundManager.getSoundById('audio');
if (sm !== undefined) {
saveTrackPosition();
}
}
}, 5000);
}
if (getCookie('CurrentSong')) {
var currentSong = JSON.parse(getCookie("CurrentSong"));
playSong(null, currentSong.songid, currentSong.albumid, currentSong.position, true);

View file

@ -65,12 +65,16 @@
}
// Table Sorting
$('#CurrentPlaylistContainer').stupidtable();
$('#TrackContainer').stupidtable();
$('#PodcastContainer').stupidtable();
$('#AlbumContainer').stupidtable();
$('#action_RequestURL').click(function () {
askPermission();
return false;
});
// Tabs
$('.tabcontent').hide(); //Hide all content
if (!getCookie('username') && !getCookie('passwordenc') && !getCookie('Server')) {
@ -629,7 +633,7 @@
msg = 'Autopilot On';
if ($('#CurrentPlaylistContainer tbody').html() == '') {
$('#CurrentPlaylistContainer tbody').empty();
getRandomSongList('', '#CurrentPlaylistContainer tbody', '', '');
getRandomSongList('autoplay', '#CurrentPlaylistContainer tbody', '', '');
$('#currentActions a.button').removeClass('disabled');
}
}
@ -642,8 +646,8 @@
$('#AutoPlaylistContainer li.item, #FolderContainer li.item').live('click', function () {
$('#AutoPlaylistContainer li, #FolderContainer li, #PlaylistContainer li').removeClass('selected');
$(this).addClass('selected');
var genre = $(this).data('genre');
var folder = $(this).data('folder');
var genre = $(this).data('genre') !== undefined ? $(this).data('genre') : '';
var folder = $(this).data('folder') !== undefined ? $(this).data('folder') : '';
getRandomSongList('', '#TrackContainer tbody', genre, folder);
});
$('#AutoPlaylistContainer li.item a.play, #FolderContainer li.item a.play').live('click', function () {
@ -909,8 +913,9 @@
if ($('#SaveTrackPosition').is(':checked')) {
setCookie('SaveTrackPosition', '1');
var sm = soundManager.getSoundById('audio');
if (sm !== undefined) {
if (sm) {
saveTrackPosition();
alert('save');
}
} else {
setCookie('SaveTrackPosition', null);
@ -942,7 +947,6 @@
return false;
});
/*
// JQuery UI Sortable - Drag and drop sorting
var fixHelper = function (e, ui) {
ui.children().each(function () {
@ -956,6 +960,5 @@
$("#TrackContainer tbody").sortable({
helper: fixHelper
}).disableSelection();
*/
}); // End document.ready

View file

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

View file

@ -280,6 +280,7 @@ a#logo:hover
{
display: block;
}
/* Library Style */
ul.simplelist
{
@ -659,6 +660,10 @@ table.songlist tr.selected td:first-child
{
background: url('../images/check_8x7.png') 10px 16px no-repeat;
}
table.songlist tr.selected td.album a
{
color: #ffffff;
}
#ArtistContainer
{
min-height: 360px;