/** * @author Wouter van Wijk * * all kinds functions and vars */ var baseurl = '/mopidy'; var host = window.location.hostname; var port = window.location.port; var wsurl = host + ':' + port + baseurl var intv; var socket; var mopidy; //values for controls var play = false; var random; var repeat; var currentVolume = -1; var muteVolume = -1; var volumeChanging = false; var posChanging = false; var posTimer; var volumeTimer; var seekTimer; var initgui = true; var currentpos = 0; var popupData = {}; var songlength = 0; var artistshtml = ''; var artiststext = ''; var songname = ''; var songdata = ''; var newposition = 0; //array of cached playlists (not only user-playlists, also search, artist, album-playlists) var playlists = {}; var currentplaylist; var customPlaylists = []; var customTracklists = []; //constants PROGRAM_NAME = 'MusicBox'; //PROGRAM_NAME = 'Mopidy'; ARTIST_TABLE = '#artiststable'; ALBUM_TABLE = '#albumstable'; PLAYLIST_TABLE = '#playlisttracks'; CURRENT_PLAYLIST_TABLE = '#currenttable'; SEARCH_ALL_TABLE = '#allresulttable'; SEARCH_ALBUM_TABLE = '#albumresulttable'; SEARCH_ARTIST_TABLE = '#artistresulttable'; SEARCH_TRACK_TABLE = '#trackresulttable'; //update track slider timer, milliseconds TRACK_TIMER = 1000; //check status timer, every 5 or 10 sec STATUS_TIMER = 10000; /******* * */ function scrollToTop() { var divtop = 0; $('body,html').animate({ scrollTop : divtop }, 250); } function scrollToTracklist() { var divtop = $("#playlisttracksdiv").offset().top - 25; $('body,html').animate({ scrollTop : divtop }, 250); } //A hack to find the name of the first artist of a playlist. this is not yet returned by mopidy //does not work wel with multiple artists of course function getArtist(pl) { for (var i = 0; i < pl.length; i++) { for (var j = 0; j < pl[i].artists.length; j++) { if (pl[i].artists[j].name != '') { return pl[i].artists[j].name; } } }; } //A hack to find the first album of a playlist. this is not yet returned by mopidy function getAlbum(pl) { for (var i = 0; i < pl.length; i++) { if (pl[i].album.name != '') { return pl[i].album.name; } }; } /******************************************************** * break up results and put them in album tables *********************************************************/ function albumTracksToTable(pl, table, uri) { var tmp = ''; $(table).empty(); var child = ''; for (var i = 0; i < pl.length; i++) { popupData[pl[i].uri] = pl[i]; child = '
' + timeFromSeconds(pl[i].length / 1000) + '
'; html += '' + timeFromSeconds(newalbum[0].length / 1000) + ''; for ( j = 0; j < newalbum[0].artists.length; j++) { html += newalbum[0].artists[j].name; html += (j == newalbum[0].artists.length - 1) ? '' : ' / '; //stop after 3 if (j > 2) { html += '...'; break; } } html += ' / ' + newalbum[0].album.name + '
'; html += '' + results[i].album.name + '
'; for ( j = 0; j < results[i].album.artists.length; j++) { html += results[i].album.artists[j].name; html += (j == results[i].album.artists.length - 1) ? '' : ' / '; //stop after 3 if (j > 2) { child += '...'; break; } } html += '
' + timeFromSeconds(newalbum[j].length / 1000) + '
'; child += '' + timeFromSeconds(pl[i].length / 1000) + ''; // for (var j = 0; j < pl[i].artists.length; j++) { child += pl[i].artists[j].name; child += (j == pl[i].artists.length - 1) ? '' : ' / '; //stop after 3 if (j > 2) { child += '...'; break; } } child += ' / ' + pl[i].album.name + '
'; // child += '' + pl[i].album.name + '
'; child += '