';
- return songLi;
+ ''
+ return songLi
}
-function resultsToTables(results, target, uri) {
+function resultsToTables (results, target, uri) {
if (!results) {
- return;
+ return
}
- var tlids = [];
+ var tlids = []
if (target == CURRENT_PLAYLIST_TABLE) {
for (i = 0; i < results.length; i++) {
- tlids[i] = results[i].tlid;
- results[i] = results[i].track;
+ tlids[i] = results[i].tlid
+ results[i] = results[i].track
}
}
- var newalbum = [];
- var newtlids = [];
- //keep a list of track URIs for retrieving of covers
- var coversList = [];
- var nextname = '';
- var count = 0;
- $(target).html('');
+ var newalbum = []
+ var newtlids = []
+ // keep a list of track URIs for retrieving of covers
+ var coversList = []
+ var nextname = ''
+ var count = 0
+ $(target).html('')
- //break into albums and put in tables
- var html = '';
- var tableid, j, artistname, alburi, name, iconClass;
- var targetmin = target.substr(1);
- $(target).attr('data', uri);
- var length = 0 || results.length;
+ // break into albums and put in tables
+ var html = ''
+ var tableid, j, artistname, alburi, name, iconClass
+ var targetmin = target.substr(1)
+ $(target).attr('data', uri)
+ var length = 0 || results.length
for (i = 0; i < length; i++) {
- //create album if none extists
+ // create album if none extists
if (!results[i].album) {
- results[i].album = {"__model__": "Album"};
+ results[i].album = {'__model__': 'Album'}
}
- //create album uri if there is none
+ // create album uri if there is none
if (!results[i].album.uri) {
- results[i].album.uri = 'x';
+ results[i].album.uri = 'x'
}
if (!results[i].album.name) {
- results[i].album.name = '';
+ results[i].album.name = ''
}
- //create name if there is no one
+ // create name if there is no one
if (!results[i].name || results[i].name === '') {
- name = results[i].uri.split('/');
- results[i].name = decodeURI(name[name.length - 1]) || 'Track ' + String(i);
+ name = results[i].uri.split('/')
+ results[i].name = decodeURI(name[name.length - 1]) || 'Track ' + String(i)
}
- //leave out unplayable items
- if (results[i].name.substring(0, 12) == '[unplayable]') continue;
+ // leave out unplayable items
+ if (results[i].name.substring(0, 12) == '[unplayable]') continue
- newalbum.push(results[i]);
- newtlids.push(tlids[i]);
- nextname = '';
+ newalbum.push(results[i])
+ newtlids.push(tlids[i])
+ nextname = ''
if ((i < length - 1) && results[i + 1].album && results[i + 1].album.name) {
- nextname = results[i + 1].album.name;
+ nextname = results[i + 1].album.name
}
if (results[i].length == -1) {
- html += '
'
+ newalbum = []
+ newtlids = []
+ nextname = ''
} else {
if ((results[i].album.name != nextname) || (nextname === '')) {
- tableid = 'art' + i;
- //render differently if only one track in the album
+ tableid = 'art' + i
+ // render differently if only one track in the album
if (newalbum.length == 1) {
if (i !== 0) {
- html += '
';
+ html += '
'
}
- iconClass = getMediaClass(newalbum[0].uri);
- var liID = targetmin + '-' + newalbum[0].uri;
+ iconClass = getMediaClass(newalbum[0].uri)
+ var liID = targetmin + '-' + newalbum[0].uri
if (target == CURRENT_PLAYLIST_TABLE) {
html += '
'
}
- $('.popupArtistsLi').hide();
- $('.popupArtistsLv').html(child).show();
- $('.popupArtistsDiv').show();
+ $('.popupArtistsLi').hide()
+ $('.popupArtistsLv').html(child).show()
+ $('.popupArtistsDiv').show()
// this makes the viewport of the window resize somehow
- $('.popupArtistsLv').listview("refresh");
+ $('.popupArtistsLv').listview('refresh')
}
} else {
- $('.popupArtistsDiv').hide();
- $('.popupArtistsLi').hide();
+ $('.popupArtistsDiv').hide()
+ $('.popupArtistsLi').hide()
}
- var hash = document.location.hash.split('?');
- var divid = hash[0].substr(1);
- var popupName = '';
+ var hash = document.location.hash.split('?')
+ var divid = hash[0].substr(1)
+ var popupName = ''
if (divid == 'current') {
- $(".addqueue").hide();
- popupName = '#popupQueue';
+ $('.addqueue').hide()
+ popupName = '#popupQueue'
} else if (divid == 'browse') {
- $(".addqueue").show();
- popupName = '#popupBrowse';
+ $('.addqueue').show()
+ popupName = '#popupBrowse'
} else {
- $(".addqueue").show();
- popupName = '#popupTracks';
+ $('.addqueue').show()
+ popupName = '#popupTracks'
}
if (typeof tlid != 'undefined' && tlid !== '') {
- $(popupName).data("list", listuri).data("track", trackuri).data("tlid", tlid).popup("open", {
+ $(popupName).data('list', listuri).data('track', trackuri).data('tlid', tlid).popup('open', {
x : e.pageX,
y : e.pageY
- });
+ })
} else {
- $(popupName).data("list", listuri).data("track", trackuri).popup("open", {
+ $(popupName).data('list', listuri).data('track', trackuri).popup('open', {
x : e.pageX,
y : e.pageY
- });
+ })
}
- return false;
+ return false
}
-function showAlbumPopup(popupId) {
- uri = $(popupId).data("track");
- showAlbum(popupData[uri].album.uri);
+function showAlbumPopup (popupId) {
+ uri = $(popupId).data('track')
+ showAlbum(popupData[uri].album.uri)
}
-/**********************
+/** ********************
* initialize sockets *
**********************/
-function initSocketevents() {
- mopidy.on("state:online", function() {
- showOffline(false);
- getCurrentPlaylist();
- updateStatusOfAll();
- getPlaylists();
- getUriSchemes().then(function() {
- showFavourites();
- });
- getBrowseDir();
- getSearchSchemes();
- showLoading(false);
- $(window).hashchange();
- });
+function initSocketevents () {
+ mopidy.on('state:online', function () {
+ showOffline(false)
+ getCurrentPlaylist()
+ updateStatusOfAll()
+ getPlaylists()
+ getUriSchemes().then(function () {
+ showFavourites()
+ })
+ getBrowseDir()
+ getSearchSchemes()
+ showLoading(false)
+ $(window).hashchange()
+ })
- mopidy.on("state:offline", function() {
- resetSong();
- showOffline(true);
- });
+ mopidy.on('state:offline', function () {
+ resetSong()
+ showOffline(true)
+ })
- mopidy.on("event:optionsChanged", updateOptions);
+ mopidy.on('event:optionsChanged', updateOptions)
- mopidy.on("event:trackPlaybackStarted", function(data) {
- setSongInfo(data.tl_track);
- setPlayState(true);
- });
+ mopidy.on('event:trackPlaybackStarted', function (data) {
+ setSongInfo(data.tl_track)
+ setPlayState(true)
+ })
- mopidy.on("event:playlistsLoaded", function(data) {
- showLoading(true);
- getPlaylists();
- });
+ mopidy.on('event:playlistsLoaded', function (data) {
+ showLoading(true)
+ getPlaylists()
+ })
- mopidy.on("event:playlistChanged", function(data) {
- $('#playlisttracksdiv').hide();
- $('#playlistslistdiv').show();
- delete playlists[data.playlist.uri];
- getPlaylists();
- });
+ mopidy.on('event:playlistChanged', function (data) {
+ $('#playlisttracksdiv').hide()
+ $('#playlistslistdiv').show()
+ delete playlists[data.playlist.uri]
+ getPlaylists()
+ })
- mopidy.on("event:playlistDeleted", function(data) {
- $('#playlisttracksdiv').hide();
- $('#playlistslistdiv').show();
- delete playlists[data.uri];
- getPlaylists();
- });
+ mopidy.on('event:playlistDeleted', function (data) {
+ $('#playlisttracksdiv').hide()
+ $('#playlistslistdiv').show()
+ delete playlists[data.uri]
+ getPlaylists()
+ })
- mopidy.on("event:volumeChanged", function(data) {
- setVolume(data.volume);
- });
+ mopidy.on('event:volumeChanged', function (data) {
+ setVolume(data.volume)
+ })
- mopidy.on("event:muteChanged", function(data) {
- setMute(data.mute);
- });
+ mopidy.on('event:muteChanged', function (data) {
+ setMute(data.mute)
+ })
- mopidy.on("event:playbackStateChanged", function(data) {
+ mopidy.on('event:playbackStateChanged', function (data) {
switch (data.new_state) {
- case "paused":
- case "stopped":
- setPlayState(false);
- break;
- case "playing":
- setPlayState(true);
- break;
+ case 'paused':
+ case 'stopped':
+ setPlayState(false)
+ break
+ case 'playing':
+ setPlayState(true)
+ break
}
- });
+ })
- mopidy.on("event:tracklistChanged", function(data) {
- getCurrentPlaylist();
- });
+ mopidy.on('event:tracklistChanged', function (data) {
+ getCurrentPlaylist()
+ })
- mopidy.on("event:seeked", function(data) {
- setPosition(parseInt(data.time_position));
+ mopidy.on('event:seeked', function (data) {
+ setPosition(parseInt(data.time_position))
if (play) {
- startProgressTimer();
+ startProgressTimer()
}
- });
+ })
- mopidy.on("event:streamTitleChanged", function(data) {
- setSongTitle(data.title, true);
- });
+ mopidy.on('event:streamTitleChanged', function (data) {
+ setSongTitle(data.title, true)
+ })
}
-$(document).bind("pageinit", function() {
- resizeMb();
+$(document).bind('pageinit', function () {
+ resizeMb()
-});
+})
-/**************
+/** ************
* gui stuff *
**************/
-function toggleFullscreen() {
- if (isMobileSafari) { alert ("To get this app in Full Screen, you have to add it to your home-screen using the Share button."); exit(); }
- if (!isFullscreen() ) { // current working methods
- var docElm = document.documentElement;
+function toggleFullscreen () {
+ if (isMobileSafari) { alert('To get this app in Full Screen, you have to add it to your home-screen using the Share button.'); exit() }
+ if (!isFullscreen()) { // current working methods
+ var docElm = document.documentElement
if (docElm.requestFullscreen) {
- docElm.requestFullscreen();
+ docElm.requestFullscreen()
} else if (docElm.msRequestFullscreen) {
- docElm.msRequestFullscreen();
+ docElm.msRequestFullscreen()
} else if (docElm.mozRequestFullScreen) {
- docElm.mozRequestFullScreen();
+ docElm.mozRequestFullScreen()
} else if (docElm.webkitRequestFullScreen) {
- docElm.webkitRequestFullScreen();
+ docElm.webkitRequestFullScreen()
}
} else {
if (document.exitFullscreen) {
- document.exitFullscreen();
+ document.exitFullscreen()
} else if (document.msExitFullscreen) {
- document.msExitFullscreen();
+ document.msExitFullscreen()
} else if (document.mozCancelFullScreen) {
- document.mozCancelFullScreen();
+ document.mozCancelFullScreen()
} else if (document.webkitCancelFullScreen) {
- document.webkitCancelFullScreen();
+ document.webkitCancelFullScreen()
}
}
}
-function isFullscreen() {
+function isFullscreen () {
return (document.fullscreenElement || // alternative standard method
- document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement ); // current working methods
+ document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement) // current working methods
}
-function switchContent(divid, uri) {
- var hash = divid;
+function switchContent (divid, uri) {
+ var hash = divid
if (uri) {
- hash += "?" + uri;
+ hash += '?' + uri
}
- location.hash = "#" + hash;
+ location.hash = '#' + hash
}
-function setHeadline(site){
- site = site.trim();
- str = $('.mainNav').find('a[href$='+site+']').text();
- if(str === ""){
- str = site.charAt(0).toUpperCase() + site.slice(1);
+function setHeadline (site) {
+ site = site.trim()
+ str = $('.mainNav').find('a[href$=' + site + ']').text()
+ if (str === '') {
+ str = site.charAt(0).toUpperCase() + site.slice(1)
}
- $('#contentHeadline').html('' + str + '');
+ $('#contentHeadline').html('' + str + '')
}
-//update tracklist options.
-function updateOptions() {
- mopidy.tracklist.getRepeat().then(processRepeat, console.error);
- mopidy.tracklist.getRandom().then(processRandom, console.error);
- mopidy.tracklist.getConsume().then(processConsume, console.error);
- mopidy.tracklist.getSingle().then(processSingle, console.error);
+// update tracklist options.
+function updateOptions () {
+ mopidy.tracklist.getRepeat().then(processRepeat, console.error)
+ mopidy.tracklist.getRandom().then(processRandom, console.error)
+ mopidy.tracklist.getConsume().then(processConsume, console.error)
+ mopidy.tracklist.getSingle().then(processSingle, console.error)
}
-//update everything as if reloaded
-function updateStatusOfAll() {
- mopidy.playback.getCurrentTlTrack().then(processCurrenttrack, console.error);
- mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
- mopidy.playback.getState().then(processPlaystate, console.error);
+// update everything as if reloaded
+function updateStatusOfAll () {
+ mopidy.playback.getCurrentTlTrack().then(processCurrenttrack, console.error)
+ mopidy.playback.getTimePosition().then(processCurrentposition, console.error)
+ mopidy.playback.getState().then(processPlaystate, console.error)
- updateOptions();
+ updateOptions()
- mopidy.playback.getVolume().then(processVolume, console.error);
- mopidy.mixer.getMute().then(processMute, console.error);
+ mopidy.playback.getVolume().then(processVolume, console.error)
+ mopidy.mixer.getMute().then(processMute, console.error)
}
-function locationHashChanged() {
- var hash = document.location.hash.split('?');
- //remove #
- var divid = hash[0].substr(1);
- setHeadline(divid);
+function locationHashChanged () {
+ var hash = document.location.hash.split('?')
+ // remove #
+ var divid = hash[0].substr(1)
+ setHeadline(divid)
- var uri = hash[1];
- $('.mainNav a').removeClass('ui-state-active ui-state-persist ui-btn-active');
- //i don't know why some li elements have those classes, but they do, so we need to remove them
- $('.mainNav li').removeClass('ui-state-active ui-state-persist ui-btn-active');
+ var uri = hash[1]
+ $('.mainNav a').removeClass('ui-state-active ui-state-persist ui-btn-active')
+ // i don't know why some li elements have those classes, but they do, so we need to remove them
+ $('.mainNav li').removeClass('ui-state-active ui-state-persist ui-btn-active')
if ($(window).width() < 560) {
- $("#panel").panel("close");
+ $('#panel').panel('close')
}
- $('.pane').hide();
+ $('.pane').hide()
- $('#' + divid + 'pane').show();
+ $('#' + divid + 'pane').show()
- switch(divid) {
+ switch (divid) {
case 'home':
- $('#navhome a').addClass('ui-state-active ui-state-persist ui-btn-active');
- break;
+ $('#navhome a').addClass('ui-state-active ui-state-persist ui-btn-active')
+ break
case 'nowPlaying':
- $('#navnowPlaying a').addClass('ui-state-active ui-state-persist ui-btn-active');
- break;
+ $('#navnowPlaying a').addClass('ui-state-active ui-state-persist ui-btn-active')
+ break
case 'current':
- $('#navcurrent a').addClass('ui-state-active ui-state-persist ui-btn-active');
- getCurrentPlaylist();
- break;
+ $('#navcurrent a').addClass('ui-state-active ui-state-persist ui-btn-active')
+ getCurrentPlaylist()
+ break
case 'playlists':
- $('#navplaylists a').addClass('ui-state-active ui-state-persist ui-btn-active');
- break;
+ $('#navplaylists a').addClass('ui-state-active ui-state-persist ui-btn-active')
+ break
case 'browse':
- $('#navbrowse a').addClass('ui-state-active ui-state-persist ui-btn-active');
- break;
+ $('#navbrowse a').addClass('ui-state-active ui-state-persist ui-btn-active')
+ break
case 'search':
- $('#navsearch a').addClass($.mobile.activeBtnClass);
- $("#searchinput").focus();
+ $('#navsearch a').addClass($.mobile.activeBtnClass)
+ $('#searchinput').focus()
if (customTracklists['mbw:allresultscache'] === '') {
- initSearch($('#searchinput').val());
+ initSearch($('#searchinput').val())
}
- break;
+ break
case 'stream':
- $('#navstream a').addClass('ui-state-active ui-state-persist ui-btn-active');
- break;
+ $('#navstream a').addClass('ui-state-active ui-state-persist ui-btn-active')
+ break
case 'artists':
if (uri !== '') {
- showArtist(uri);
+ showArtist(uri)
}
- break;
+ break
case 'albums':
if (uri !== '') {
- showAlbum(uri);
+ showAlbum(uri)
}
- break;
+ break
}
- //switch the footer
- switch(divid) {
+ // switch the footer
+ switch (divid) {
case 'nowPlaying':
- $('#normalFooter').hide();
- $('#nowPlayingFooter').show();
- break;
+ $('#normalFooter').hide()
+ $('#nowPlayingFooter').show()
+ break
default:
- $('#normalFooter').show();
- $('#nowPlayingFooter').hide();
+ $('#normalFooter').show()
+ $('#nowPlayingFooter').hide()
}
// Set the page title based on the hash.
- document.title = PROGRAM_NAME;
- return false;
+ document.title = PROGRAM_NAME
+ return false
}
-/***********************
+/** *********************
* initialize software *
***********************/
-$(document).ready(function(event) {
- //check for websockets
+$(document).ready(function (event) {
+ // check for websockets
if (!window.WebSocket) {
- switchContent("playlists");
- $('#playlistspane').html('
Old Browser
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.
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.
')
+ exit
}
- //workaround for a bug in jQuery Mobile, without that the panel doesn't close on mobile devices...
- $('.ui-panel-dismiss').on( "tap", function() { $("#panel").panel("close"); } );
- //end of workaround
+ // workaround for a bug in jQuery Mobile, without that the panel doesn't close on mobile devices...
+ $('.ui-panel-dismiss').on( 'tap', function () { $('#panel').panel('close') })
+ // end of workaround
- $(window).hashchange();
+ $(window).hashchange()
// Connect to server
if (websocketUrl) {
@@ -481,196 +481,196 @@ $(document).ready(function(event) {
mopidy = new Mopidy({
webSocketUrl: websocketUrl,
callingConvention: 'by-position-or-by-name'
- });
+ })
} catch (e) {
- showOffline(true);
+ showOffline(true)
}
} else {
try {
- mopidy = new Mopidy({callingConvention: 'by-position-or-by-name'});
- } catch (e) {
- showOffline(true);
- }
+ mopidy = new Mopidy({callingConvention: 'by-position-or-by-name'})
+ } catch (e) {
+ showOffline(true)
+ }
}
- //initialize events
- initSocketevents();
+ // initialize events
+ initSocketevents()
progressTimer = new ProgressTimer({
callback: timerCallback,
- //updateRate: 2000,
- });
+ // updateRate: 2000,
+ })
- resetSong();
+ resetSong()
if (location.hash.length < 2) {
- switchContent("home");
+ switchContent('home')
}
- initgui = false;
- window.onhashchange = locationHashChanged;
+ initgui = false
+ window.onhashchange = locationHashChanged
- //only show backbutton if in UIWebview
+ // only show backbutton if in UIWebview
if (window.navigator.standalone) {
- $("#btback").show();
+ $('#btback').show()
} else {
- $("#btback").hide();
+ $('#btback').hide()
}
- $(window).resize(function() {
- resizeMb();
- });
+ $(window).resize(function () {
+ resizeMb()
+ })
- //navigation temporary, rewrite this!
- $('#songinfo').click(function() {
- return switchContent('nowPlaying');
- });
- $('#controlspopupimage').click(function() {
- return switchContent('current');
- });
- $('#navToggleFullscreen').click(function() {
- toggleFullscreen();
- });
+ // navigation temporary, rewrite this!
+ $('#songinfo').click(function () {
+ return switchContent('nowPlaying')
+ })
+ $('#controlspopupimage').click(function () {
+ return switchContent('current')
+ })
+ $('#navToggleFullscreen').click(function () {
+ toggleFullscreen()
+ })
// event handlers for full screen mode
- $(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange, MSFullscreenChange', function(e) {
+ $(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange, MSFullscreenChange', function (e) {
if (isFullscreen()) {
- document.getElementById("toggletxt").innerHTML = "Exit Fullscreen";
+ document.getElementById('toggletxt').innerHTML = "Exit Fullscreen"
} else {
- document.getElementById("toggletxt").innerHTML = "Fullscreen";
+ document.getElementById('toggletxt').innerHTML = "Fullscreen"
}
- });
+ })
// remove buttons only for MusicBox
if (!isMusicBox) {
- $('#navSettings').hide();
- $('#navshutdown').hide();
- $('#homesettings').hide();
- $('#homeshutdown').hide();
+ $('#navSettings').hide()
+ $('#navshutdown').hide()
+ $('#homesettings').hide()
+ $('#homeshutdown').hide()
}
// remove Alarm Clock if it is not present
if (!hasAlarmClock) {
- $('#navAlarmClock').hide();
- $('#homeAlarmClock').hide();
- $('#homeAlarmClock').nextAll().find('.ui-block-a, .ui-block-b').toggleClass('ui-block-a').toggleClass('ui-block-b');
+ $('#navAlarmClock').hide()
+ $('#homeAlarmClock').hide()
+ $('#homeAlarmClock').nextAll().find('.ui-block-a, .ui-block-b').toggleClass('ui-block-a').toggleClass('ui-block-b')
}
- //navigation stuff
+ // navigation stuff
- $(document).keypress( function (event) {
- //console.log('kp: '+event);
- if (event.target.tagName != 'INPUT') {
- var unicode=event.keyCode? event.keyCode : event.charCode;
- var actualkey=String.fromCharCode(unicode);
- switch(actualkey) {
- case ' ':
- doPlay();
- event.preventDefault();
- break;
- case '>':
- doNext();
- event.preventDefault();
- break;
- case '<':
- doPrevious();
- event.preventDefault();
- break;
+ $(document).keypress(function (event) {
+ // console.log('kp: '+event);
+ if (event.target.tagName != 'INPUT') {
+ var unicode = event.keyCode ? event.keyCode : event.charCode
+ var actualkey = String.fromCharCode(unicode)
+ switch (actualkey) {
+ case ' ':
+ doPlay()
+ event.preventDefault()
+ break
+ case '>':
+ doNext()
+ event.preventDefault()
+ break
+ case '<':
+ doPrevious()
+ event.preventDefault()
+ break
}
- return true;
+ return true
}
- });
+ })
if ($(window).width() < 980) {
- $("#panel").panel("close");
- }else{
- $("#panel").panel("open");
+ $('#panel').panel('close')
+ } else {
+ $('#panel').panel('open')
}
- $.event.special.swipe.horizontalDistanceThreshold = 125; // (default: 30px) Swipe horizontal displacement must be more than this.
- $.event.special.swipe.verticalDistanceThreshold = 50; // (default: 75px) Swipe vertical displacement must be less than this.
- $.event.special.swipe.durationThreshold = 500;
+ $.event.special.swipe.horizontalDistanceThreshold = 125 // (default: 30px) Swipe horizontal displacement must be more than this.
+ $.event.special.swipe.verticalDistanceThreshold = 50 // (default: 75px) Swipe vertical displacement must be less than this.
+ $.event.special.swipe.durationThreshold = 500
// swipe songinfo and panel
- $( "#normalFooter, #nowPlayingFooter" ).on( "swiperight", doPrevious );
- $( "#normalFooter, #nowPlayingFooter" ).on( "swipeleft", doNext );
- $( "#nowPlayingpane, .ui-body-c, #header, #panel, .pane" ).on( "swiperight", function() {
- if(!$(event.target).is("#normalFooter") && !$(event.target).is("#nowPlayingFooter")) {
- $("#panel").panel("open");
- event.stopImmediatePropagation(); }
- } );
- $( "#nowPlayingpane, .ui-body-c, #header, #panel, .pane" ).on( "swipeleft", function() {
- if(!$(event.target).is("#normalFooter") && !$(event.target).is("#nowPlayingFooter")) {
- $("#panel").panel("close");
- event.stopImmediatePropagation(); }
- } );
+ $("#normalFooter, #nowPlayingFooter").on( 'swiperight', doPrevious)
+ $("#normalFooter, #nowPlayingFooter").on( 'swipeleft', doNext)
+ $("#nowPlayingpane, .ui-body-c, #header, #panel, .pane").on( 'swiperight', function () {
+ if (!$(event.target).is('#normalFooter') && !$(event.target).is('#nowPlayingFooter')) {
+ $('#panel').panel('open')
+ event.stopImmediatePropagation() }
+ })
+ $("#nowPlayingpane, .ui-body-c, #header, #panel, .pane").on( 'swipeleft', function () {
+ if (!$(event.target).is('#normalFooter') && !$(event.target).is('#nowPlayingFooter')) {
+ $('#panel').panel('close')
+ event.stopImmediatePropagation() }
+ })
- $( "#trackslider" ).on( "slidestart", function() {
- progressTimer.stop();
- $( "#trackslider" ).on( "change", function() { updatePosition( $(this).val() ); } );
- } );
+ $("#trackslider").on( 'slidestart', function () {
+ progressTimer.stop()
+ $("#trackslider").on( 'change', function () { updatePosition($(this).val()) })
+ })
- $( "#trackslider" ).on( "slidestop", function() {
- $( "#trackslider" ).off( "change");
- doSeekPos( $(this).val() );
- } );
+ $("#trackslider").on( 'slidestop', function () {
+ $("#trackslider").off( 'change')
+ doSeekPos($(this).val())
+ })
- $( "#volumeslider" ).on( "slidestart", function() { volumeSliding = true; } );
- $( "#volumeslider" ).on( "slidestop", function() { volumeSliding = false; } );
- $( "#volumeslider" ).on( "change", function() { doVolume( $(this).val() ); } );
-});
+ $("#volumeslider").on( 'slidestart', function () { volumeSliding = true })
+ $("#volumeslider").on( 'slidestop', function () { volumeSliding = false })
+ $("#volumeslider").on( 'change', function () { doVolume($(this).val()) })
+})
function updatePlayIcons (uri, tlid) {
- //update styles of listviews
- $('#currenttable li').each(function() {
- var eachTlid = $(this).attr('tlid');
+ // update styles of listviews
+ $('#currenttable li').each(function () {
+ var eachTlid = $(this).attr('tlid')
if (typeof eachTlid != 'undefined') {
- eachTlid = parseInt(eachTlid);
+ eachTlid = parseInt(eachTlid)
}
if (this.id == 'currenttable-' + uri && eachTlid == tlid) {
- $(this).addClass('currenttrack');
+ $(this).addClass('currenttrack')
} else {
- $(this).removeClass("currenttrack");
- }
- });
+ $(this).removeClass('currenttrack')
+ }
+ })
- $('#playlisttracks li').each(function() {
+ $('#playlisttracks li').each(function () {
if (this.id == 'playlisttracks-' + uri) {
- $(this).addClass('currenttrack2');
+ $(this).addClass('currenttrack2')
} else {
- $(this).removeClass("currenttrack2");
- }
- });
+ $(this).removeClass('currenttrack2')
+ }
+ })
- $('#trackresulttable li').each(function() {
+ $('#trackresulttable li').each(function () {
if (this.id == 'trackresulttable-' + uri) {
- $(this).addClass('currenttrack2');
+ $(this).addClass('currenttrack2')
} else {
- $(this).removeClass("currenttrack2");
- }
- });
+ $(this).removeClass('currenttrack2')
+ }
+ })
- $('#artiststable li').each(function() {
+ $('#artiststable li').each(function () {
if (this.id == 'artiststable-' + uri) {
- $(this).addClass('currenttrack2');
+ $(this).addClass('currenttrack2')
} else {
- $(this).removeClass("currenttrack2");
- }
- });
+ $(this).removeClass('currenttrack2')
+ }
+ })
- $('#albumstable li').each(function() {
+ $('#albumstable li').each(function () {
if (this.id == 'albumstable-' + uri) {
- $(this).addClass('currenttrack2');
+ $(this).addClass('currenttrack2')
} else {
- $(this).removeClass("currenttrack2");
- }
- });
- $('#browselist li').each(function() {
+ $(this).removeClass('currenttrack2')
+ }
+ })
+ $('#browselist li').each(function () {
if (this.id == 'browselisttracks-' + uri) {
- $(this).addClass('currenttrack2');
+ $(this).addClass('currenttrack2')
} else {
- $(this).removeClass("currenttrack2");
- }
- });
+ $(this).removeClass('currenttrack2')
+ }
+ })
}
diff --git a/mopidy_musicbox_webclient/static/js/images.js b/mopidy_musicbox_webclient/static/js/images.js
index 652fae3..8cb61dc 100644
--- a/mopidy_musicbox_webclient/static/js/images.js
+++ b/mopidy_musicbox_webclient/static/js/images.js
@@ -2,91 +2,91 @@
* @author Wouter van Wijk
*/
-API_KEY = 'b6d34c3af91d62ab0ae00ab1b6fa8733';
-API_SECRET = '2c631802c2285d5d5d1502462fe42a2b';
+API_KEY = 'b6d34c3af91d62ab0ae00ab1b6fa8733'
+API_SECRET = '2c631802c2285d5d5d1502462fe42a2b'
-var fmcache;
-var lastfm;
+var fmcache
+var lastfm
$(window).load(function () {
// create a Cache object
- fmcache = new LastFMCache();
+ fmcache = new LastFMCache()
// create a LastFM object
lastfm = new LastFM({
apiKey : API_KEY,
apiSecret : API_SECRET,
cache : fmcache
- });
-});
+ })
+})
-function getCover(uri, images, size) {
- var defUrl = 'images/default_cover.png';
- $(images).attr('src', defUrl);
+function getCover (uri, images, size) {
+ var defUrl = 'images/default_cover.png'
+ $(images).attr('src', defUrl)
if (!uri) {
- return;
+ return
}
- mopidy.library.getImages({'uris': [uri]}).then(function(imageResults) {
- var uri = Object.keys(imageResults)[0];
+ mopidy.library.getImages({'uris': [uri]}).then(function (imageResults) {
+ var uri = Object.keys(imageResults)[0]
if (imageResults[uri].length > 0) {
- $(images).attr('src', imageResults[uri][0].uri);
+ $(images).attr('src', imageResults[uri][0].uri)
} else {
// Also check deprecated 'album.images' in case backend does not
// implement mopidy.library.getImages yet...
- getCoverFromAlbum(uri, images, size);
+ getCoverFromAlbum(uri, images, size)
}
- });
+ })
}
// Note that this approach has been deprecated in Mopidy
// TODO: Remove when Mopidy no longer supports getting images
// with 'album.images'.
-function getCoverFromAlbum(uri, images, size) {
- mopidy.library.lookup({'uris': [uri]}).then(function(resultDict) {
- var uri = Object.keys(resultDict)[0];
- var track = resultDict[uri][0];
- if (track.album && track.album.images && (track.album.images.length > 0) ) {
- $(images).attr('src', track.album.images[0]);
+function getCoverFromAlbum (uri, images, size) {
+ mopidy.library.lookup({'uris': [uri]}).then(function (resultDict) {
+ var uri = Object.keys(resultDict)[0]
+ var track = resultDict[uri][0]
+ if (track.album && track.album.images && (track.album.images.length > 0)) {
+ $(images).attr('src', track.album.images[0])
} else {
// Fallback to last.fm
- getCoverFromLastFm(track, images, size);
+ getCoverFromLastFm(track, images, size)
}
- });
+ })
}
-function getCoverFromLastFm(track, images, size) {
- var defUrl = 'images/default_cover.png';
+function getCoverFromLastFm (track, images, size) {
+ var defUrl = 'images/default_cover.png'
if (!(track.album || track.artist)) {
- return;
+ return
}
- var albumname = track.album.name || '';
- var artistname = '';
- if ( track.album.artists && (track.album.artists.length > 0) ) {
+ var albumname = track.album.name || ''
+ var artistname = ''
+ if (track.album.artists && (track.album.artists.length > 0)) {
// First look for the artist in the album
- artistname = track.album.artists[0].name;
- } else if (track.artists && (track.artists.length > 0) ) {
+ artistname = track.album.artists[0].name
+ } else if (track.artists && (track.artists.length > 0)) {
// Fallback to using artists for specific track
- artistname = track.artists[0].name;
+ artistname = track.artists[0].name
}
- lastfm.album.getInfo( {artist: artistname, album: albumname},
- { success: function(data) {
+ lastfm.album.getInfo({artist: artistname, album: albumname},
+ { success: function (data) {
for (var i = 0; i < data.album.image.length; i++) {
- if ( data.album.image[i].size == size) {
- $(images).attr('src', data.album.image[i]['#text'] || defUrl);
+ if (data.album.image[i].size == size) {
+ $(images).attr('src', data.album.image[i]['#text'] || defUrl)
}
}
}
- });
+ })
}
-function getArtistImage(nwartist, image, size) {
- var defUrl = 'images/user_24x32.png';
- lastfm.artist.getInfo({artist: nwartist}, {success: function(data){
+function getArtistImage (nwartist, image, size) {
+ var defUrl = 'images/user_24x32.png'
+ lastfm.artist.getInfo({artist: nwartist}, {success: function (data) {
for (var i = 0; i < data.artist.image.length; i++) {
- if ( data.artist.image[i].size == size) {
- $(image).attr('src', data.artist.image[i]['#text'] || defUrl);
+ if (data.artist.image[i].size == size) {
+ $(image).attr('src', data.artist.image[i]['#text'] || defUrl)
}
}
- }});
-}
\ No newline at end of file
+ }})
+}
diff --git a/mopidy_musicbox_webclient/static/js/library.js b/mopidy_musicbox_webclient/static/js/library.js
index 3a62e05..e91e6bc 100644
--- a/mopidy_musicbox_webclient/static/js/library.js
+++ b/mopidy_musicbox_webclient/static/js/library.js
@@ -1,167 +1,167 @@
-/*********************************
+/** *******************************
* Search
*********************************/
-function searchPressed(key) {
- var value = $('#searchinput').val();
- switchContent('search');
+function searchPressed (key) {
+ var value = $('#searchinput').val()
+ switchContent('search')
if (key == 13) {
- initSearch();
- return false;
+ initSearch()
+ return false
}
- return true;
+ return true
}
-//init search
-function initSearch() {
- var value = $('#searchinput').val();
- var searchService = $('#selectSearchService').val();
+// init search
+function initSearch () {
+ var value = $('#searchinput').val()
+ var searchService = $('#selectSearchService').val()
if ((value.length < 100) && (value.length > 0)) {
- showLoading(true);
- //hide ios/android keyboard
- document.activeElement.blur();
- $("input").blur();
+ showLoading(true)
+ // hide ios/android keyboard
+ document.activeElement.blur()
+ $('input').blur()
- delete customTracklists[URI_SCHEME+':allresultscache'];
- delete customTracklists[URI_SCHEME+':artistresultscache'];
- delete customTracklists[URI_SCHEME+':albumresultscache'];
- delete customTracklists[URI_SCHEME+':trackresultscache'];
- $("#searchartists").hide();
- $("#searchalbums").hide();
- $("#searchtracks").hide();
+ delete customTracklists[URI_SCHEME + ':allresultscache']
+ delete customTracklists[URI_SCHEME + ':artistresultscache']
+ delete customTracklists[URI_SCHEME + ':albumresultscache']
+ delete customTracklists[URI_SCHEME + ':trackresultscache']
+ $('#searchartists').hide()
+ $('#searchalbums').hide()
+ $('#searchtracks').hide()
if (searchService != 'all') {
- mopidy.library.search({'query': {any:[value]}, 'uris': [searchService + ':']}).then(processSearchResults, console.error);
+ mopidy.library.search({'query': {any:[value]}, 'uris': [searchService + ':']}).then(processSearchResults, console.error)
} else {
mopidy.getUriSchemes().then(function (schemes) {
var query = {},
- uris = [];
+ uris = []
var regexp = $.map(schemes, function (scheme) {
- return '^' + scheme + ':';
- }).join('|');
+ return '^' + scheme + ':'
+ }).join('|')
- var match = value.match(regexp);
+ var match = value.match(regexp)
if (match) {
- var scheme = match[0];
- query = {uri: [value]};
- uris = [scheme];
+ var scheme = match[0]
+ query = {uri: [value]}
+ uris = [scheme]
} else {
- query = {any: [value]};
+ query = {any: [value]}
}
- mopidy.library.search({'query': query, 'uris': uris}).then(processSearchResults, console.error);
- });
+ mopidy.library.search({'query': query, 'uris': uris}).then(processSearchResults, console.error)
+ })
}
}
}
-/********************************************************
+/** ******************************************************
* process results of a search
*********************************************************/
-//# speed clone http://jsperf.com/cloning-an-object/2
-function clone(obj) {
- var target = {};
+// # speed clone http://jsperf.com/cloning-an-object/2
+function clone (obj) {
+ var target = {}
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
- target[i] = obj[i];
+ target[i] = obj[i]
}
}
- return target;
+ return target
}
-function processSearchResults(resultArr) {
- $(SEARCH_TRACK_TABLE).empty();
- $(SEARCH_ARTIST_TABLE).empty();
- $(SEARCH_ALBUM_TABLE).empty();
+function processSearchResults (resultArr) {
+ $(SEARCH_TRACK_TABLE).empty()
+ $(SEARCH_ARTIST_TABLE).empty()
+ $(SEARCH_ALBUM_TABLE).empty()
// Merge results from different backends.
// TODO should of coures have multiple tables
- var results = {'tracks': [], 'artists': [], 'albums': []};
- var j, emptyResult = true;
+ var results = {'tracks': [], 'artists': [], 'albums': []}
+ var j, emptyResult = true
for (var i = 0; i < resultArr.length; i++) {
if (resultArr[i].tracks) {
for (j = 0; j < resultArr[i].tracks.length; j++) {
- results.tracks.push(resultArr[i].tracks[j]);
- emptyResult = false;
+ results.tracks.push(resultArr[i].tracks[j])
+ emptyResult = false
}
}
if (resultArr[i].artists) {
for (j = 0; j < resultArr[i].artists.length; j++) {
- results.artists.push(resultArr[i].artists[j]);
- emptyResult = false;
+ results.artists.push(resultArr[i].artists[j])
+ emptyResult = false
}
}
if (resultArr[i].albums) {
for (j = 0; j < resultArr[i].albums.length; j++) {
- results.albums.push(resultArr[i].albums[j]);
- emptyResult = false;
+ results.albums.push(resultArr[i].albums[j])
+ emptyResult = false
}
}
}
- customTracklists[URI_SCHEME+':trackresultscache'] = results.tracks;
+ customTracklists[URI_SCHEME + ':trackresultscache'] = results.tracks
if (emptyResult) {
- toast('No results');
- showLoading(false);
- return false;
+ toast('No results')
+ showLoading(false)
+ return false
}
if (results.artists.length > 0) {
- $("#searchartists").show();
+ $('#searchartists').show()
}
if (results.albums.length > 0) {
- $("#searchalbums").show();
+ $('#searchalbums').show()
}
if (results.tracks.length > 0) {
- $("#searchtracks").show();
+ $('#searchtracks').show()
}
// Returns a string where {x} in template is replaced by tokens[x].
- function theme(template, tokens) {
- return template.replace(/{[^}]+}/g, function(match) {
- return tokens[match.slice(1,-1)];
- });
+ function theme (template, tokens) {
+ return template.replace(/{[^}]+}/g, function (match) {
+ return tokens[match.slice(1, -1)]
+ })
}
// 'Show more' pattern
- var showMorePattern = '