mirror of
https://github.com/SuperBFG7/ympd
synced 2025-10-21 17:07:41 +00:00
Feat: Add playlist actions
This commit is contained in:
277
htdocs/js/mpd.js
277
htdocs/js/mpd.js
@@ -38,7 +38,12 @@ app.apps = { "Playback": { "state": "0/-/", "scrollPos": 0 },
|
||||
"Browse": {
|
||||
"active": "Database",
|
||||
"tabs": { "Filesystem": { "state": "0/-/", "scrollPos": 0 },
|
||||
"Playlists": { "state": "0/-/", "scrollPos": 0 },
|
||||
"Playlists": {
|
||||
"active": "All",
|
||||
"views": { "All": { "state": "0/-/", "scrollPos": 0 },
|
||||
"Detail": { "state": "0/-/", "scrollPos": 0 }
|
||||
}
|
||||
},
|
||||
"Database": {
|
||||
"active": "Artist",
|
||||
"views": { "Artist": { "state": "0/-/", "scrollPos": 0 },
|
||||
@@ -75,6 +80,8 @@ var modalSettings = new Modal(document.getElementById('modalSettings'));
|
||||
var modalAddstream = new Modal(document.getElementById('modalAddstream'));
|
||||
var modalSavequeue = new Modal(document.getElementById('modalSavequeue'));
|
||||
var modalSongDetails = new Modal(document.getElementById('modalSongDetails'));
|
||||
var modalAddToPlaylist = new Modal(document.getElementById('modalAddToPlaylist'));
|
||||
var modalRenamePlaylist = new Modal(document.getElementById('modalRenamePlaylist'));
|
||||
var mainMenu = new Dropdown(document.getElementById('mainMenu'));
|
||||
|
||||
function appPrepare(scrollPos) {
|
||||
@@ -102,6 +109,11 @@ function appPrepare(scrollPos) {
|
||||
}
|
||||
scrollTo(scrollPos);
|
||||
}
|
||||
var list = document.getElementById(app.current.app +
|
||||
(app.current.tab == undefined ? '' : app.current.tab) +
|
||||
(app.current.view == undefined ? '' : app.current.view) + 'List');
|
||||
if (list)
|
||||
list.classList.add('opacity05');
|
||||
}
|
||||
|
||||
function appGoto(a,t,v,s) {
|
||||
@@ -171,13 +183,6 @@ function appRoute() {
|
||||
sendAPI({"cmd":"MPD_API_GET_CURRENT_SONG"}, songChange);
|
||||
}
|
||||
else if (app.current.app == 'Queue' ) {
|
||||
document.getElementById('QueueList').classList.add('opacity05');
|
||||
/* if (app.last.app != app.current.app) {
|
||||
if (app.current.search.length < 2) {
|
||||
setPagination(app.current.page);
|
||||
}
|
||||
}
|
||||
*/
|
||||
var btns = document.getElementById('searchqueuetag').getElementsByTagName('button');
|
||||
for (var i = 0; i < btns.length; i++) {
|
||||
btns[i].classList.remove('active');
|
||||
@@ -188,23 +193,23 @@ function appRoute() {
|
||||
}
|
||||
getQueue();
|
||||
}
|
||||
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists') {
|
||||
document.getElementById('BrowsePlaylistsList').classList.add('opacity05');
|
||||
sendAPI({"cmd":"MPD_API_GET_PLAYLISTS","data": {"offset": app.current.page, "filter": app.current.filter}},parsePlaylists);
|
||||
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'All') {
|
||||
sendAPI({"cmd":"MPD_API_GET_PLAYLISTS","data": {"offset": app.current.page, "filter": app.current.filter}}, parsePlaylists);
|
||||
doSetFilterLetter('BrowsePlaylistsFilter');
|
||||
}
|
||||
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail') {
|
||||
sendAPI({"cmd":"MPD_API_GET_PLAYLIST_LIST","data": {"offset": app.current.page, "filter": app.current.filter, "uri": app.current.search}}, parsePlaylists);
|
||||
doSetFilterLetter('BrowsePlaylistsFilter');
|
||||
}
|
||||
else if (app.current.app == 'Browse' && app.current.tab == 'Database' && app.current.view == 'Artist') {
|
||||
document.getElementById('BrowseDatabaseArtistList').classList.add('opacity05');
|
||||
sendAPI({"cmd":"MPD_API_GET_ARTISTS","data": {"offset": app.current.page, "filter": app.current.filter}}, parseListDBtags);
|
||||
doSetFilterLetter('BrowseDatabaseFilter');
|
||||
}
|
||||
else if (app.current.app == 'Browse' && app.current.tab == 'Database' && app.current.view == 'Album') {
|
||||
document.getElementById('BrowseDatabaseAlbumCards').classList.add('opacity05');
|
||||
sendAPI({"cmd":"MPD_API_GET_ARTISTALBUMS","data": {"offset": app.current.page, "filter": app.current.filter, "albumartist": app.current.search}}, parseListDBtags);
|
||||
doSetFilterLetter('BrowseDatabaseFilter');
|
||||
}
|
||||
else if (app.current.app == 'Browse' && app.current.tab == 'Filesystem') {
|
||||
document.getElementById('BrowseFilesystemList').classList.add('opacity05');
|
||||
sendAPI({"cmd":"MPD_API_GET_FILESYSTEM","data": {"offset": app.current.page, "path": (app.current.search ? app.current.search : "/"), "filter": app.current.filter}}, parseFilesystem);
|
||||
// Don't add all songs from root
|
||||
if (app.current.search)
|
||||
@@ -238,15 +243,11 @@ function appRoute() {
|
||||
}
|
||||
else if (app.current.app == 'Search') {
|
||||
document.getElementById('searchstr').focus();
|
||||
document.getElementById('SearchList').classList.add('opacity05');
|
||||
if (app.last.app != app.current.app) {
|
||||
if (app.current.search != '')
|
||||
document.getElementById('SearchList').getElementsByTagName('tbody')[0].innerHTML=
|
||||
'<tr><td><span class="material-icons">search</span></td>' +
|
||||
'<td colspan="5">Searching...</td></tr>';
|
||||
// else
|
||||
// setPagination(app.current.page);
|
||||
// document.getElementById('searchstr').value = app.current.search;
|
||||
}
|
||||
|
||||
if (app.current.search.length >= 2) {
|
||||
@@ -255,7 +256,6 @@ function appRoute() {
|
||||
document.getElementById('SearchList').getElementsByTagName('tbody')[0].innerHTML = '';
|
||||
document.getElementById('searchAddAllSongs').setAttribute('disabled', 'disabled');
|
||||
document.getElementById('panel-heading-search').innerText = '';
|
||||
// setPagination(app.current.page);
|
||||
document.getElementById('SearchList').classList.remove('opacity05');
|
||||
}
|
||||
|
||||
@@ -313,10 +313,6 @@ function appInit() {
|
||||
document.getElementById('streamurl').focus();
|
||||
});
|
||||
|
||||
document.getElementById('addstreamFrm').addEventListener('submit', function () {
|
||||
addStream();
|
||||
});
|
||||
|
||||
addFilterLetter('BrowseFilesystemFilterLetters');
|
||||
addFilterLetter('BrowseDatabaseFilterLetters');
|
||||
addFilterLetter('BrowsePlaylistsFilterLetters');
|
||||
@@ -386,7 +382,7 @@ function appInit() {
|
||||
}
|
||||
}, false);
|
||||
|
||||
document.getElementById('BrowsePlaylistsList').addEventListener('click', function(event) {
|
||||
document.getElementById('BrowsePlaylistsAllList').addEventListener('click', function(event) {
|
||||
if (event.target.nodeName == 'TD') {
|
||||
appendQueue('plist', decodeURI(event.target.parentNode.getAttribute("data-uri")), event.target.parentNode.getAttribute("data-name"));
|
||||
}
|
||||
@@ -395,6 +391,16 @@ function appInit() {
|
||||
showMenu(event.target);
|
||||
}
|
||||
}, false);
|
||||
|
||||
document.getElementById('BrowsePlaylistsDetailList').addEventListener('click', function(event) {
|
||||
if (event.target.nodeName == 'TD') {
|
||||
appendQueue('plist', decodeURI(event.target.parentNode.getAttribute("data-uri")), event.target.parentNode.getAttribute("data-name"));
|
||||
}
|
||||
else if (event.target.nodeName == 'A') {
|
||||
event.preventDefault();
|
||||
showMenu(event.target);
|
||||
}
|
||||
}, false);
|
||||
|
||||
document.getElementById('BrowseDatabaseArtistList').addEventListener('click', function(event) {
|
||||
if (event.target.nodeName == 'TD') {
|
||||
@@ -877,23 +883,23 @@ function parseFilesystem(obj) {
|
||||
switch(obj.data[i].type) {
|
||||
case 'dir':
|
||||
row.innerHTML = '<td><span class="material-icons">folder_open</span></td>' +
|
||||
'<td colspan="4">' + obj.data[i].name + '</td>' +
|
||||
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||
'<td colspan="4">' + obj.data[i].name + '</td>' +
|
||||
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||
break;
|
||||
case 'song':
|
||||
var minutes = Math.floor(obj.data[i].duration / 60);
|
||||
var seconds = obj.data[i].duration - minutes * 60;
|
||||
row.innerHTML = '<td><span class="material-icons">music_note</span></td>' +
|
||||
'<td>' + obj.data[i].title + '</td>' +
|
||||
'<td>' + obj.data[i].artist + '</td>' +
|
||||
'<td>' + obj.data[i].album + '</td>' +
|
||||
'<td>' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
|
||||
'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||
'<td>' + obj.data[i].title + '</td>' +
|
||||
'<td>' + obj.data[i].artist + '</td>' +
|
||||
'<td>' + obj.data[i].album + '</td>' +
|
||||
'<td>' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
|
||||
'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||
break;
|
||||
case 'plist':
|
||||
row.innerHTML = '<td><span class="material-icons">list</span></td>' +
|
||||
'<td colspan="4">' + obj.data[i].name + '</td>' +
|
||||
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||
'<td colspan="4">' + obj.data[i].name + '</td>' +
|
||||
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||
break;
|
||||
}
|
||||
if (i < tr.length)
|
||||
@@ -917,28 +923,76 @@ function parseFilesystem(obj) {
|
||||
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');
|
||||
document.getElementById('btnBrowsePlaylistsAll').parentNode.classList.add('hide');
|
||||
document.getElementById('btnPlaylistClear').parentNode.classList.add('hide');
|
||||
} else {
|
||||
if (obj.uri.indexOf('.') > -1) {
|
||||
document.getElementById('BrowsePlaylistsDetailList').setAttribute('data-ro', 'true')
|
||||
document.getElementById('btnPlaylistClear').parentNode.classList.add('hide');
|
||||
}
|
||||
else {
|
||||
document.getElementById('BrowsePlaylistsDetailList').setAttribute('data-ro', 'false');
|
||||
document.getElementById('btnPlaylistClear').parentNode.classList.remove('hide');
|
||||
}
|
||||
document.getElementById('BrowsePlaylistsDetailList').setAttribute('data-uri', obj.uri);
|
||||
document.getElementById('BrowsePlaylistsDetailList').getElementsByTagName('caption')[0].innerText = 'Playlist: ' + obj.uri;
|
||||
document.getElementById('BrowsePlaylistsDetailList').classList.remove('hide');
|
||||
document.getElementById('BrowsePlaylistsAllList').classList.add('hide');
|
||||
document.getElementById('btnBrowsePlaylistsAll').parentNode.classList.remove('hide');
|
||||
}
|
||||
|
||||
var nrItems = obj.data.length;
|
||||
var tbody = document.getElementById(app.current.app + app.current.tab + 'List').getElementsByTagName('tbody')[0];
|
||||
var tbody = document.getElementById(app.current.app + app.current.tab + app.current.view + 'List').getElementsByTagName('tbody')[0];
|
||||
var tr = tbody.getElementsByTagName('tr');
|
||||
for (var i = 0; i < nrItems; i++) {
|
||||
var uri = encodeURI(obj.data[i].uri);
|
||||
if (tr[i])
|
||||
if (tr[i].getAttribute('data-uri') == uri)
|
||||
continue;
|
||||
var d = new Date(obj.data[i].last_modified * 1000);
|
||||
var row = document.createElement('tr');
|
||||
row.setAttribute('data-uri', uri);
|
||||
row.setAttribute('data-type', 'plist');
|
||||
row.setAttribute('data-name', obj.data[i].name);
|
||||
row.innerHTML = '<td><span class="material-icons">list</span></td>' +
|
||||
'<td>' + obj.data[i].name + '</td>' +
|
||||
'<td>'+ d.toUTCString() + '</td>' +
|
||||
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||
if (i < tr.length)
|
||||
tr[i].replaceWith(row);
|
||||
else
|
||||
tbody.append(row);
|
||||
if (app.current.view == 'All') {
|
||||
for (var i = 0; i < nrItems; i++) {
|
||||
var uri = encodeURI(obj.data[i].uri);
|
||||
if (tr[i])
|
||||
if (tr[i].getAttribute('data-uri') == uri)
|
||||
continue;
|
||||
var d = new Date(obj.data[i].last_modified * 1000);
|
||||
var row = document.createElement('tr');
|
||||
row.setAttribute('data-uri', uri);
|
||||
row.setAttribute('data-type', 'plist');
|
||||
row.setAttribute('data-name', obj.data[i].name);
|
||||
row.innerHTML = '<td><span class="material-icons">list</span></td>' +
|
||||
'<td>' + obj.data[i].name + '</td>' +
|
||||
'<td>'+ d.toUTCString() + '</td>' +
|
||||
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||
if (i < tr.length)
|
||||
tr[i].replaceWith(row);
|
||||
else
|
||||
tbody.append(row);
|
||||
}
|
||||
}
|
||||
else if (app.current.view == 'Detail') {
|
||||
for (var i = 0; i < nrItems; i++) {
|
||||
var uri = encodeURI(obj.data[i].uri);
|
||||
if (tr[i])
|
||||
if (tr[i].getAttribute('data-uri') == uri)
|
||||
continue;
|
||||
var songpos = obj.offset + i;
|
||||
var row = document.createElement('tr');
|
||||
row.setAttribute('data-type', obj.data[i].type);
|
||||
row.setAttribute('data-uri', uri);
|
||||
row.setAttribute('data-name', obj.data[i].name);
|
||||
row.setAttribute('data-songpos', songpos);
|
||||
var minutes = Math.floor(obj.data[i].duration / 60);
|
||||
var seconds = obj.data[i].duration - minutes * 60;
|
||||
row.innerHTML = '<td>' + (songpos + 1) + '</td>' +
|
||||
'<td>' + obj.data[i].title + '</td>' +
|
||||
'<td>' + obj.data[i].artist + '</td>' +
|
||||
'<td>' + obj.data[i].album + '</td>' +
|
||||
'<td>' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
|
||||
'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||
if (i < tr.length)
|
||||
tr[i].replaceWith(row);
|
||||
else
|
||||
tbody.append(row);
|
||||
}
|
||||
}
|
||||
var tr_length=tr.length - 1;
|
||||
for (var i = tr_length; i >= nrItems; i --) {
|
||||
@@ -947,10 +1001,15 @@ function parsePlaylists(obj) {
|
||||
|
||||
setPagination(obj.totalEntities);
|
||||
|
||||
if (nrItems == 0)
|
||||
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
||||
'<td colspan="5">No playlists found.</td></tr>'
|
||||
document.getElementById(app.current.app + (app.current.tab==undefined ? '' : app.current.tab) + 'List').classList.remove('opacity05');
|
||||
if (nrItems == 0)
|
||||
if (app.current.view == 'All')
|
||||
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
||||
'<td colspan="5">No playlists found.</td></tr>';
|
||||
else
|
||||
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
||||
'<td colspan="5">Empty playlist.</td></tr>';
|
||||
|
||||
document.getElementById(app.current.app + app.current.tab + app.current.view + 'List').classList.remove('opacity05');
|
||||
}
|
||||
|
||||
function parseListDBtags(obj) {
|
||||
@@ -959,7 +1018,7 @@ function parseListDBtags(obj) {
|
||||
if (obj.tagtype == 'AlbumArtist') {
|
||||
document.getElementById('BrowseDatabaseAlbumCards').classList.add('hide');
|
||||
document.getElementById('BrowseDatabaseArtistList').classList.remove('hide');
|
||||
document.getElementById('btnBrowseDatabaseArtist').classList.add('hide');
|
||||
document.getElementById('btnBrowseDatabaseArtist').parentNode.classList.add('hide');
|
||||
var nrItems = obj.data.length;
|
||||
var tbody = document.getElementById(app.current.app + app.current.tab + app.current.view + 'List').getElementsByTagName('tbody')[0];
|
||||
var tr = tbody.getElementsByTagName('tr');
|
||||
@@ -994,7 +1053,7 @@ function parseListDBtags(obj) {
|
||||
} else if (obj.tagtype == 'Album') {
|
||||
document.getElementById('BrowseDatabaseAlbumCards').classList.remove('hide');
|
||||
document.getElementById('BrowseDatabaseArtistList').classList.add('hide');
|
||||
document.getElementById('btnBrowseDatabaseArtist').classList.remove('hide');
|
||||
document.getElementById('btnBrowseDatabaseArtist').parentNode.classList.remove('hide');
|
||||
var nrItems = obj.data.length;
|
||||
var cardContainer = document.getElementById('BrowseDatabaseAlbumCards');
|
||||
var cards = cardContainer.querySelectorAll('.col-md');
|
||||
@@ -1178,6 +1237,74 @@ function parseSongDetails(obj) {
|
||||
}
|
||||
}
|
||||
|
||||
function playlistDetails(uri) {
|
||||
appGoto('Browse', 'Playlists', 'Detail', '0/-/' + uri);
|
||||
}
|
||||
|
||||
function removeFromPlaylist(uri, pos) {
|
||||
sendAPI({"cmd": "MPD_API_RM_PLAYLIST_TRACK", "data": {"uri": uri, "track": pos}});
|
||||
document.getElementById('BrowsePlaylistsDetailList').classList.add('opacity05');
|
||||
sendAPI({"cmd": "MPD_API_GET_PLAYLIST_LIST", "data": {"offset": app.current.page, "filter": app.current.filter, "uri": app.current.search}}, parsePlaylists);
|
||||
}
|
||||
|
||||
function playlistClear() {
|
||||
var uri = document.getElementById('BrowsePlaylistsDetailList').getAttribute('data-uri');
|
||||
sendAPI({"cmd": "MPD_API_PLAYLIST_CLEAR", "data": {"uri": uri}});
|
||||
document.getElementById('BrowsePlaylistsDetailList').classList.add('opacity05');
|
||||
sendAPI({"cmd": "MPD_API_GET_PLAYLIST_LIST", "data": {"offset": app.current.page, "filter": app.current.filter, "uri": app.current.search}}, parsePlaylists);
|
||||
}
|
||||
|
||||
function getAllPlaylists(obj) {
|
||||
var nrItems = obj.data.length;
|
||||
var playlists = '';
|
||||
for (var i = 0; i < nrItems; i++) {
|
||||
playlists += '<option>' + obj.data[i].uri + '</option>';
|
||||
}
|
||||
document.getElementById('addToPlaylistPlaylist').innerHTML += playlists;
|
||||
if (obj.totalEntities > obj.returnedEntities) {
|
||||
obj.offset += settings.max_elements_per_page;
|
||||
sendAPI({"cmd":"MPD_API_GET_PLAYLISTS","data": {"offset": obj.offset, "filter": "-"}}, getAllPlaylists);
|
||||
}
|
||||
}
|
||||
|
||||
function showAddToPlaylist(uri) {
|
||||
modalAddToPlaylist.show();
|
||||
document.getElementById('addToPlaylistUri').value = uri;
|
||||
document.getElementById('addToPlaylistPlaylist').innerHTML = '';
|
||||
sendAPI({"cmd":"MPD_API_GET_PLAYLISTS","data": {"offset": 0, "filter": "-"}}, getAllPlaylists);
|
||||
}
|
||||
|
||||
function addToPlaylist() {
|
||||
var uri = document.getElementById('addToPlaylistUri').value;
|
||||
var plistEl = document.getElementById('addToPlaylistPlaylist');
|
||||
var plist = plistEl.options[plistEl.selectedIndex].text;
|
||||
sendAPI({"cmd": "MPD_API_ADD_TO_PLAYLIST", "data": {"uri": uri, "plist": plist}});
|
||||
modalAddToPlaylist.hide();
|
||||
}
|
||||
|
||||
function showRenamePlaylist(from) {
|
||||
document.getElementById('renamePlaylistFrm').classList.remove('was-validated');
|
||||
document.getElementById('renamePlaylistTo').classList.remove('is-invalid');
|
||||
modalRenamePlaylist.show();
|
||||
document.getElementById('renamePlaylistFrom').value = from;
|
||||
document.getElementById('renamePlaylistTo').value = '';
|
||||
}
|
||||
|
||||
function renamePlaylist() {
|
||||
var from = document.getElementById('renamePlaylistFrom').value;
|
||||
var to = document.getElementById('renamePlaylistTo').value;
|
||||
var valid = to.replace(/\w/g,'');
|
||||
if (to != '' && to != from && valid == '') {
|
||||
sendAPI({"cmd": "MPD_API_PLAYLIST_RENAME", "data": {"from": from, "to": to}});
|
||||
modalRenamePlaylist.hide();
|
||||
sendAPI({"cmd":"MPD_API_GET_PLAYLISTS","data": {"offset": app.current.page, "filter": app.current.filter}}, parsePlaylists);
|
||||
}
|
||||
else {
|
||||
document.getElementById('renamePlaylistTo').classList.add('is-invalid');
|
||||
document.getElementById('renamePlaylistFrm').classList.add('was-validated');
|
||||
}
|
||||
}
|
||||
|
||||
function showMenu(el) {
|
||||
var type = el.getAttribute('data-type');
|
||||
var uri = decodeURI(el.getAttribute('data-uri'));
|
||||
@@ -1201,22 +1328,32 @@ function showMenu(el) {
|
||||
uri + '\',' + nextsongpos + ',\'' + name + '\']}">Add after current playing song</a>' : '') +
|
||||
'<a class="dropdown-item" href="#" data-href="{\'cmd\': \'replaceQueue\', \'options\': [\'' + type + '\',\'' +
|
||||
uri + '\',\'' + name + '\']}">Replace queue</a>' +
|
||||
// ( type != 'plist' ? '<div class="dropdown-divider"></div><a class="dropdown-item" href="#">Add to playlist</a>' : '') +
|
||||
( type != 'plist' ? '<div class="dropdown-divider"></div><a class="dropdown-item" href="#" data-href="{\'cmd\': \'showAddToPlaylist\', \'options\': [\'' + uri + '\']}">Add to playlist</a>' : '') +
|
||||
( type != 'dir' ? '<div class="dropdown-divider"></div>' : '') +
|
||||
( type == 'song' ? '<a class="dropdown-item" data-href="{\'cmd\': \'songDetails\', \'options\': [\'' + uri + '\']}" href="#">Songdetails</a>' : '');
|
||||
// ( type == 'plist' ? '<a class="dropdown-item" href="#">Show playlist</a>' : '');
|
||||
( type == 'song' ? '<a class="dropdown-item" data-href="{\'cmd\': \'songDetails\', \'options\': [\'' + uri + '\']}" href="#">Songdetails</a>' : '') +
|
||||
( type == 'plist' ? '<a class="dropdown-item" href="#" data-href="{\'cmd\': \'playlistDetails\', \'options\': [\'' + uri + '\']}">Show playlist</a>' : '');
|
||||
}
|
||||
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists') {
|
||||
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'All') {
|
||||
menu += '<a class="dropdown-item" href="#" data-href="{\'cmd\': \'appendQueue\', \'options\': [\'' + type + '\',\'' +
|
||||
uri + '\',\'' + name + '\']}">Append to queue</a>' +
|
||||
'<a class="dropdown-item" href="#" data-href="{\'cmd\': \'replaceQueue\', \'options\': [\'' + type + '\',\'' +
|
||||
uri + '\',\'' + name + '\']}">Replace queue</a>' +
|
||||
'<div class="dropdown-divider"></div>' +
|
||||
// '<a class="dropdown-item" href="#">Show playlist</a>' +
|
||||
// '<a class="dropdown-item" href="#">Rename playlist</a>' +
|
||||
'<a class="dropdown-item" href="#" data-href="{\'cmd\': \'playlistDetails\', \'options\': [\'' + uri + '\']}">Edit playlist</a>' +
|
||||
'<a class="dropdown-item" href="#" data-href="{\'cmd\': \'showRenamePlaylist\', \'options\': [\'' + uri + '\']}">Rename playlist</a>' +
|
||||
'<a class="dropdown-item" href="#" data-href="{\'cmd\': \'delPlaylist\', \'options\': [\'' +
|
||||
uri + '\',\'' + name + '\']}">Delete playlist</a>';
|
||||
}
|
||||
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail') {
|
||||
menu += '<a class="dropdown-item" href="#" data-href="{\'cmd\': \'appendQueue\', \'options\': [\'' + type + '\',\'' +
|
||||
uri + '\',\'' + name + '\']}">Append to queue</a>' +
|
||||
'<a class="dropdown-item" href="#" data-href="{\'cmd\': \'replaceQueue\', \'options\': [\'' + type + '\',\'' +
|
||||
uri + '\',\'' + name + '\']}">Replace queue</a>' +
|
||||
( document.getElementById('BrowsePlaylistsDetailList').getAttribute('data-ro') == 'false' ?
|
||||
'<div class="dropdown-divider"></div>' +
|
||||
'<a class="dropdown-item" href="#" data-href="{\'cmd\': \'removeFromPlaylist\', \'options\': [\'' + document.getElementById('BrowsePlaylistsDetailList').getAttribute('data-uri') + '\', \'' +
|
||||
el.parentNode.parentNode.getAttribute('data-songpos') + '\']}">Remove</a>' : '');
|
||||
}
|
||||
else if (app.current.app == 'Queue') {
|
||||
menu += '<a class="dropdown-item" href="#" data-href="{\'cmd\': \'delQueueSong\', \'options\': [\'single\',' +
|
||||
el.parentNode.parentNode.getAttribute('data-trackid') + ']}">Remove</a>' +
|
||||
@@ -1262,7 +1399,7 @@ function sendAPI(request, callback) {
|
||||
if (ajaxRequest.responseText != '') {
|
||||
var obj = JSON.parse(ajaxRequest.responseText);
|
||||
if (obj.type == 'error') {
|
||||
showNotification('Error', obj.data, obj.data, 'error');
|
||||
showNotification('Error', obj.data, obj.data, 'danger');
|
||||
console.log('Error: ' + obj.data);
|
||||
}
|
||||
else if (obj.type == 'result' && obj.data != 'ok')
|
||||
@@ -1284,7 +1421,7 @@ function openLocalPlayer() {
|
||||
|
||||
function updateDB() {
|
||||
sendAPI({"cmd": "MPD_API_UPDATE_DB"});
|
||||
// showNotification('Updating MPD Database...', '', '', 'success');
|
||||
showNotification('Updating MPD Database...', '', '', 'success');
|
||||
}
|
||||
|
||||
function clickPlay() {
|
||||
@@ -1439,7 +1576,7 @@ function showNotification(notificationTitle,notificationText,notificationHtml,no
|
||||
else {
|
||||
alertBox = document.getElementById('alertBox');
|
||||
}
|
||||
alertBox.classList.remove('alert-success', 'alert-error');
|
||||
alertBox.classList.remove('alert-success', 'alert-danger');
|
||||
alertBox.classList.add('alert','alert-' + notificationType);
|
||||
alertBox.innerHTML = '<div><strong>' + notificationTitle + '</strong><br/>' + notificationHtml + '</div>';
|
||||
document.getElementsByTagName('main')[0].append(alertBox);
|
||||
@@ -1466,7 +1603,7 @@ function notificationsSupported() {
|
||||
}
|
||||
|
||||
function songChange(obj) {
|
||||
if (obj.type == 'error')
|
||||
if (obj.type == 'error' || obj.type == 'result')
|
||||
return;
|
||||
var cur_song = obj.data.title + obj.data.artist + obj.data.album + obj.data.uri + obj.data.currentsongid;
|
||||
if (last_song == cur_song)
|
||||
@@ -1479,7 +1616,7 @@ function songChange(obj) {
|
||||
|
||||
if(typeof obj.data.artist != 'undefined' && obj.data.artist.length > 0 && obj.data.artist != '-') {
|
||||
textNotification += obj.data.artist;
|
||||
htmlNotification += '<br/>' + obj.data.artist;
|
||||
htmlNotification += obj.data.artist;
|
||||
pageTitle += obj.data.artist + ' - ';
|
||||
document.getElementById('artist').innerText = obj.data.artist;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user