better control-buttons, cleanup, comments
This commit is contained in:
parent
0469c3de11
commit
cb2850b705
66
css/ws.css
66
css/ws.css
@ -1,71 +1,37 @@
|
||||
/*@navbarBackground: green;
|
||||
@navbarBackgroundHighlight: green;
|
||||
@navbarLinkColor: white;
|
||||
@navbarLinkColorHover: white;
|
||||
|
||||
.navbar .nav {
|
||||
height: @navbarHeight;
|
||||
}
|
||||
.navbar .nav > li > a {
|
||||
padding: (@navbarHeight - 20)/2 10px ((@navbarHeight - 20)/2 + 1);
|
||||
}
|
||||
.navbar .brand {
|
||||
padding: (((@navbarHeight - 20) / 2) * 0.8) 20px (((@navbarHeight - 20) / 2) * 1.2);
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
.content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.menutext {
|
||||
vertical-align:bottom;
|
||||
}
|
||||
|
||||
#trackslider {
|
||||
width:90%;
|
||||
}
|
||||
|
||||
#slidercontainer {
|
||||
margin-left:2%;
|
||||
width:95%;
|
||||
margin-top:5px;
|
||||
margin-bottom:5px;
|
||||
}
|
||||
|
||||
#mainmenu a {
|
||||
margin-right:5px;
|
||||
display:inline;
|
||||
}
|
||||
|
||||
.menutext a:hover {
|
||||
text-decoration:none;
|
||||
text-underline-position:0;
|
||||
}
|
||||
|
||||
#controlbt {
|
||||
margin-left: 5px;
|
||||
width: 90px;
|
||||
height: 30px;
|
||||
#controlbt a {
|
||||
margin-top: 4px;
|
||||
margin-left:8px;
|
||||
}
|
||||
|
||||
#playpause {
|
||||
width: 150px;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
a.name, a.album, a.artist {
|
||||
display:block;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
body {
|
||||
padding-top:80px;
|
||||
}
|
||||
|
||||
@media(max-width:979px) {
|
||||
body {
|
||||
padding-top:0px;
|
||||
@ -74,49 +40,39 @@ body {
|
||||
display:block;
|
||||
}
|
||||
}
|
||||
|
||||
@media(min-width:979px) {
|
||||
.btsquare {
|
||||
display:inline;
|
||||
}
|
||||
}
|
||||
|
||||
.nobreak, .btsquare {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
#allresultloader, .loader {
|
||||
display:none;
|
||||
}
|
||||
|
||||
#playlistslist li {
|
||||
padding:5px;
|
||||
list-style-type:none;
|
||||
}
|
||||
|
||||
#playlistslist li:nth-of-type(odd) {
|
||||
background-color:#444;
|
||||
}
|
||||
|
||||
#playlistslist li:nth-of-type(even) {
|
||||
background-color:#333;
|
||||
}
|
||||
|
||||
#volumecontainer {
|
||||
margin-top:3px;
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
padding:9px 0;
|
||||
}
|
||||
.sidebar-nav li {
|
||||
margin-top:20px;
|
||||
}
|
||||
|
||||
#searchresults {
|
||||
display:none;
|
||||
}
|
||||
|
||||
.resultrow:hover {
|
||||
background-color:#555 !important;
|
||||
}
|
||||
@ -126,37 +82,27 @@ body {
|
||||
.nav img {
|
||||
margin-top:16px;
|
||||
}
|
||||
|
||||
.navbar, .navbar-inner, .container {
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
}
|
||||
|
||||
div {
|
||||
/* border: 1px solid #444; */
|
||||
}
|
||||
|
||||
.breakafter {
|
||||
margin-right:15px;
|
||||
}
|
||||
|
||||
.content {
|
||||
display:none;
|
||||
}
|
||||
|
||||
.currenttrack {
|
||||
font-weight:bold;
|
||||
background-image:url('../img/icons/play_alt_16x16.png');
|
||||
background-repeat:no-repeat;
|
||||
padding-left:20px;
|
||||
}
|
||||
|
||||
#songinfo {
|
||||
overflow:hidden;
|
||||
margin-top:5px;
|
||||
/* border: 1px solid white; */
|
||||
}
|
||||
|
||||
#infoname {
|
||||
overflow:hidden;
|
||||
font:bold;
|
||||
@ -165,14 +111,12 @@ div {
|
||||
text-shadow:1px 1px #555;
|
||||
/* border: 1px solid white; */
|
||||
}
|
||||
|
||||
#infoartist {
|
||||
overflow:hidden;
|
||||
color:#aaa;
|
||||
font-size:11px;
|
||||
text-shadow:1px 1px #333;
|
||||
}
|
||||
|
||||
#playlistpane {
|
||||
visibility:hidden;
|
||||
}
|
||||
|
||||
BIN
img/icons/pause_32x32.png
Normal file
BIN
img/icons/pause_32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 179 B |
BIN
img/icons/play_32x32.png
Normal file
BIN
img/icons/play_32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 306 B |
61
index.html
61
index.html
@ -4,54 +4,50 @@
|
||||
<meta http-equiv="imagetoolbar" content="no" />
|
||||
<meta content="true" name="MSSmartTagsPreventParsing" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9" />
|
||||
|
||||
<meta name = "viewport" content = "width=device-width, initial-scale = 1.0, user-scalable = no" />
|
||||
<!-- <meta name="viewport" content="width=device-width, user-scalable=no"> -->
|
||||
<!-- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> -->
|
||||
|
||||
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
|
||||
<link rel="apple-touch-icon" href="img/icons/headphones_32x28.png" />
|
||||
|
||||
<script src="js/html5slider.js"></script>
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
|
||||
<meta charset="utf-8">
|
||||
<title>Mopidy</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="Wouter van Wijk">
|
||||
<meta name="copyright" content="(c) 2012 Wouter van Wijk" />
|
||||
<meta name="copyright" content="(c) 2012/2013 Wouter van Wijk" />
|
||||
<!-- Styles -->
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="css/ws.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<script type="text/javascript" src="/mopidy/mopidy.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a type="button" class="btn btn-navbar" style="margin-left: 5px" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<img src="img/icons/arrow_down_16x16.png" /></a>
|
||||
<a type="button" class="btn btn-navbar" style="margin-left: 5px" data-toggle="collapse" data-target=".nav-collapse"> <img src="img/icons/arrow_down_16x16.png" /></a>
|
||||
<div class="nav pull-right" id="mainmenu">
|
||||
<a href="#playlists"><img src="img/icons/list_nested_24x21.png" /><div class="nav-collapse menutext nobreak hidden-phone"> Playlists</div></a>
|
||||
<a href="#current"><img src="img/icons/list_24x21.png" /><div class="nav-collapse nobreak menutext hidden-phone"> Queue</div></a>
|
||||
<a href="#search"><img src="img/icons/magnifying_glass_24x24.png" /><div class="nav-collapse nobreak menutext hidden-phone"> Search</div></a>
|
||||
<a href="#playlists"><img src="img/icons/list_nested_24x21.png" />
|
||||
<div class="nav-collapse menutext nobreak hidden-phone">
|
||||
Playlists
|
||||
</div></a>
|
||||
<a href="#current"><img src="img/icons/list_24x21.png" />
|
||||
<div class="nav-collapse nobreak menutext hidden-phone">
|
||||
Queue
|
||||
</div></a>
|
||||
<a href="#search"><img src="img/icons/magnifying_glass_24x24.png" />
|
||||
<div class="nav-collapse nobreak menutext hidden-phone">
|
||||
Search
|
||||
</div></a>
|
||||
</div>
|
||||
<div id="controlbt" class="nav span2">
|
||||
<span><a href="#" onclick="doPrevious(); return false"><img src="img/icons/first_16x16.png" alt="Previous Track" /></a></span>
|
||||
<span id="playpause"><a href="#" onclick="doPlayPause(); return false"><img src="img/icons/pause_18x24.png" style="margin-top: 8px;" alt="Play" id="playbt" /></a></span>
|
||||
<span id="playpause"><a href="#" onclick="doPlayPause(); return false"><img src="img/icons/pause_18x24.png" alt="Play" id="playbt" /></a></span>
|
||||
<span><a href="#" onclick="doNext(); return false"><img src="img/icons/last_16x16.png" alt="Next Track" class="breakafter" /></a></span>
|
||||
</div>
|
||||
<div class="nav nav-collapse span2">
|
||||
<a href="#" onclick="doShuffle(); return false"><img src="img/icons/loop_alt2_16x14.png" alt="" id="shufflebt" /></a>
|
||||
<a href="#" onclick="doRandom(); return false"><img src="img/icons/loop_alt2_16x14.png" alt="" id="randombt" /></a>
|
||||
<a href="#" onclick="doRepeat(); return false"><img src="img/icons/reload_12x14.png" id="repeatbt" alt="" /></a>
|
||||
<a href="#" onclick="doMute(); return false;"><img id="mutebt" src="img/icons/volume_16x12.png" alt="" /></a>
|
||||
<!-- <a href="#plus" class="dropdown-toggle" data-toggle="dropdown"><img src="img/icons/plus_12x12.png" alt="" /></a>
|
||||
@ -79,9 +75,6 @@
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- songinfo -->
|
||||
|
||||
</div><!-- /container -->
|
||||
<div class="nav-collapse" id="slidercontainer">
|
||||
<span id="songelapsed">0:00</span>
|
||||
@ -209,7 +202,9 @@
|
||||
<tbody id="albumresulttable"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="span10" style="text-align: center" id="expandsearch"><a href="#" onclick="toggleSearch(); return false;"><img src="img/icons/arrow_down_16x16.png"></a></div>
|
||||
<div class="span10" style="text-align: center" id="expandsearch">
|
||||
<a href="#" onclick="toggleSearch(); return false;"><img src="img/icons/arrow_down_16x16.png"></a>
|
||||
</div>
|
||||
<div class="span11" id="searchtracks">
|
||||
<h4>Tracks</h4>
|
||||
<table class="table table-striped">
|
||||
@ -225,7 +220,8 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- search div -->
|
||||
</div>
|
||||
<!-- search div -->
|
||||
|
||||
</div><!--/row fluid-->
|
||||
</div><!--/.fluid-container-->
|
||||
@ -236,9 +232,9 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
<img src="img/loader.gif" id="offlinemodalloader" class="loader" />
|
||||
Cannot connect to the server... <br/>Please wait.
|
||||
<br/><br/>
|
||||
Cannot connect to the server. Please wait...
|
||||
<br/>
|
||||
<br/>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -249,11 +245,12 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
<img src="img/loader.gif" id="loadingmodalloader" class="loader" />
|
||||
Getting data from the server... <br/><br/>
|
||||
Please wait.<br/><br/>
|
||||
Getting data from the server. Please wait...
|
||||
<br/>
|
||||
<br/>
|
||||
This could take a while (Too much of a while actually. Will be fixed...)
|
||||
<br/><br/>
|
||||
<br/>
|
||||
<br/>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -14,7 +14,7 @@ var socket;
|
||||
|
||||
//values for controls
|
||||
var play = false;
|
||||
var shuffle;
|
||||
var random;
|
||||
var repeat;
|
||||
var currentVolume = -1;
|
||||
var muteVolume = -1;
|
||||
@ -64,7 +64,6 @@ function getAlbum(pl) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//process updated playlist to gui
|
||||
function playlisttotable(pl, table, uri) {
|
||||
/* <tr>
|
||||
@ -103,8 +102,6 @@ function playlisttotable(pl, table, uri) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getPlaylistFromUri(uri) {
|
||||
for (var i = 0; i < playlists.length; i++) {
|
||||
if (playlists[i]["uri"] == uri) {
|
||||
|
||||
142
js/gui.js
142
js/gui.js
@ -13,11 +13,11 @@ function showartist(nwuri) {
|
||||
if (pl) {
|
||||
playlisttotable(pl, ARTIST_TABLE, nwuri)
|
||||
$('#h_artistname').html(getArtist(pl));
|
||||
mopidy.library.lookup(nwuri).then(handleArtistResults,console.error);
|
||||
mopidy.library.lookup(nwuri).then(processArtistResults, console.error);
|
||||
} else {
|
||||
$('#h_artistname').html('');
|
||||
$('#artistsloader').show();
|
||||
mopidy.library.lookup(nwuri).then(handleArtistResults,console.error);
|
||||
mopidy.library.lookup(nwuri).then(processArtistResults, console.error);
|
||||
}
|
||||
//show
|
||||
switchContent('artists', nwuri);
|
||||
@ -33,12 +33,12 @@ function showalbum(uri) {
|
||||
playlisttotable(pl, ALBUM_TABLE, uri)
|
||||
$('#h_albumname').html(getAlbum(pl));
|
||||
$('#h_albumartist').html(getArtist(pl));
|
||||
mopidy.library.lookup(uri).then(handleAlbumResults,console.error);
|
||||
mopidy.library.lookup(uri).then(processAlbumResults, console.error);
|
||||
} else {
|
||||
$('#h_albumname').html('');
|
||||
$('#h_albumartist').html('');
|
||||
$('#albumsloader').show();
|
||||
mopidy.library.lookup(uri).then(handleAlbumResults,console.error);
|
||||
mopidy.library.lookup(uri).then(processAlbumResults, console.error);
|
||||
}
|
||||
//show
|
||||
switchContent('albums', uri);
|
||||
@ -70,8 +70,18 @@ function resizeSonginfo () {
|
||||
$("#infoartist").html(artiststext);
|
||||
//bug in truncate?
|
||||
var spanwidth = $("#infoartist").width() - 1;
|
||||
$("#infoname").truncate({ width: spanwidth, token: '…', center: true, multiline: false});
|
||||
$("#infoartist").truncate({ width: spanwidth, token: '…', center: true, multiline: false});
|
||||
$("#infoname").truncate({
|
||||
width : spanwidth,
|
||||
token : '…',
|
||||
center : true,
|
||||
multiline : false
|
||||
});
|
||||
$("#infoartist").truncate({
|
||||
width : spanwidth,
|
||||
token : '…',
|
||||
center : true,
|
||||
multiline : false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,8 +106,7 @@ function setSongInfo(data) {
|
||||
|
||||
resizeSonginfo();
|
||||
|
||||
$('#currenttable tr .name').each(
|
||||
function() {
|
||||
$('#currenttable tr .name').each(function() {
|
||||
//console.log(this.className);
|
||||
this.className = "name";
|
||||
if (this.id == data["uri"]) {
|
||||
@ -107,9 +116,10 @@ function setSongInfo(data) {
|
||||
});
|
||||
}
|
||||
|
||||
/* Toggle state of play button */
|
||||
function setPlayState(nwplay) {
|
||||
if (nwplay) {
|
||||
$("#playbt").attr('src', 'img/icons/pause_18x24.png');
|
||||
$("#playbt").attr('src', 'img/icons/pause_32x32.png');
|
||||
} else {
|
||||
$("#playbt").attr('src', 'img/icons/play_alt_32x32.png');
|
||||
}
|
||||
@ -119,13 +129,14 @@ function setPlayState(nwplay) {
|
||||
//play or pause
|
||||
function doPlayPause() {
|
||||
if (!play) {
|
||||
mopidy.playback.play().then(console.log);
|
||||
mopidy.playback.play().then();
|
||||
} else {
|
||||
mopidy.playback.pause().then(console.log);
|
||||
mopidy.playback.pause().then();
|
||||
}
|
||||
setPlayState(!play);
|
||||
}
|
||||
|
||||
/* Show tracks of playlist */
|
||||
function setPlaylist(uri) {
|
||||
$(PLAYLIST_TABLE).empty();
|
||||
$('#playlisttablediv').show();
|
||||
@ -139,6 +150,7 @@ function setPlaylist(uri) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Initialise search */
|
||||
function searchPressed(key) {
|
||||
value = $('#searchinput').val();
|
||||
// console.log(value);
|
||||
@ -168,31 +180,12 @@ function initSearch(value) {
|
||||
delete customTracklists['albumresultscache'];
|
||||
delete customTracklists['trackresultscache'];
|
||||
$("#searchresults").hide();
|
||||
mopidy.library.search({any: value}).then(handleSearchResults, console.error);
|
||||
mopidy.library.search({
|
||||
any : value
|
||||
}).then(processSearchResults, console.error);
|
||||
}
|
||||
}
|
||||
|
||||
function initAlbumSearch(value) {
|
||||
if (customTracklists['albumresultscache']) { return; }
|
||||
value = $('#searchinput').val();
|
||||
mopidy.library.search({album: value}).then(handleAlbumSearchResults, console.error);
|
||||
return false;
|
||||
}
|
||||
|
||||
function initTrackSearch(value) {
|
||||
if (customTracklists['trackresultscache']) { return; }
|
||||
value = $('#searchinput').val();
|
||||
mopidy.library.search({track: value}).then(handleTrackSearchResults, console.error);
|
||||
return false;
|
||||
}
|
||||
|
||||
function initArtistSearch(value) {
|
||||
if (customTracklists['artistresultscache']) { return; }
|
||||
value = $('#searchinput').val();
|
||||
mopidy.library.search({artist: value}).then(handleArtistSearchResults, console.error);
|
||||
return false;
|
||||
}
|
||||
|
||||
function doMute() {
|
||||
//only emit the event, not the status
|
||||
|
||||
@ -220,16 +213,16 @@ function setRepeat(nwrepeat) {
|
||||
repeat = nwrepeat;
|
||||
}
|
||||
|
||||
function setShuffle(nwshuffle) {
|
||||
if (shuffle == nwshuffle) {
|
||||
function setRandom(nwrandom) {
|
||||
if (random == nwrandom) {
|
||||
return
|
||||
}
|
||||
if (!nwshuffle) {
|
||||
$("#shufflebt").attr('src', 'img/icons/loop_alt2_24x21.png');
|
||||
if (!nwrandom) {
|
||||
$("#randombt").attr('src', 'img/icons/loop_alt2_24x21.png');
|
||||
} else {
|
||||
$("#shufflebt").attr('src', 'img/icons/loop_24x24.png');
|
||||
$("#randombt").attr('src', 'img/icons/loop_24x24.png');
|
||||
}
|
||||
shuffle = nwshuffle;
|
||||
random = nwrandom;
|
||||
}
|
||||
|
||||
function doPrevious() {
|
||||
@ -245,13 +238,13 @@ function doNext() {
|
||||
mopidy.playback.next();
|
||||
}
|
||||
|
||||
function doShuffle() {
|
||||
if (shuffle == false) {
|
||||
function doRandom() {
|
||||
if (random == false) {
|
||||
mopidy.playback.setRandom(true);
|
||||
} else {
|
||||
mopidy.playback.setRandom(false);
|
||||
}
|
||||
setShuffle(!shuffle);
|
||||
setRandom(!random);
|
||||
}
|
||||
|
||||
function doRepeat() {
|
||||
@ -281,18 +274,22 @@ function doSeekPos(value) {
|
||||
}
|
||||
|
||||
function triggerPos() {
|
||||
if (mopidy) {mopidy.playback.seek(val);}
|
||||
if(play) { resumeTimer();}
|
||||
if (mopidy) {
|
||||
mopidy.playback.seek(val);
|
||||
}
|
||||
if (play) {
|
||||
resumeTimer();
|
||||
}
|
||||
}
|
||||
|
||||
function getPlaylists() {
|
||||
// d = new Date();
|
||||
// console.log('Getplaylists: ' + d.getMilliseconds() );
|
||||
mopidy.playlists.getPlaylists().then(handleGetplaylists, console.error);
|
||||
mopidy.playlists.getPlaylists().then(processGetplaylists, console.error);
|
||||
}
|
||||
|
||||
function getCurrentPlaylist() {
|
||||
mopidy.tracklist.getTracks().then(handleCurrentPlaylist, console.error);
|
||||
mopidy.tracklist.getTracks().then(processCurrentPlaylist, console.error);
|
||||
}
|
||||
|
||||
function setPosition(pos) {
|
||||
@ -306,12 +303,12 @@ function setPosition(pos) {
|
||||
|
||||
//update everything as if reloaded
|
||||
function updateStatusOfAll() {
|
||||
mopidy.playback.getCurrentTrack().then(currentTrackResults, console.error);
|
||||
mopidy.playback.getTimePosition().then(currentPositionResults, console.error);
|
||||
mopidy.playback.getState().then(currentStateResults, console.error);
|
||||
mopidy.playback.getCurrentTrack().then(processCurrenttrack, console.error);
|
||||
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
|
||||
mopidy.playback.getState().then(processPlaystate, console.error);
|
||||
|
||||
mopidy.playback.getRepeat().then(repeatResults, console.error);
|
||||
mopidy.playback.getRandom().then(randomResults, console.error);
|
||||
mopidy.playback.getRepeat().then(processRepeat, console.error);
|
||||
mopidy.playback.getRandom().then(processRandom, console.error);
|
||||
}
|
||||
|
||||
function initSocketevents() {
|
||||
@ -331,7 +328,7 @@ function initSocketevents() {
|
||||
});
|
||||
|
||||
mopidy.on("event:trackPlaybackStarted", function(data) {
|
||||
mopidy.playback.getTimePosition().then(currentPositionResults, console.error);
|
||||
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
|
||||
setSongInfo(data.tl_track.track);
|
||||
setPlayState(true);
|
||||
initTimer();
|
||||
@ -354,7 +351,7 @@ function initSocketevents() {
|
||||
resetSong();
|
||||
break;
|
||||
case "playing":
|
||||
mopidy.playback.getTimePosition().then(currentPositionResults, console.error);
|
||||
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
|
||||
resumeTimer();
|
||||
setPlayState(true);
|
||||
break;
|
||||
@ -365,22 +362,6 @@ function initSocketevents() {
|
||||
getCurrentPlaylist();
|
||||
});
|
||||
|
||||
/* mopidy.on("event:trackPlaybackStopped", function (data) {
|
||||
pauseTimer();
|
||||
setPlayState(false);
|
||||
});
|
||||
|
||||
mopidy.on("event:trackPlaybackEnded", function (data) {
|
||||
pauseTimer();
|
||||
setPlayState(false);
|
||||
});
|
||||
|
||||
mopidy.on("event:trackPlaybackResumed", function (data) {
|
||||
mopidy.playback.getTimePosition().then(currentPositionResults, console.error);
|
||||
resumeTimer();
|
||||
setPlayState(true);
|
||||
});
|
||||
*/
|
||||
mopidy.on("event:seeked", function(data) {
|
||||
setPosition(parseInt(data["time_position"]));
|
||||
});
|
||||
@ -390,12 +371,8 @@ function setVolume(value) {
|
||||
$("#volumeslider").attr("value", value);
|
||||
}
|
||||
|
||||
|
||||
function switchContent(divid, uri) {
|
||||
//TODO
|
||||
// History.pushState({viewpane:divid, state:uri}, divid, "?" + divid + "/" + uri);
|
||||
hash = divid;
|
||||
console.log("switchc hash:" + hash);
|
||||
if (uri) {
|
||||
hash += "/" + uri;
|
||||
}
|
||||
@ -427,8 +404,10 @@ function pauseTimer () {
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
mopidy = new Mopidy(); // Connect to server
|
||||
mopidy.on(console.log); // Log all events
|
||||
mopidy = new Mopidy();
|
||||
// Connect to server
|
||||
mopidy.on(console.log);
|
||||
// Log all events
|
||||
initSocketevents();
|
||||
|
||||
$('.content').hide();
|
||||
@ -460,20 +439,25 @@ $(document).ready(function() {
|
||||
break;
|
||||
case 'search':
|
||||
$("div.searchpane input").focus();
|
||||
if (customTracklists['allresultscache'] == '') { initSearch( $('#searchinput').val() ); }
|
||||
if (customTracklists['allresultscache'] == '') {
|
||||
initSearch($('#searchinput').val());
|
||||
}
|
||||
break;
|
||||
case 'artists':
|
||||
if(uri != '') { showartist(uri);}
|
||||
if (uri != '') {
|
||||
showartist(uri);
|
||||
}
|
||||
break;
|
||||
case 'albums':
|
||||
if(uri != '') { showalbum(uri);}
|
||||
if (uri != '') {
|
||||
showalbum(uri);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the page title based on the hash.
|
||||
document.title = divid;
|
||||
|
||||
|
||||
$('.content').hide();
|
||||
$('.nav li').removeClass('active');
|
||||
$('#li' + divid).addClass('active');
|
||||
|
||||
89
js/ws.js
89
js/ws.js
@ -1,15 +1,15 @@
|
||||
/**
|
||||
* @author Wouter van Wijk
|
||||
*
|
||||
* communication with ws server
|
||||
* these functions communication with ws server
|
||||
*
|
||||
*/
|
||||
|
||||
//play uri, update playlist to player if needed
|
||||
/********************************************************
|
||||
* play an uri from a trackslist or the current playlist
|
||||
*********************************************************/
|
||||
function playtrack(uri, playlisturi) {
|
||||
trackslist = new Array();
|
||||
// console.log('play uri:' + uri);
|
||||
// console.log('playlist uri:' + playlisturi);
|
||||
var track;
|
||||
switchContent('current', uri);
|
||||
tracks = getTracksFromUri(playlisturi);
|
||||
@ -17,7 +17,6 @@ function playtrack(uri, playlisturi) {
|
||||
$(CURRENT_PLAYLIST_TABLE).empty();
|
||||
mopidy.tracklist.clear();
|
||||
mopidy.tracklist.add(tracks);
|
||||
// console.log(tracks);
|
||||
} else {
|
||||
tracks = currentplaylist;
|
||||
}
|
||||
@ -26,7 +25,6 @@ function playtrack(uri, playlisturi) {
|
||||
track = i + 1;
|
||||
}
|
||||
}
|
||||
// console.log(pl.tracks);
|
||||
console.log(track);
|
||||
|
||||
mopidy.playback.stop(true);
|
||||
@ -38,28 +36,40 @@ function playtrack(uri, playlisturi) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function currentTrackResults (data) {
|
||||
//modify results for songinfo
|
||||
// var tr = new Object();
|
||||
// tr["track"] = data;
|
||||
/********************************************************
|
||||
* process results of a (new) currently playing track
|
||||
*********************************************************/
|
||||
function processCurrenttrack(data) {
|
||||
setSongInfo(data);
|
||||
}
|
||||
|
||||
function repeatResults (data) {
|
||||
/********************************************************
|
||||
* process results of a repeat
|
||||
*********************************************************/
|
||||
function processRepeat(data) {
|
||||
setRepeat(data);
|
||||
}
|
||||
|
||||
function randomResults (data) {
|
||||
setShuffle(data);
|
||||
/********************************************************
|
||||
* process results of random
|
||||
*********************************************************/
|
||||
function processRandom(data) {
|
||||
setRandom(data);
|
||||
}
|
||||
|
||||
function currentPositionResults (data) {
|
||||
/********************************************************
|
||||
* process results of current position
|
||||
*********************************************************/
|
||||
function processCurrentposition(data) {
|
||||
pos = parseInt(data);
|
||||
setPosition(pos);
|
||||
console.log('pos:' + pos);
|
||||
}
|
||||
|
||||
function currentStateResults (data) {
|
||||
/********************************************************
|
||||
* process results playstate
|
||||
*********************************************************/
|
||||
function processPlaystate(data) {
|
||||
console.log(data);
|
||||
if (data == 'playing') {
|
||||
setPlayState(true);
|
||||
@ -69,12 +79,16 @@ function currentStateResults (data) {
|
||||
}
|
||||
}
|
||||
|
||||
//process results of list of playlists of the user
|
||||
function handleGetplaylists(resultArr) {
|
||||
/********************************************************
|
||||
* process results of list of playlists of the user
|
||||
*********************************************************/
|
||||
function processGetplaylists(resultArr) {
|
||||
/*<p><ul><li>Donec id elit non mi porta</li><li>Gravida at eget metus. Fusce dapibus.</li><li>Tellus ac cursus commodo</li></p>
|
||||
<p><a class="btn" href="#">More »</a></p>
|
||||
*/
|
||||
if ((!resultArr) || (resultArr == '') ) { return; }
|
||||
if ((!resultArr) || (resultArr == '')) {
|
||||
return;
|
||||
}
|
||||
playlists = resultArr;
|
||||
tmp = '';
|
||||
for (var i = 0; i < playlists.length; i++) {
|
||||
@ -87,8 +101,10 @@ function handleGetplaylists(resultArr) {
|
||||
$("#loadingmodal").modal('hide');
|
||||
}
|
||||
|
||||
//process results of a returned playlist
|
||||
function handlePlaylist(resultArr) {
|
||||
/********************************************************
|
||||
* process results of a returned playlist
|
||||
*********************************************************/
|
||||
function processSinglePlaylist(resultArr) {
|
||||
//cache
|
||||
newplaylisturi = resultArr["uri"];
|
||||
playlists[newplaylisturi] = resultArr;
|
||||
@ -96,14 +112,19 @@ function handlePlaylist(resultArr) {
|
||||
$('#playlistloader').hide();
|
||||
}
|
||||
|
||||
//process results of a returned playlist
|
||||
function handleCurrentPlaylist(resultArr) {
|
||||
/********************************************************
|
||||
* process results of a returned playlist
|
||||
*********************************************************/
|
||||
function processCurrentPlaylist(resultArr) {
|
||||
currentplaylist = resultArr;
|
||||
playlisttotable(resultArr, CURRENT_PLAYLIST_TABLE);
|
||||
mopidy.playback.getCurrentTrack().then(currentTrackResults, console.error);
|
||||
}
|
||||
|
||||
function handleSearchResults(resultArr) {
|
||||
/********************************************************
|
||||
* process results of a search
|
||||
*********************************************************/
|
||||
function processSearchResults(resultArr) {
|
||||
$(SEARCH_TRACK_TABLE).empty();
|
||||
$(SEARCH_ARTIST_TABLE).empty();
|
||||
$(SEARCH_ALBUM_TABLE).empty();
|
||||
@ -115,7 +136,6 @@ function handleSearchResults(resultArr) {
|
||||
var artists = resultArr[1].artists;
|
||||
var child = '';
|
||||
|
||||
|
||||
for (var i = 0; i < artists.length; i++) {
|
||||
child += '<tr class="resultrow';
|
||||
if (i > 4) {
|
||||
@ -142,33 +162,28 @@ function handleSearchResults(resultArr) {
|
||||
}
|
||||
$(SEARCH_ALBUM_TABLE).html(child);
|
||||
|
||||
/* playlisttotable(resultArr[1].albums, SEARCH_ALBUM_TABLE, 'albumresultscache');
|
||||
customTracklists['albumresultscache'] = resultArr[1].albums;
|
||||
$('#albumresultloader').hide();
|
||||
playlisttotable(resultArr[1].artists, SEARCH_ARTIST_TABLE, 'artistresultscache');
|
||||
customTracklists['artistresultscache'] = resultArr[1].artists;
|
||||
*/
|
||||
$('#expandsearch').show();
|
||||
|
||||
$('#allresultloader').hide();
|
||||
}
|
||||
|
||||
function handleArtistResults(resultArr) {
|
||||
// console.log(resultArr.tracks);
|
||||
// console.log(resultArr);
|
||||
/********************************************************
|
||||
* process results of an artist lookup
|
||||
*********************************************************/
|
||||
function processArtistResults(resultArr) {
|
||||
customTracklists[resultArr["uri"]] = resultArr;
|
||||
playlisttotable(resultArr, ARTIST_TABLE, resultArr["uri"]);
|
||||
$('#h_artistname').html(getArtist(resultArr));
|
||||
$('#artistsloader').hide();
|
||||
}
|
||||
|
||||
function handleAlbumResults(resultArr) {
|
||||
//console.log(resultArr.tracks);
|
||||
//console.log(resultArr);
|
||||
/********************************************************
|
||||
* process results of an album lookup
|
||||
*********************************************************/
|
||||
function processAlbumResults(resultArr) {
|
||||
customTracklists[resultArr["uri"]] = resultArr;
|
||||
playlisttotable(resultArr, ALBUM_TABLE, resultArr["uri"]);
|
||||
$('#h_albumname').html(getAlbum(resultArr));
|
||||
//$('#h_albumartist').html('<a href="#" onclick="return showartist(this.id, uri)" id="' + resultArr["uri"] + '">' + getArtist(resultArr) + '</a>');
|
||||
$('#h_albumartist').html(getArtist(resultArr));
|
||||
$('#albumsloader').hide();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user