no more siwtch to queue after playing a track, seperately scrolling playlist/tracks

This commit is contained in:
Wouter van Wijk 2013-02-24 21:55:30 +01:00
parent 0eaba322f0
commit 0cc9465faf
7 changed files with 93 additions and 39 deletions

View File

@ -37,7 +37,7 @@
.pl-breakpoint.ui-grid-a .ui-block-a { .pl-breakpoint.ui-grid-a .ui-block-a {
clear: left; clear: left;
} }
#playlisttablediv { #playlisttracksdiv {
margin-left: 10px; margin-left: 10px;
} }
/*search*/ /*search*/
@ -51,6 +51,11 @@
#btcontrols { #btcontrols {
display: none; display: none;
} }
.scroll {
overflow-y: scroll;
overflow-x: hidden;
}
} }
/* tablet etc */ /* tablet etc */
@ -101,6 +106,10 @@
#btcontrols { #btcontrols {
display: block; display: block;
} }
.scroll {
overflow-y: auto;
overflow-x: auto;
}
} }
/* phone portrait */ /* phone portrait */
@ -242,15 +251,19 @@
display: none; display: none;
} }
#playlistspane {
padding: 2px;
}
#artistviewimage, #albumviewcover { #artistviewimage, #albumviewcover {
float: right; float: right;
heigth: 90px; heigth: 90px;
} }
/********************* /*********************
* listviews * listviews
********************/ ********************/
.ui-li-divider { .ui-li-divider {
padding: 2px; padding: 2px;
padding-top: 10px; padding-top: 10px;
@ -267,7 +280,7 @@
} }
.albumli { .albumli {
padding-left: 5px; padding-left: 5px;
} }
.playlistactive { .playlistactive {
@ -285,18 +298,25 @@
margin-right: 3px; margin-right: 3px;
} }
.currenttrack2 {
background-image: url('../images/icons/play_alt_8x8.png');
background-repeat: no-repeat;
background-position: 4px center;
}
.currenttrack { .currenttrack {
background-image: url('../images/icons/play_alt_16x16.png'); background-image: url('../images/icons/play_alt_16x16.png');
background-repeat: no-repeat; background-repeat: no-repeat;
background-color: #eee; background-color: #eee;
background-position: 4px center; background-position: 6px center;
} }
.currenttrack2 a {
margin-left: 8px;
}
.currenttrack a { .currenttrack a {
margin-left: 14px; margin-left: 14px;
} }
/******************* /*******************
* Popups * Popups
*******************/ *******************/

View File

@ -94,7 +94,7 @@
</div> </div>
</div> </div>
<div data-role="header" id="header" data-position="fixed" class="ui-grid-b header-breakpoint"> <div data-role="header" data-tap-toggle="false" id="header" data-position="fixed" class="ui-grid-b header-breakpoint">
<div id="controldiv" class="ui-block-a"> <div id="controldiv" class="ui-block-a">
<span id="btback"><a href="#" onclick="return backbt();"> <img id="backimg"src="images/icons/arrow_left_alt1_24x24.png" /></a></span> <span id="btback"><a href="#" onclick="return backbt();"> <img id="backimg"src="images/icons/arrow_left_alt1_24x24.png" /></a></span>
@ -119,11 +119,11 @@
</div><!-- /header --> </div><!-- /header -->
<div data-role="content" id="playlistspane" class="pane ui-grid-a pl-breakpoint"> <div data-role="content" id="playlistspane" class="pane ui-grid-a pl-breakpoint">
<div class="ui-block-a"> <div class="ui-block-a scroll">
<ul id="playlistslist" data-icon="false" data-inset="true" data-role="listview" data-filter="true"></ul> <ul id="playlistslist" data-icon="false" data-inset="true" data-role="listview"></ul>
</div> </div>
<div class="ui-block-b" id="playlisttablediv"> <div class="ui-block-b scroll" id="playlisttracksdiv">
<ul data-role="listview" data-theme="c" data-icon="false" id="playlisttable" data-inset="true" data-filter="true"></ul> <ul data-role="listview" data-theme="c" data-icon="false" id="playlisttracks" data-inset="true"></ul>
</div> </div>
</div><!--/playlistspane--> </div><!--/playlistspane-->
@ -180,7 +180,7 @@
</div> </div>
<!-- search div --> <!-- search div -->
<div data-role="footer" data-position="fixed"> <div data-role="footer" data-tap-toggle="false" data-position="fixed">
<div data-role="navbar" data-iconpos="left"> <div data-role="navbar" data-iconpos="left">
<ul> <ul>
<li id="navplaylists"> <li id="navplaylists">

View File

@ -29,7 +29,7 @@ function playTrack(addtobottom) {
return false; return false;
} }
switchContent('current', uri); // switchContent('current', uri);
for (var i = 0; i < tracks.length; i++) { for (var i = 0; i < tracks.length; i++) {
if (tracks[i].uri == uri) { if (tracks[i].uri == uri) {

View File

@ -32,6 +32,7 @@ var songlength = 0;
var artistshtml = ''; var artistshtml = '';
var artiststext = ''; var artiststext = '';
var songname = ''; var songname = '';
var songdata = '';
var newposition = 0; var newposition = 0;
//array of cached playlists (not only user-playlists, also search, artist, album-playlists) //array of cached playlists (not only user-playlists, also search, artist, album-playlists)
@ -45,7 +46,7 @@ PROGRAM_NAME = 'MusicBox';
//PROGRAM_NAME = 'Mopidy'; //PROGRAM_NAME = 'Mopidy';
ARTIST_TABLE = '#artiststable'; ARTIST_TABLE = '#artiststable';
ALBUM_TABLE = '#albumstable'; ALBUM_TABLE = '#albumstable';
PLAYLIST_TABLE = '#playlisttable'; PLAYLIST_TABLE = '#playlisttracks';
CURRENT_PLAYLIST_TABLE = '#currenttable'; CURRENT_PLAYLIST_TABLE = '#currenttable';
SEARCH_ALL_TABLE = '#allresulttable'; SEARCH_ALL_TABLE = '#allresulttable';
SEARCH_ALBUM_TABLE = '#albumresulttable'; SEARCH_ALBUM_TABLE = '#albumresulttable';
@ -69,7 +70,7 @@ function scrollToTop() {
} }
function scrollToTracklist() { function scrollToTracklist() {
var divtop = $("#playlisttablediv").offset().top - 25; var divtop = $("#playlisttracksdiv").offset().top - 25;
$('body,html').animate({ $('body,html').animate({
scrollTop : divtop scrollTop : divtop
}, 250); }, 250);
@ -209,15 +210,15 @@ function resultsToTables(results, target, uri) {
} }
//process updated playlist to gui //process updated playlist to gui
function playlisttotable(pl, table, uri) { function playlisttotable(pl, target, uri) {
var tmp = ''; var tmp = '';
$(table).html(''); $(target).html('');
var targetmin = target.substr(1);
var child = ''; var child = '';
for (var i = 0; i < pl.length; i++) { for (var i = 0; i < pl.length; i++) {
popupData[pl[i].uri] = pl[i]; popupData[pl[i].uri] = pl[i];
child = '<li id="' + pl[i].uri + '"><a href="#" onclick="return popupTracks(event, \'' + uri + '\',\'' + pl[i].uri + '\');">'; child = '<li id="' + targetmin + '-' + pl[i].uri + '"><a href="#" onclick="return popupTracks(event, \'' + uri + '\',\'' + pl[i].uri + '\');">';
child += '<h1>' + pl[i].name + "</h1>"; child += '<h1>' + pl[i].name + "</h1>";
child += '<p>'; child += '<p>';
child += '<span style="float: right;">' + timeFromSeconds(pl[i].length / 1000) + '</span>'; child += '<span style="float: right;">' + timeFromSeconds(pl[i].length / 1000) + '</span>';
@ -238,13 +239,13 @@ function playlisttotable(pl, table, uri) {
tmp += child; tmp += child;
}; };
$(table).html(tmp); $(target).html(tmp);
$(table).attr('data', uri); $(target).attr('data', uri);
//create (for new tables) //create (for new tables)
// $(table).listview().trigger("create"); // $(target).listview().trigger("create");
//refresh //refresh
$(table).listview('refresh'); $(target).listview('refresh');
} }
function getPlaylistFromUri(uri) { function getPlaylistFromUri(uri) {

View File

@ -24,7 +24,7 @@ function expandSonginfo() {
} }
function resizeSonginfo() { function resizeSonginfo() {
$("#infoname").html(songname); $("#infoname").html(songdata.name);
$("#infoartist").html(artiststext); $("#infoartist").html(artiststext);
//bug in truncate? //bug in truncate?
var spanwidth = $("#infoartist").width() - 38; var spanwidth = $("#infoartist").width() - 38;
@ -44,10 +44,14 @@ function resizeSonginfo() {
} }
function setSongInfo(data) { function setSongInfo(data) {
if (data) {
songdata = data;
} else {
data = songdata;
}
artistshtml = ''; artistshtml = '';
artiststext = ''; artiststext = '';
songname = data.name; if (data.name == '') {
if (songname == '') {
return; return;
}; };
@ -63,7 +67,7 @@ function setSongInfo(data) {
if (data.album) { if (data.album) {
$("#modalalbum").html('Album: <a href="#" onclick="return showAlbum(\'' + data.album.uri + '\');">' + data.album.name + '</a>'); $("#modalalbum").html('Album: <a href="#" onclick="return showAlbum(\'' + data.album.uri + '\');">' + data.album.name + '</a>');
} }
$("#modalname").html(songname); $("#modalname").html(data.name);
getCover(artiststext, data.album.name, '#infocover, #controlspopupimage', 'extralarge'); getCover(artiststext, data.album.name, '#infocover, #controlspopupimage', 'extralarge');
var arttmp = 'Artist'; var arttmp = 'Artist';
@ -79,12 +83,37 @@ function setSongInfo(data) {
$("#songlength").html(timeFromSeconds(data.length / 1000)); $("#songlength").html(timeFromSeconds(data.length / 1000));
resizeSonginfo(); resizeSonginfo();
$('#currenttable li').each(function() { $('#currenttable li').each(function() {
$(this).removeClass("currenttrack"); $(this).removeClass("currenttrack");
if (this.id == 'currenttable-' + data.uri) { if (this.id == 'currenttable-' + data.uri) {
$(this).addClass('currenttrack'); $(this).addClass('currenttrack');
} }
}); });
$('#playlisttracks li').each(function() {
$(this).removeClass("currenttrack2");
if (this.id == 'playlisttracks-' + data.uri) {
$(this).addClass('currenttrack2');
}
});
$('#trackresulttable li').each(function() {
$(this).removeClass("currenttrack2");
if (this.id == 'trackresulttable-' + data.uri) {
$(this).addClass('currenttrack2');
}
});
$('#artiststable li').each(function() {
$(this).removeClass("currenttrack2");
if (this.id == 'trackresulttable-' + data.uri) {
$(this).addClass('currenttrack2');
}
});
$('#albumstable li').each(function() {
$(this).removeClass("currenttrack2");
if (this.id == 'trackresulttable-' + data.uri) {
$(this).addClass('currenttrack2');
}
});
} }
/*************** /***************
@ -248,7 +277,7 @@ function initSocketevents() {
$(document).ready(function() { $(document).ready(function() {
//$(document).bind("pageinit", function() { //$(document).bind("pageinit", function() {
//check for websockets //check for websockets
if(!window.WebSocket) { if (!window.WebSocket) {
switchContent("playlists"); switchContent("playlists");
$('#playlistspane').html('<h2>Old Browser</h2><p>Sorry. Your browser isn\'t modern enough for this webapp. Modern versions of Chrome, Firefox, Safari all will do. Maybe Opera and Internet Explorer 10 also work, but it\'s not tested.</p>'); $('#playlistspane').html('<h2>Old Browser</h2><p>Sorry. Your browser isn\'t modern enough for this webapp. Modern versions of Chrome, Firefox, Safari all will do. Maybe Opera and Internet Explorer 10 also work, but it\'s not tested.</p>');
exit; exit;
@ -284,8 +313,11 @@ $(document).ready(function() {
$("#btback").hide(); $("#btback").hide();
} }
$('.scroll').height($(window).height() - 100);
$(window).resize(function() { $(window).resize(function() {
resizeSonginfo(); resizeSonginfo();
$('.scroll').height($(window).height() - 100);
}); });
}); });

View File

@ -85,6 +85,7 @@ function processSearchResults(resultArr) {
$('#expandsearch').show(); $('#expandsearch').show();
playlisttotable(results.tracks, SEARCH_TRACK_TABLE, 'trackresultscache'); playlisttotable(results.tracks, SEARCH_TRACK_TABLE, 'trackresultscache');
setSongInfo();
showLoading(false); showLoading(false);
} }
@ -111,7 +112,7 @@ function getCurrentPlaylist() {
********************************************************/ ********************************************************/
function showTracklist(uri) { function showTracklist(uri) {
$(PLAYLIST_TABLE).empty(); $(PLAYLIST_TABLE).empty();
$('#playlisttablediv').show(); $('#playlisttracksdiv').show();
showLoading(true); showLoading(true);
var pl = getPlaylistFromUri(uri); var pl = getPlaylistFromUri(uri);

View File

@ -86,8 +86,7 @@ function processGetTracklist(resultArr) {
var newplaylisturi = resultArr.uri; var newplaylisturi = resultArr.uri;
playlists[newplaylisturi] = resultArr; playlists[newplaylisturi] = resultArr;
resultsToTables(playlists[newplaylisturi].tracks, PLAYLIST_TABLE, newplaylisturi); resultsToTables(playlists[newplaylisturi].tracks, PLAYLIST_TABLE, newplaylisturi);
// playlisttotable(playlists[newplaylisturi].tracks, PLAYLIST_TABLE, newplaylisturi); setSongInfo();
// $('#playlistloader').hide();
showLoading(false); showLoading(false);
scrollToTracklist(); scrollToTracklist();
} }
@ -111,6 +110,7 @@ function processArtistResults(resultArr) {
var artistname = getArtist(resultArr); var artistname = getArtist(resultArr);
$('#h_artistname, #artistpopupname').html(artistname); $('#h_artistname, #artistpopupname').html(artistname);
getArtistImage(artistname, '#artistviewimage, #artistpopupimage', 'extralarge'); getArtistImage(artistname, '#artistviewimage, #artistpopupimage', 'extralarge');
setSongInfo();
showLoading(false); showLoading(false);
} }
@ -127,6 +127,6 @@ function processAlbumResults(resultArr) {
$('#coverpopupalbumname').html(albumname); $('#coverpopupalbumname').html(albumname);
$('#coverpopupartist').html(artistname); $('#coverpopupartist').html(artistname);
getCover(artistname, albumname, '#albumviewcover, #coverpopupimage', 'extralarge'); getCover(artistname, albumname, '#albumviewcover, #coverpopupimage', 'extralarge');
setSongInfo();
showLoading(false); showLoading(false);
// $('#albumsloader').hide();
} }