1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-06-23 13:13:15 +00:00

Feat: add last played tab to queue card

This commit is contained in:
jcorporation 2018-11-14 23:14:47 +00:00
parent bf317d4039
commit 34c0506a3b
10 changed files with 143 additions and 135 deletions

View File

@ -70,9 +70,9 @@ post_upgrade() {
[ -f /var/lib/mympd/state/colsPlayback ] || echo -n '["Artist","Album","Genre"]' > /var/lib/mympd/state/colsPlayback
[ -f /var/lib/mympd/state/colsBrowseFilesystem ] || echo -n '["Type","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowseFilesystem
[ -f /var/lib/mympd/state/colsBrowsePlaylistsDetail ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowsePlaylistsDetail
[ -f /var/lib/mympd/state/colsQueue ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueue
[ -f /var/lib/mympd/state/colsQueueCurrent ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueueCurrent
[ -f /var/lib/mympd/state/colsSearch ] || echo -n '["Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsSearch
[ -f /var/lib/mympd/state/colsLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsLastPlayed
[ -f /var/lib/mympd/state/colsQueueLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsQueueLastPlayed
# fix ownership of /var/lib/mympd
echo "INFO: Fixing ownership of /var/lib/mympd"

View File

@ -85,9 +85,9 @@ done
[ -f /var/lib/mympd/state/colsBrowseFilesystem ] || echo -n '["Type","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowseFilesystem
[ -f /var/lib/mympd/state/colsPlayback ] || echo -n '["Artist","Album","Genre"]' > /var/lib/mympd/state/colsPlayback
[ -f /var/lib/mympd/state/colsBrowsePlaylistsDetail ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowsePlaylistsDetail
[ -f /var/lib/mympd/state/colsQueue ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueue
[ -f /var/lib/mympd/state/colsQueueCurrent ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueueCurrent
[ -f /var/lib/mympd/state/colsSearch ] || echo -n '["Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsSearch
[ -f /var/lib/mympd/state/colsLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsLastPlayed
[ -f /var/lib/mympd/state/colsQueueLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsQueueLastPlayed
echo "Fixing ownership of /var/lib/mympd"
chown -R mympd.mympd /var/lib/mympd

4
debian/postinst vendored
View File

@ -65,8 +65,8 @@ fi
[ -f /var/lib/mympd/state/colsBrowseFilesystem ] || echo -n '["Type","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowseFilesystem
[ -f /var/lib/mympd/state/colsPlayback ] || echo -n '["Artist","Album","Genre"]' > /var/lib/mympd/state/colsPlayback
[ -f /var/lib/mympd/state/colsBrowsePlaylistsDetail ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowsePlaylistsDetail
[ -f /var/lib/mympd/state/colsQueue ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueue
[ -f /var/lib/mympd/state/colsLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsLastPlayed
[ -f /var/lib/mympd/state/colsQueueCurrent ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueueCurrent
[ -f /var/lib/mympd/state/colsQueueLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsQueueLastPlayed
[ -f /var/lib/mympd/state/colsSearch ] || echo -n '["Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsSearch
echo "Fixing ownership of /var/lib/mympd"

View File

@ -320,4 +320,8 @@ div.key {
width: 20px;
heigth: 20px;
text-align: center;
}
#QueueCurrentLength, #QueueLastPlayedLength {
padding-top: 5px;
}

View File

@ -109,11 +109,19 @@
</div>
<div class="card hide" id="cardQueue">
<div class="card-header">
Queue<span id="panel-heading-queue" class="text pull-right"></span>
<div class="card-header" id="cardHeaderQueue">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<a data-href='{"cmd": "appGoto", "options": ["Queue", "Current"]}' class="nav-link text-dark" href="#" id="cardQueueNavCurrent">Queue</a>
</li>
<li class="nav-item">
<a data-href='{"cmd": "appGoto", "options": ["Queue", "LastPlayed"]}' class="nav-link text-dark" href="#" id="cardQueueNavLastPlayed">Last Played</a>
</li>
</ul>
</div>
<div class="card-body">
<div class="btn-toolbar card-toolbar" id="queue-buttons">
<div class="card-body hide" id="cardQueueCurrent">
<div class="btn-toolbar card-toolbar" id="QueueCurrentButtonsTop">
<div class="btn-group mr-2 featPlaylists">
<button type="button" class="btn btn-secondary material-icons" data-toggle="modal" data-target="#modalSaveQueue" title="Save queue">
save
@ -147,25 +155,27 @@
</div>
</div>
</form>
<div id="QueuePaginationTop" class="btn-group mr-2 hide">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueuePaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div id="QueueCurrentPaginationTop" class="btn-group mr-2 hide">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueueCurrentPaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div class="input-group-append">
<button id="QueuePaginationTopPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueuePaginationTopPages">
<button id="QueueCurrentPaginationTopPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueueCurrentPaginationTopPages">
</div>
</div>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueuePaginationTopNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueueCurrentPaginationTopNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
</div>
<div class="btn-group mr-2 featTags">
<button id="QueueColsBtn" class="btn btn-secondary dropdown-toggle material-icons" type="button" data-toggle="dropdown">settings</button>
<div class="dropdown-menu bg-dark px-2" id="QueueColsDropdown"><form></form>
<button data-href='{"cmd": "saveCols", "options": ["Queue"]}' class="btn btn-success btn-block btn-sm mt-2">Apply</button>
<button id="QueueCurrentColsBtn" class="btn btn-secondary dropdown-toggle material-icons" type="button" data-toggle="dropdown">settings</button>
<div class="dropdown-menu bg-dark px-2" id="QueueCurrentColsDropdown"><form></form>
<button data-href='{"cmd": "saveCols", "options": ["QueueCurrent"]}' class="btn btn-success btn-block btn-sm mt-2">Apply</button>
</div>
</div>
<div class="btn-group mr-2" id="QueueCurrentLength">
</div>
</div>
<div class="table-responsive-md">
<table id="QueueList" class="table table-hover table-sm" data-version="">
<table id="QueueCurrentList" class="table table-hover table-sm" data-version="">
<thead>
<tr>
<th>#</th>
@ -180,48 +190,47 @@
</tbody>
</table>
</div>
<div class="btn-toolbar hide" id="QueueButtonsBottom">
<div class="btn-toolbar hide" id="QueueCurrentButtonsBottom">
<div class="btn-group mr-2">
<button type="button" class="btn btn-secondary material-icons" data-href='{"cmd": "scrollTo", "options: [0]}' title="To top">
keyboard_arrow_up
</button>
</div>
<div id="QueuePaginationBottom" class="btn-group mr-2 dropup">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueuePaginationBottomPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div id="QueueCurrentPaginationBottom" class="btn-group mr-2 dropup">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueueCurrentPaginationBottomPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div class="input-group-append">
<button id="QueuePaginationBottomPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueuePaginationBottomPages">
<button id="QueueCurrentPaginationBottomPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueueCurrentPaginationBottomPages">
</div>
</div>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueuePaginationBottomNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueueCurrentPaginationBottomNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
</div>
</div>
</div>
</div>
<div class="card hide" id="cardLastPlayed">
<div class="card-header">Last Played Songs<span id="panel-heading-last-played" class="text pull-right"></span></div>
<div class="card-body">
<div class="card-body hide" id="cardQueueLastPlayed">
<div class="btn-toolbar card-toolbar">
<div id="LastPlayedPaginationTop" class="btn-group mr-2 hide">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="LastPlayedPaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div id="QueueLastPlayedPaginationTop" class="btn-group mr-2 hide">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueueLastPlayedPaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div class="input-group-append">
<button id="LastPlayedPaginationTopPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="LastPlayedPaginationTopPages">
<button id="QueueLastPlayedPaginationTopPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueueLastPlayedPaginationTopPages">
</div>
</div>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="LastPlayedPaginationTopNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueueLastPlayedPaginationTopNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
</div>
<div class="btn-group mr-2 featTags">
<button id="LastPlayedColsBtn" class="btn btn-secondary dropdown-toggle material-icons" type="button" data-toggle="dropdown">settings</button>
<div class="dropdown-menu bg-dark px-2" id="LastPlayedColsDropdown"><form></form>
<button data-href='{"cmd": "saveCols", "options": ["LastPlayed"]}' class="btn btn-success btn-block btn-sm mt-2">Apply</button>
<button id="QueueLastPlayedColsBtn" class="btn btn-secondary dropdown-toggle material-icons" type="button" data-toggle="dropdown">settings</button>
<div class="dropdown-menu bg-dark px-2" id="QueueLastPlayedColsDropdown"><form></form>
<button data-href='{"cmd": "saveCols", "options": ["QueueLastPlayed"]}' class="btn btn-success btn-block btn-sm mt-2">Apply</button>
</div>
</div>
<div class="btn-group mr-2" id="QueueLastPlayedLength">
</div>
</div>
<div class="table-responsive-md">
<table id="LastPlayedList" class="table table-hover table-sm">
<table id="QueueLastPlayedList" class="table table-hover table-sm">
<thead>
<tr>
<th>#</th>
@ -236,27 +245,27 @@
</tbody>
</table>
</div>
<div class="btn-toolbar hide" id="LastPlayedButtonsBottom">
<div class="btn-toolbar hide" id="QueueLastPlayedButtonsBottom">
<div class="btn-group mr-2">
<button type="button" class="btn btn-secondary material-icons" data-href='{"cmd": "scrollTo", "options: [0]}' title="To top">
keyboard_arrow_up
</button>
</div>
<div id="LastPlayedPaginationBottom" class="btn-group mr-2 dropup">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="LastPlayedPaginationBottomPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div id="QueueLastPlayedPaginationBottom" class="btn-group mr-2 dropup">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueueLastPlayedPaginationBottomPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div class="input-group-append">
<button id="LastPlayedPaginationBottomPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="LastPlayedPaginationBottomPages">
<button id="QueueLastPlayedPaginationBottomPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueueLastPlayedPaginationBottomPages">
</div>
</div>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="LastPlayedPaginationBottomNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueueLastPlayedPaginationBottomNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
</div>
</div>
</div>
</div>
<div class="card hide" id="cardBrowse">
<div class="card-header" id="panel-heading-browse">
<div class="card-header" id="cardHeaderBrowse">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item featTags">
<a data-href='{"cmd": "appGoto", "options": ["Browse", "Database"]}' class="nav-link text-dark" href="#" id="cardBrowseNavDatabase">Database</a>

View File

@ -15,11 +15,12 @@ var keymap = {
"y": {"cmd": "openModal", "options": ["modalAbout"], "action": "Open About"},
"i": {"cmd": "clickTitle", "options": [], "action": "Open Song Details"},
"1": {"cmd": "appGoto", "options": ["Playback"], "action": "Goto Playback"},
"2": {"cmd": "appGoto", "options": ["Queue"], "action": "Goto Queue"},
"3": {"cmd": "appGoto", "options": ["Browse","Database"], "action": "Goto Browse Database"},
"4": {"cmd": "appGoto", "options": ["Browse","Playlists"], "action": "Goto Browse Playlists"},
"5": {"cmd": "appGoto", "options": ["Browse","Filesystem"], "action": "Goto Browse Filesystem"},
"6": {"cmd": "appGoto", "options": ["Search"], "action": "Goto Search"},
"2": {"cmd": "appGoto", "options": ["Queue","Current"], "action": "Goto Queue"},
"3": {"cmd": "appGoto", "options": ["Queue","LastPlayed"], "action": "Goto Last Played"},
"4": {"cmd": "appGoto", "options": ["Browse","Database"], "action": "Goto Browse Database"},
"5": {"cmd": "appGoto", "options": ["Browse","Playlists"], "action": "Goto Browse Playlists"},
"6": {"cmd": "appGoto", "options": ["Browse","Filesystem"], "action": "Goto Browse Filesystem"},
"7": {"cmd": "appGoto", "options": ["Search"], "action": "Goto Search"},
"m": {"cmd": "openDropdown", "options": ["dropdownMainMenu"], "action": "Open Main Menu"},
"v": {"cmd": "openDropdown", "options": ["dropdownVolumeMenu"], "action": "Open Volume Menu"},
"S": {"cmd": "MPD_API_QUEUE_SHUFFLE", "options": [], "action": "Shuffle Queue"},

View File

@ -38,8 +38,12 @@ var playlistEl;
var app = {};
app.apps = { "Playback": { "state": "0/-/", "scrollPos": 0 },
"Queue": { "state": "0/any/", "scrollPos": 0 },
"LastPlayed": { "state": "0/any/", "scrollPos": 0 },
"Queue": {
"active": "Current",
"tabs": { "Current": { "state": "0/any/", "scrollPos": 0 },
"LastPlayed": { "state": "0/any/", "scrollPos": 0 }
}
},
"Browse": {
"active": "Database",
"tabs": { "Filesystem": { "state": "0/-/", "scrollPos": 0 },
@ -65,8 +69,10 @@ app.last = { "app": undefined, "tab": undefined, "view": undefined, "filter": ""
var domCache = {};
domCache.navbarBottomBtns = document.getElementById('navbar-bottom').getElementsByTagName('div');
domCache.navbarBottomBtnsLen = domCache.navbarBottomBtns.length;
domCache.panelHeadingBrowse = document.getElementById('panel-heading-browse').getElementsByTagName('a');
domCache.panelHeadingBrowseLen = domCache.panelHeadingBrowse.length;
domCache.cardHeaderBrowse = document.getElementById('cardHeaderBrowse').getElementsByTagName('a');
domCache.cardHeaderBrowseLen = domCache.cardHeaderBrowse.length;
domCache.cardHeaderQueue = document.getElementById('cardHeaderQueue').getElementsByTagName('a');
domCache.cardHeaderQueueLen = domCache.cardHeaderQueue.length;
domCache.counter = document.getElementById('counter');
domCache.volumePrct = document.getElementById('volumePrct');
domCache.volumeControl = document.getElementById('volumeControl');
@ -111,13 +117,15 @@ function appPrepare(scrollPos) {
document.getElementById('cardPlayback').classList.add('hide');
document.getElementById('cardQueue').classList.add('hide');
document.getElementById('cardBrowse').classList.add('hide');
document.getElementById('cardSearch').classList.add('hide');
document.getElementById('cardLastPlayed').classList.add('hide');
for (var i = 0; i < domCache.panelHeadingBrowseLen; i++) {
domCache.panelHeadingBrowse[i].classList.remove('active');
}
document.getElementById('cardQueueLastPlayed').classList.add('hide');
for (var i = 0; i < domCache.cardHeaderBrowseLen; i++)
domCache.cardHeaderBrowse[i].classList.remove('active');
for (var i = 0; i < domCache.cardHeaderQueueLen; i++)
domCache.cardHeaderQueue[i].classList.remove('active');
document.getElementById('cardQueueCurrent').classList.add('hide');
document.getElementById('cardQueueLastPlayed').classList.add('hide');
document.getElementById('cardBrowsePlaylists').classList.add('hide');
document.getElementById('cardBrowseDatabase').classList.add('hide');
document.getElementById('cardBrowseDatabase').classList.add('hide');
document.getElementById('cardBrowseFilesystem').classList.add('hide');
//show active card + nav
document.getElementById('card' + app.current.app).classList.remove('hide');
@ -192,7 +200,8 @@ function appRoute() {
app.current.page = parseInt(params[5]);
app.current.filter = params[6];
app.current.search = params[7];
} else {
}
else {
appGoto('Playback');
return;
}
@ -202,11 +211,11 @@ function appRoute() {
if (app.current.app == 'Playback') {
sendAPI({"cmd": "MPD_API_PLAYER_CURRENT_SONG"}, songChange);
}
else if (app.current.app == 'Queue' ) {
else if (app.current.app == 'Queue' && app.current.tab == 'Current' ) {
selectTag('searchqueuetags', 'searchqueuetagsdesc', app.current.filter);
getQueue();
}
else if (app.current.app == 'LastPlayed') {
else if (app.current.app == 'Queue' && app.current.tab == 'LastPlayed') {
sendAPI({"cmd": "MPD_API_QUEUE_LAST_PLAYED", "data": {"offset": app.current.page}}, parseLastPlayed);
}
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'All') {
@ -461,14 +470,14 @@ function appInit() {
toggleBtn(event.target.id);
}, false);
document.getElementById('QueueList').addEventListener('click', function(event) {
document.getElementById('QueueCurrentList').addEventListener('click', function(event) {
if (event.target.nodeName == 'TD')
sendAPI({"cmd": "MPD_API_PLAYER_PLAY_TRACK","data": {"track": event.target.parentNode.getAttribute('data-trackid')}});
else if (event.target.nodeName == 'A')
showMenu(event.target, event);
}, false);
document.getElementById('LastPlayedList').addEventListener('click', function(event) {
document.getElementById('QueueLastPlayedList').addEventListener('click', function(event) {
if (event.target.nodeName == 'A')
showMenu(event.target, event);
}, false);
@ -578,8 +587,8 @@ function appInit() {
appGoto(app.current.app, app.current.tab, app.current.view, app.current.page + '/' + event.target.getAttribute('data-tag') + '/' + app.current.search);
}, false);
var dropdowns = ['QueueColsDropdown', 'BrowseFilesystemColsDropdown', 'SearchColsDropdown', 'BrowsePlaylistsDetailColsDropdown',
'BrowseDatabaseColsDropdown', 'PlaybackColsDropdown', 'LastPlayedColsDropdown'];
var dropdowns = ['QueueCurrentColsDropdown', 'BrowseFilesystemColsDropdown', 'SearchColsDropdown', 'BrowsePlaylistsDetailColsDropdown',
'BrowseDatabaseColsDropdown', 'PlaybackColsDropdown', 'QueueLastPlayedColsDropdown'];
for (var i = 0; i < dropdowns.length; i++) {
document.getElementById(dropdowns[i]).addEventListener('click', function(event) {
if (event.target.nodeName == 'INPUT')
@ -611,10 +620,10 @@ function appInit() {
hideMenu();
}, false);
dragAndDropTable('QueueList');
dragAndDropTable('QueueCurrentList');
dragAndDropTable('BrowsePlaylistsDetailList');
dragAndDropTableHeader('Queue');
dragAndDropTableHeader('LastPlayed');
dragAndDropTableHeader('QueueCurrent');
dragAndDropTableHeader('QueueLastPlayed');
dragAndDropTableHeader('Search');
dragAndDropTableHeader('BrowseFilesystem');
dragAndDropTableHeader('BrowsePlaylistsDetail');
@ -769,7 +778,7 @@ function dragAndDropTable(table) {
tr[i].classList.remove('dragover');
}
document.getElementById(table).classList.add('opacity05');
if (app.current.app == 'Queue')
if (app.current.app == 'Queue' && app.current.tab == 'Current')
sendAPI({"cmd": "MPD_API_QUEUE_MOVE_TRACK","data": {"from": oldSongpos, "to": newSongpos}});
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail')
playlistMoveTrack(oldSongpos, newSongpos);
@ -978,11 +987,11 @@ function filterCols(x) {
if (settings.featTags == false)
tags.push('Title');
tags.push('Duration');
if (x == 'colsQueue' || x == 'colsBrowsePlaylistsDetail' || x == 'colsLastPlayed')
if (x == 'colsQueueCurrent' || x == 'colsBrowsePlaylistsDetail' || x == 'colsQueueLastPlayed')
tags.push('Pos');
else if (x == 'colsBrowseFilesystem')
tags.push('Type');
if (x == 'colsLastPlayed')
if (x == 'colsQueueLastPlayed')
tags.push('LastPlayed');
var cols = [];
@ -1061,8 +1070,8 @@ function parseSettings(obj) {
app.apps.Browse.active = 'Filesystem';
app.apps.Search.state = '0/filename/';
app.apps.Queue.state = '0/filename/';
settings.colsQueue = ["Pos", "Title", "Duration"];
settings.colsLastPlayed = ["Pos", "Title", "LastPlayed"];
settings.colsQueueCurrent = ["Pos", "Title", "Duration"];
settings.colsQueueLastPlayed = ["Pos", "Title", "LastPlayed"];
settings.colsSearch = ["Title", "Duration"];
settings.colsBrowseFilesystem = ["Type", "Title", "Duration"];
settings.colsBrowseDatabase = ["Track", "Title", "Duration"];
@ -1116,8 +1125,8 @@ function parseSettings(obj) {
settings.searchtags.sort();
settings.browsetags.sort();
filterCols('colsSearch');
filterCols('colsQueue');
filterCols('colsLastPlayed');
filterCols('colsQueueCurrent');
filterCols('colsQueueLastPlayed');
filterCols('colsBrowsePlaylistsDetail');
filterCols('colsBrowseFilesystem');
filterCols('colsBrowseDatabase');
@ -1160,16 +1169,16 @@ function parseSettings(obj) {
document.getElementById('syscmds').innerHTML = '';
dropdownMainMenu = new Dropdown(document.getElementById('mainMenu'));
setCols('Queue');
setCols('QueueCurrent');
setCols('Search');
setCols('LastPlayed');
setCols('QueueLastPlayed');
setCols('BrowseFilesystem');
setCols('BrowsePlaylistsDetail');
setCols('BrowseDatabase', '.tblAlbumTitles');
setCols('Playback');
if (app.current.app == 'Queue')
if (app.current.app == 'Queue' && app.current.tab == 'Current')
getQueue();
else if (app.current.app == 'LastPlayed')
else if (app.current.app == 'Queue' && app.current.tab == 'LastPlayed')
appRoute();
else if (app.current.app == 'Search')
appRoute();
@ -1187,11 +1196,11 @@ function setCols(table, className) {
if (settings.featTags == false)
tags.push('Title');
tags.push('Duration');
if (table == 'Queue' || table == 'BrowsePlaylistsDetail' || table == 'LastPlayed')
if (table == 'QueueCurrent' || table == 'BrowsePlaylistsDetail' || table == 'QueueLastPlayed')
tags.push('Pos');
if (table == 'BrowseFilesystem')
tags.push('Type');
if (table == 'LastPlayed')
if (table == 'QueueLastPlayed')
tags.push('LastPlayed');
tags.sort();
@ -1455,26 +1464,19 @@ function getQueue() {
}
function parseQueue(obj) {
if (app.current.app !== 'Queue')
return;
if (typeof(obj.totalTime) != undefined && obj.totalTime > 0 && obj.totalEntities <= settings.maxElementsPerPage )
document.getElementById('panel-heading-queue').innerText = obj.totalEntities + ' ' + (obj.totalEntities > 1 ? 'Songs' : 'Song') + ' ' + beautifyDuration(obj.totalTime);
document.getElementById('QueueCurrentLength').innerText = obj.totalEntities + ' ' + (obj.totalEntities > 1 ? 'Songs' : 'Song') + ' ' + beautifyDuration(obj.totalTime);
else if (obj.totalEntities > 0)
document.getElementById('panel-heading-queue').innerText = obj.totalEntities + ' ' + (obj.totalEntities > 1 ? 'Songs' : 'Song');
document.getElementById('QueueCurrentLength').innerText = obj.totalEntities + ' ' + (obj.totalEntities > 1 ? 'Songs' : 'Song');
else
document.getElementById('panel-heading-queue').innerText = '';
document.getElementById('QueueCurrentLength').innerText = '';
var nrItems = obj.data.length;
var table = document.getElementById(app.current.app + 'List');
var table = document.getElementById('QueueCurrentList');
table.setAttribute('data-version', obj.queueVersion);
var tbody = table.getElementsByTagName('tbody')[0];
var tr = tbody.getElementsByTagName('tr');
for (var i = 0; i < nrItems; i++) {
//if (tr[i])
// if (tr[i].getAttribute('data-trackid') == obj.data[i].id && tr[i].getAttribute('data-songpos') == (obj.data[i].pos + 1))
// continue;
var minutes = Math.floor(obj.data[i].Duration / 60);
var seconds = obj.data[i].Duration - minutes * 60;
obj.data[i].Duration = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
@ -1486,8 +1488,8 @@ function parseQueue(obj) {
row.setAttribute('data-duration', obj.data[i].Duration);
row.setAttribute('data-uri', obj.data[i].uri);
var tds = '';
for (var c = 0; c < settings.colsQueue.length; c++) {
tds += '<td data-col="' + settings.colsQueue[c] + '">' + obj.data[i][settings.colsQueue[c]] + '</td>';
for (var c = 0; c < settings.colsQueueCurrent.length; c++) {
tds += '<td data-col="' + settings.colsQueueCurrent[c] + '">' + obj.data[i][settings.colsQueueCurrent[c]] + '</td>';
}
tds += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
row.innerHTML = tds;
@ -1501,7 +1503,7 @@ function parseQueue(obj) {
tr[i].remove();
}
var colspan = settings['cols' + app.current.app].length;
var colspan = settings['colsQueueCurrent'].length;
colspan--;
if (obj.type == 'queuesearch' && nrItems == 0)
@ -1512,17 +1514,13 @@ function parseQueue(obj) {
'<td colspan="' + colspan + '">Empty queue</td></tr>';
setPagination(obj.totalEntities);
document.getElementById('QueueList').classList.remove('opacity05');
document.getElementById('QueueCurrentList').classList.remove('opacity05');
}
function parseLastPlayed(obj) {
if (app.current.app !== 'LastPlayed')
return;
document.getElementById('panel-heading-last-played').innerText = obj.totalEntities + ' Songs';
document.getElementById('QueueLastPlayedLength').innerText = obj.totalEntities + ' Songs';
var nrItems = obj.data.length;
var table = document.getElementById(app.current.app + 'List');
var table = document.getElementById('QueueLastPlayedList');
table.setAttribute('data-version', obj.queueVersion);
var tbody = table.getElementsByTagName('tbody')[0];
var tr = tbody.getElementsByTagName('tr');
@ -1535,8 +1533,8 @@ function parseLastPlayed(obj) {
row.setAttribute('data-songpos', (obj.data[i].Pos + 1));
row.setAttribute('data-uri', obj.data[i].uri);
var tds = '';
for (var c = 0; c < settings.colsLastPlayed.length; c++) {
tds += '<td data-col="' + settings.colsLastPlayed[c] + '">' + obj.data[i][settings.colsLastPlayed[c]] + '</td>';
for (var c = 0; c < settings.colsQueueLastPlayed.length; c++) {
tds += '<td data-col="' + settings.colsQueueLastPlayed[c] + '">' + obj.data[i][settings.colsQueueLastPlayed[c]] + '</td>';
}
tds += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
row.innerHTML = tds;
@ -1550,7 +1548,7 @@ function parseLastPlayed(obj) {
tr[i].remove();
}
var colspan = settings['cols' + app.current.app].length;
var colspan = settings['colsQueueLastPlayed'].length;
colspan--;
if (nrItems == 0)
@ -1558,7 +1556,7 @@ function parseLastPlayed(obj) {
'<td colspan="' + colspan + '">Empty list</td></tr>';
setPagination(obj.totalEntities);
document.getElementById('LastPlayedList').classList.remove('opacity05');
document.getElementById('QueueLastPlayedList').classList.remove('opacity05');
}
function parseSearch(obj) {
@ -1577,8 +1575,6 @@ function parseSearch(obj) {
}
function parseFilesystem(obj) {
if (app.current.app !== 'Browse' && app.current.tab !== 'Filesystem' && app.current.app !== 'Search')
return;
var list = app.current.app + (app.current.tab == 'Filesystem' ? app.current.tab : '');
var colspan = settings['cols' + list].length;
colspan--;
@ -1647,12 +1643,10 @@ function parseFilesystem(obj) {
if (nrItems == 0)
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
'<td colspan="' + colspan + '">No results</td></tr>';
document.getElementById(app.current.app + (app.current.tab==undefined ? '' : app.current.tab) + 'List').classList.remove('opacity05');
document.getElementById(app.current.app + (app.current.tab == undefined ? '' : app.current.tab) + 'List').classList.remove('opacity05');
}
function parsePlaylists(obj) {
if (app.current.app !== 'Browse' && app.current.tab !== 'Playlists')
return;
if (app.current.view == 'All') {
document.getElementById('BrowsePlaylistsAllList').classList.remove('hide');
document.getElementById('BrowsePlaylistsDetailList').classList.add('hide');
@ -2461,7 +2455,7 @@ function showMenu(el, event) {
addMenuItem({"cmd": "showAddToPlaylist", "options": [uri]}, 'Add to playlist') +
(uri.indexOf('http') == -1 ? addMenuItem({"cmd": "songDetails", "options": [uri]}, 'Songdetails') : '');
}
else if (app.current.app == 'Queue') {
else if (app.current.app == 'Queue' && app.current.tab == 'Current') {
menu += addMenuItem({"cmd": "delQueueSong", "options": ["single", el.parentNode.parentNode.getAttribute('data-trackid')]}, 'Remove') +
addMenuItem({"cmd": "delQueueSong", "options": ["range", 0, el.parentNode.parentNode.getAttribute('data-songpos')]}, 'Remove all upwards') +
addMenuItem({"cmd": "delQueueSong", "options": ["range", (parseInt(el.parentNode.parentNode.getAttribute('data-songpos'))-1), -1]}, 'Remove all downwards') +

View File

@ -118,9 +118,9 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) {
int len = strlen(cols);
if (len > 1)
cols[len - 2] = '\0';
if (strcmp(p_charbuf1,"colsQueue")==0) {
free(mympd_state.colsQueue);
mympd_state.colsQueue = strdup(cols);
if (strcmp(p_charbuf1,"colsQueueCurrent")==0) {
free(mympd_state.colsQueueCurrent);
mympd_state.colsQueueCurrent = strdup(cols);
}
else if (strcmp(p_charbuf1,"colsSearch")==0) {
free(mympd_state.colsSearch);
@ -142,9 +142,9 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) {
free(mympd_state.colsPlayback);
mympd_state.colsPlayback = strdup(cols);
}
else if (strcmp(p_charbuf1,"colsLastPlayed")==0) {
free(mympd_state.colsLastPlayed);
mympd_state.colsLastPlayed = strdup(cols);
else if (strcmp(p_charbuf1,"colsQueueLastPlayed")==0) {
free(mympd_state.colsQueueLastPlayed);
mympd_state.colsQueueLastPlayed = strdup(cols);
}
mympd_state_set(p_charbuf1, cols);
free(p_charbuf1);
@ -1488,15 +1488,15 @@ int mympd_put_settings(char *buffer) {
}
len += json_printf(&out, "]");
}
len += json_printf(&out, ", colsQueue: %s, colsSearch: %s, colsBrowseDatabase: %s, colsBrowsePlaylistsDetail: %s, "
"colsBrowseFilesystem: %s, colsPlayback: %s, colsLastPlayed: %s}}",
mympd_state.colsQueue,
len += json_printf(&out, ", colsQueueCurrent: %s, colsSearch: %s, colsBrowseDatabase: %s, colsBrowsePlaylistsDetail: %s, "
"colsBrowseFilesystem: %s, colsPlayback: %s, colsQueueLastPlayed: %s}}",
mympd_state.colsQueueCurrent,
mympd_state.colsSearch,
mympd_state.colsBrowseDatabase,
mympd_state.colsBrowsePlaylistsDetail,
mympd_state.colsBrowseFilesystem,
mympd_state.colsPlayback,
mympd_state.colsLastPlayed
mympd_state.colsQueueLastPlayed
);
CHECK_RETURN_LEN();

View File

@ -219,13 +219,13 @@ typedef struct {
int jukeboxMode;
const char *jukeboxPlaylist;
int jukeboxQueueLength;
char *colsQueue;
char *colsQueueCurrent;
char *colsSearch;
char *colsBrowseDatabase;
char *colsBrowsePlaylistsDetail;
char *colsBrowseFilesystem;
char *colsPlayback;
char *colsLastPlayed;
char *colsQueueLastPlayed;
} t_mympd_state;
t_mympd_state mympd_state;

View File

@ -279,11 +279,11 @@ void read_statefiles() {
mympd_state_set("jukeboxQueueLength", "1");
}
if (mympd_state_get("colsQueue", value))
mympd_state.colsQueue = strdup(value);
if (mympd_state_get("colsQueueCurrent", value))
mympd_state.colsQueueCurrent = strdup(value);
else {
mympd_state.colsQueue = strdup("[\"Pos\",\"Title\",\"Artist\",\"Album\",\"Duration\"]");
mympd_state_set("colsQueue", mympd_state.colsQueue);
mympd_state.colsQueueCurrent = strdup("[\"Pos\",\"Title\",\"Artist\",\"Album\",\"Duration\"]");
mympd_state_set("colsQueueCurrent", mympd_state.colsQueueCurrent);
}
if (mympd_state_get("colsSearch", value))
@ -321,11 +321,11 @@ void read_statefiles() {
mympd_state_set("colsPlayback", mympd_state.colsPlayback);
}
if (mympd_state_get("colsLastPlayed", value))
mympd_state.colsLastPlayed = strdup(value);
if (mympd_state_get("colsQueueLastPlayed", value))
mympd_state.colsQueueLastPlayed = strdup(value);
else {
mympd_state.colsLastPlayed = strdup("[\"Pos\",\"Title\",\"Artist\",\"Album\",\"LastPlayed\"]");
mympd_state_set("colsLastPlayed", mympd_state.colsLastPlayed);
mympd_state.colsQueueLastPlayed = strdup("[\"Pos\",\"Title\",\"Artist\",\"Album\",\"LastPlayed\"]");
mympd_state_set("colsQueueLastPlayed", mympd_state.colsQueueLastPlayed);
}
}