2018-07-19 18:26:15 +00:00
|
|
|
|
"use strict";
|
2018-05-14 23:13:43 +00:00
|
|
|
|
/* myMPD
|
|
|
|
|
(c) 2018 Juergen Mang <mail@jcgames.de>
|
2018-06-21 21:29:49 +00:00
|
|
|
|
This project's homepage is: https://github.com/jcorporation/mympd
|
2018-05-14 23:13:43 +00:00
|
|
|
|
|
|
|
|
|
myMPD ist fork of:
|
|
|
|
|
|
|
|
|
|
ympd
|
2014-02-22 00:57:26 +00:00
|
|
|
|
(c) 2013-2014 Andrew Karpow <andy@ndyk.de>
|
2016-09-11 15:54:25 +00:00
|
|
|
|
This project's homepage is: https://www.ympd.org
|
2014-02-22 00:57:26 +00:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2014-01-17 18:41:41 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2013-11-04 17:18:38 +00:00
|
|
|
|
var socket;
|
2018-08-14 14:10:00 +00:00
|
|
|
|
var lastSong = '';
|
2018-11-05 19:57:06 +00:00
|
|
|
|
var lastSongObj = {};
|
2018-08-14 14:10:00 +00:00
|
|
|
|
var lastState;
|
|
|
|
|
var currentSong = new Object();
|
2018-06-03 08:52:38 +00:00
|
|
|
|
var playstate = '';
|
2018-06-21 16:57:40 +00:00
|
|
|
|
var settings = {};
|
2018-07-05 19:34:16 +00:00
|
|
|
|
var alertTimeout;
|
2018-08-14 14:10:00 +00:00
|
|
|
|
var progressTimer;
|
2018-09-20 16:59:29 +00:00
|
|
|
|
var deferredPrompt;
|
2018-07-22 23:07:25 +00:00
|
|
|
|
var dragEl;
|
2018-09-20 16:59:29 +00:00
|
|
|
|
var playlistEl;
|
2013-11-04 17:18:38 +00:00
|
|
|
|
|
2018-06-07 18:47:40 +00:00
|
|
|
|
var app = {};
|
2018-11-12 23:48:29 +00:00
|
|
|
|
app.apps = { "Playback": { "state": "0/-/", "scrollPos": 0 },
|
2018-11-14 23:14:47 +00:00
|
|
|
|
"Queue": {
|
|
|
|
|
"active": "Current",
|
|
|
|
|
"tabs": { "Current": { "state": "0/any/", "scrollPos": 0 },
|
|
|
|
|
"LastPlayed": { "state": "0/any/", "scrollPos": 0 }
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-11-12 23:48:29 +00:00
|
|
|
|
"Browse": {
|
2018-06-10 21:21:48 +00:00
|
|
|
|
"active": "Database",
|
2018-07-09 15:36:45 +00:00
|
|
|
|
"tabs": { "Filesystem": { "state": "0/-/", "scrollPos": 0 },
|
2018-07-22 19:00:26 +00:00
|
|
|
|
"Playlists": {
|
|
|
|
|
"active": "All",
|
|
|
|
|
"views": { "All": { "state": "0/-/", "scrollPos": 0 },
|
|
|
|
|
"Detail": { "state": "0/-/", "scrollPos": 0 }
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-06-10 21:21:48 +00:00
|
|
|
|
"Database": {
|
2018-09-10 20:32:15 +00:00
|
|
|
|
"active": "AlbumArtist",
|
2018-10-10 21:40:04 +00:00
|
|
|
|
"views": {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-09-03 18:02:12 +00:00
|
|
|
|
"Search": { "state": "0/any/", "scrollPos": 0 }
|
2018-06-07 18:47:40 +00:00
|
|
|
|
};
|
2018-10-10 21:40:04 +00:00
|
|
|
|
|
2018-07-09 15:36:45 +00:00
|
|
|
|
app.current = { "app": "Playback", "tab": undefined, "view": undefined, "page": 0, "filter": "", "search": "", "scrollPos": 0 };
|
|
|
|
|
app.last = { "app": undefined, "tab": undefined, "view": undefined, "filter": "", "search": "", "scrollPos": 0 };
|
2018-06-07 18:47:40 +00:00
|
|
|
|
|
2018-06-27 23:19:09 +00:00
|
|
|
|
var domCache = {};
|
|
|
|
|
domCache.navbarBottomBtns = document.getElementById('navbar-bottom').getElementsByTagName('div');
|
|
|
|
|
domCache.navbarBottomBtnsLen = domCache.navbarBottomBtns.length;
|
2018-11-14 23:14:47 +00:00
|
|
|
|
domCache.cardHeaderBrowse = document.getElementById('cardHeaderBrowse').getElementsByTagName('a');
|
|
|
|
|
domCache.cardHeaderBrowseLen = domCache.cardHeaderBrowse.length;
|
|
|
|
|
domCache.cardHeaderQueue = document.getElementById('cardHeaderQueue').getElementsByTagName('a');
|
|
|
|
|
domCache.cardHeaderQueueLen = domCache.cardHeaderQueue.length;
|
2018-06-27 23:19:09 +00:00
|
|
|
|
domCache.counter = document.getElementById('counter');
|
2018-06-28 22:51:24 +00:00
|
|
|
|
domCache.volumePrct = document.getElementById('volumePrct');
|
|
|
|
|
domCache.volumeControl = document.getElementById('volumeControl');
|
2018-11-06 23:59:44 +00:00
|
|
|
|
domCache.volumeMenu = document.getElementById('volumeMenu');
|
2018-08-21 22:02:22 +00:00
|
|
|
|
domCache.btnsPlay = document.getElementsByClassName('btnPlay');
|
|
|
|
|
domCache.btnsPlayLen = domCache.btnsPlay.length;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
domCache.btnPrev = document.getElementById('btnPrev');
|
|
|
|
|
domCache.btnNext = document.getElementById('btnNext');
|
|
|
|
|
domCache.progressBar = document.getElementById('progressBar');
|
|
|
|
|
domCache.volumeBar = document.getElementById('volumeBar');
|
2018-06-29 06:52:32 +00:00
|
|
|
|
domCache.outputs = document.getElementById('outputs');
|
2018-08-01 21:54:53 +00:00
|
|
|
|
domCache.btnAdd = document.getElementById('nav-add2homescreen');
|
2018-08-21 22:02:22 +00:00
|
|
|
|
domCache.currentCover = document.getElementById('currentCover');
|
2018-11-04 23:26:59 +00:00
|
|
|
|
domCache.currentTitle = document.getElementById('currentTitle');
|
2018-08-21 22:02:22 +00:00
|
|
|
|
domCache.btnVoteUp = document.getElementById('btnVoteUp');
|
|
|
|
|
domCache.btnVoteDown = document.getElementById('btnVoteDown');
|
2018-11-11 22:22:48 +00:00
|
|
|
|
domCache.badgeQueueItems = document.getElementById('badgeQueueItems');
|
2018-11-27 19:45:35 +00:00
|
|
|
|
domCache.searchstr = document.getElementById('searchstr');
|
|
|
|
|
domCache.searchCrumb = document.getElementById('searchCrumb');
|
2018-06-27 23:19:09 +00:00
|
|
|
|
|
2018-09-18 23:10:53 +00:00
|
|
|
|
var modalConnectionError = new Modal(document.getElementById('modalConnectionError'), { backdrop: 'static', keyboard: false});
|
2018-07-02 22:02:02 +00:00
|
|
|
|
var modalSettings = new Modal(document.getElementById('modalSettings'));
|
2018-11-05 23:13:22 +00:00
|
|
|
|
var modalAbout = new Modal(document.getElementById('modalAbout'));
|
2018-07-22 19:42:01 +00:00
|
|
|
|
var modalSavequeue = new Modal(document.getElementById('modalSaveQueue'));
|
2018-07-09 17:28:28 +00:00
|
|
|
|
var modalSongDetails = new Modal(document.getElementById('modalSongDetails'));
|
2018-07-22 19:00:26 +00:00
|
|
|
|
var modalAddToPlaylist = new Modal(document.getElementById('modalAddToPlaylist'));
|
|
|
|
|
var modalRenamePlaylist = new Modal(document.getElementById('modalRenamePlaylist'));
|
2018-08-24 10:11:27 +00:00
|
|
|
|
var modalUpdateDB = new Modal(document.getElementById('modalUpdateDB'));
|
2018-09-29 18:41:58 +00:00
|
|
|
|
var modalSaveSmartPlaylist = new Modal(document.getElementById('modalSaveSmartPlaylist'));
|
2018-10-14 21:08:10 +00:00
|
|
|
|
var modalDeletePlaylist = new Modal(document.getElementById('modalDeletePlaylist'));
|
2018-11-08 22:42:45 +00:00
|
|
|
|
var modalHelp = new Modal(document.getElementById('modalHelp'));
|
2018-07-02 22:02:02 +00:00
|
|
|
|
|
2018-11-12 23:48:29 +00:00
|
|
|
|
var dropdownMainMenu;
|
2018-11-06 23:59:44 +00:00
|
|
|
|
var dropdownVolumeMenu = new Dropdown(document.getElementById('volumeMenu'));
|
|
|
|
|
|
|
|
|
|
var collapseDBupdate = new Collapse(document.getElementById('navDBupdate'));
|
|
|
|
|
|
2018-07-09 15:36:45 +00:00
|
|
|
|
function appPrepare(scrollPos) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
if (app.current.app != app.last.app || app.current.tab != app.last.tab || app.current.view != app.last.view) {
|
|
|
|
|
//Hide all cards + nav
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < domCache.navbarBottomBtnsLen; i++) {
|
2018-06-27 23:19:09 +00:00
|
|
|
|
domCache.navbarBottomBtns[i].classList.remove('active');
|
|
|
|
|
}
|
|
|
|
|
document.getElementById('cardPlayback').classList.add('hide');
|
|
|
|
|
document.getElementById('cardQueue').classList.add('hide');
|
|
|
|
|
document.getElementById('cardBrowse').classList.add('hide');
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('cardSearch').classList.add('hide');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
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');
|
2018-06-27 23:19:09 +00:00
|
|
|
|
document.getElementById('cardBrowsePlaylists').classList.add('hide');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
document.getElementById('cardBrowseDatabase').classList.add('hide');
|
2018-06-27 23:19:09 +00:00
|
|
|
|
document.getElementById('cardBrowseFilesystem').classList.add('hide');
|
2018-06-25 22:41:44 +00:00
|
|
|
|
//show active card + nav
|
2018-06-27 23:19:09 +00:00
|
|
|
|
document.getElementById('card' + app.current.app).classList.remove('hide');
|
2018-11-12 23:48:29 +00:00
|
|
|
|
if (document.getElementById('nav' + app.current.app))
|
|
|
|
|
document.getElementById('nav' + app.current.app).classList.add('active');
|
2018-06-25 22:41:44 +00:00
|
|
|
|
if (app.current.tab != undefined) {
|
2018-06-27 23:19:09 +00:00
|
|
|
|
document.getElementById('card' + app.current.app + app.current.tab).classList.remove('hide');
|
|
|
|
|
document.getElementById('card' + app.current.app + 'Nav' + app.current.tab).classList.add('active');
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
2018-07-09 15:36:45 +00:00
|
|
|
|
scrollTo(scrollPos);
|
2018-06-10 21:15:33 +00:00
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
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');
|
2018-06-07 18:47:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-02 19:40:27 +00:00
|
|
|
|
function appGoto(a,t,v,s) {
|
2018-07-09 15:36:45 +00:00
|
|
|
|
var scrollPos = 0;
|
|
|
|
|
if (document.body.scrollTop)
|
|
|
|
|
scrollPos = document.body.scrollTop
|
|
|
|
|
else
|
|
|
|
|
scrollPos = document.documentElement.scrollTop;
|
|
|
|
|
|
|
|
|
|
if (app.apps[app.current.app].scrollPos != undefined)
|
|
|
|
|
app.apps[app.current.app].scrollPos = scrollPos
|
|
|
|
|
else if (app.apps[app.current.app].tabs[app.current.tab].scrollPos != undefined)
|
|
|
|
|
app.apps[app.current.app].tabs[app.current.tab].scrollPos = scrollPos
|
|
|
|
|
else if (app.apps[app.current.app].tabs[app.current.tab].views[app.current.view].scrollPos != undefined)
|
|
|
|
|
app.apps[app.current.app].tabs[app.current.tab].views[app.current.view].scrollPos = scrollPos;
|
|
|
|
|
|
|
|
|
|
var hash = '';
|
2018-06-25 22:41:44 +00:00
|
|
|
|
if (app.apps[a].tabs) {
|
|
|
|
|
if (t == undefined)
|
|
|
|
|
t = app.apps[a].active;
|
|
|
|
|
if (app.apps[a].tabs[t].views) {
|
|
|
|
|
if (v == undefined)
|
|
|
|
|
v = app.apps[a].tabs[t].active;
|
2018-07-05 19:34:16 +00:00
|
|
|
|
hash = '/' + a + '/' + t +'/'+v + '!' + (s == undefined ? app.apps[a].tabs[t].views[v].state : s);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
} else {
|
|
|
|
|
hash = '/'+a+'/'+t+'!'+ (s == undefined ? app.apps[a].tabs[t].state : s);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2018-07-05 19:34:16 +00:00
|
|
|
|
hash = '/' + a + '!'+ (s == undefined ? app.apps[a].state : s);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
2018-07-05 19:34:16 +00:00
|
|
|
|
location.hash = hash;
|
2018-06-07 18:47:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-02 19:40:27 +00:00
|
|
|
|
function appRoute() {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
var hash = decodeURI(location.hash);
|
2018-07-19 18:26:15 +00:00
|
|
|
|
var params;
|
2018-07-05 19:34:16 +00:00
|
|
|
|
if (params = hash.match(/^\#\/(\w+)\/?(\w+)?\/?(\w+)?\!((\d+)\/([^\/]+)\/(.*))$/)) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
app.current.app = params[1];
|
|
|
|
|
app.current.tab = params[2];
|
|
|
|
|
app.current.view = params[3];
|
|
|
|
|
if (app.apps[app.current.app].state) {
|
|
|
|
|
app.apps[app.current.app].state = params[4];
|
2018-07-09 15:36:45 +00:00
|
|
|
|
app.current.scrollPos = app.apps[app.current.app].scrollPos;
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
|
|
|
|
else if (app.apps[app.current.app].tabs[app.current.tab].state) {
|
|
|
|
|
app.apps[app.current.app].tabs[app.current.tab].state = params[4];
|
|
|
|
|
app.apps[app.current.app].active = app.current.tab;
|
2018-07-09 15:36:45 +00:00
|
|
|
|
app.current.scrollPos = app.apps[app.current.app].tabs[app.current.tab].scrollPos;
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
|
|
|
|
else if (app.apps[app.current.app].tabs[app.current.tab].views[app.current.view].state) {
|
|
|
|
|
app.apps[app.current.app].tabs[app.current.tab].views[app.current.view].state = params[4];
|
|
|
|
|
app.apps[app.current.app].active = app.current.tab;
|
|
|
|
|
app.apps[app.current.app].tabs[app.current.tab].active = app.current.view;
|
2018-07-09 15:36:45 +00:00
|
|
|
|
app.current.scrollPos = app.apps[app.current.app].tabs[app.current.tab].views[app.current.view].scrollPos;
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
|
|
|
|
app.current.page = parseInt(params[5]);
|
|
|
|
|
app.current.filter = params[6];
|
|
|
|
|
app.current.search = params[7];
|
2018-11-14 23:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-07-02 19:40:27 +00:00
|
|
|
|
appGoto('Playback');
|
2018-06-25 22:41:44 +00:00
|
|
|
|
return;
|
2018-06-10 21:15:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-09 15:36:45 +00:00
|
|
|
|
appPrepare(app.current.scrollPos);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
2018-06-10 21:15:33 +00:00
|
|
|
|
if (app.current.app == 'Playback') {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_CURRENT_SONG"}, songChange);
|
2018-06-07 18:47:40 +00:00
|
|
|
|
}
|
2018-11-14 23:14:47 +00:00
|
|
|
|
else if (app.current.app == 'Queue' && app.current.tab == 'Current' ) {
|
2018-10-29 18:17:04 +00:00
|
|
|
|
selectTag('searchqueuetags', 'searchqueuetagsdesc', app.current.filter);
|
2018-06-14 19:56:12 +00:00
|
|
|
|
getQueue();
|
2018-06-07 18:47:40 +00:00
|
|
|
|
}
|
2018-11-14 23:14:47 +00:00
|
|
|
|
else if (app.current.app == 'Queue' && app.current.tab == 'LastPlayed') {
|
2018-11-12 23:48:29 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_LAST_PLAYED", "data": {"offset": app.current.page}}, parseLastPlayed);
|
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'All') {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST", "data": {"offset": app.current.page, "filter": app.current.filter}}, parsePlaylists);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
doSetFilterLetter('BrowsePlaylistsFilter');
|
2018-06-07 18:47:40 +00:00
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail') {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_CONTENT_LIST", "data": {"offset": app.current.page, "filter": app.current.filter, "uri": app.current.search}}, parsePlaylists);
|
2018-07-22 19:00:26 +00:00
|
|
|
|
doSetFilterLetter('BrowsePlaylistsFilter');
|
|
|
|
|
}
|
2018-09-10 20:32:15 +00:00
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Database') {
|
|
|
|
|
if (app.current.search != '') {
|
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_TAG_ALBUM_LIST", "data": {"offset": app.current.page, "filter": app.current.filter, "search": app.current.search, "tag": app.current.view}}, parseListDBtags);
|
|
|
|
|
doSetFilterLetter('BrowseDatabaseFilter');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_TAG_LIST","data": {"offset": app.current.page, "filter": app.current.filter, "tag": app.current.view}}, parseListDBtags);
|
|
|
|
|
doSetFilterLetter('BrowseDatabaseFilter');
|
2018-09-11 18:59:22 +00:00
|
|
|
|
selectTag('BrowseDatabaseByTagDropdown', 'btnBrowseDatabaseByTag', app.current.view);
|
2018-09-10 20:32:15 +00:00
|
|
|
|
}
|
2018-06-07 18:47:40 +00:00
|
|
|
|
}
|
2018-06-10 21:15:33 +00:00
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Filesystem') {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_FILESYSTEM_LIST", "data": {"offset": app.current.page, "path": (app.current.search ? app.current.search : "/"), "filter": app.current.filter}}, parseFilesystem);
|
2015-08-17 21:01:47 +00:00
|
|
|
|
// Don't add all songs from root
|
2018-07-31 20:46:53 +00:00
|
|
|
|
if (app.current.search) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
document.getElementById('BrowseFilesystemAddAllSongs').removeAttribute('disabled');
|
2018-07-31 20:46:53 +00:00
|
|
|
|
document.getElementById('BrowseFilesystemAddAllSongsBtn').removeAttribute('disabled');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('BrowseFilesystemAddAllSongs').setAttribute('disabled', 'disabled');
|
|
|
|
|
document.getElementById('BrowseFilesystemAddAllSongsBtn').setAttribute('disabled', 'disabled');
|
|
|
|
|
}
|
2018-06-25 22:41:44 +00:00
|
|
|
|
// Create breadcrumb
|
2018-07-01 22:49:47 +00:00
|
|
|
|
var breadcrumbs='<li class="breadcrumb-item"><a data-uri="">root</a></li>';
|
2018-06-27 23:19:09 +00:00
|
|
|
|
var pathArray = app.current.search.split('/');
|
|
|
|
|
var pathArrayLen = pathArray.length;
|
|
|
|
|
var fullPath = '';
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < pathArrayLen; i++) {
|
2018-06-27 23:19:09 +00:00
|
|
|
|
if (pathArrayLen -1 == i) {
|
2018-07-01 22:49:47 +00:00
|
|
|
|
breadcrumbs += '<li class="breadcrumb-item active">' + pathArray[i] + '</li>';
|
2018-06-25 22:41:44 +00:00
|
|
|
|
break;
|
2014-01-16 17:32:20 +00:00
|
|
|
|
}
|
2018-06-27 23:19:09 +00:00
|
|
|
|
fullPath += pathArray[i];
|
2018-07-01 22:49:47 +00:00
|
|
|
|
breadcrumbs += '<li class="breadcrumb-item"><a data-uri="' + fullPath + '">' + pathArray[i] + '</a></li>';
|
2018-06-27 23:19:09 +00:00
|
|
|
|
fullPath += '/';
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
|
|
|
|
var elBrowseBreadcrumb=document.getElementById('BrowseBreadcrumb');
|
2018-07-01 22:49:47 +00:00
|
|
|
|
elBrowseBreadcrumb.innerHTML = breadcrumbs;
|
2018-06-25 22:41:44 +00:00
|
|
|
|
var breadcrumbItems = elBrowseBreadcrumb.getElementsByTagName('a');
|
2018-06-27 23:19:09 +00:00
|
|
|
|
var breadcrumbItemsLen = breadcrumbItems.length;
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < breadcrumbItemsLen; i++) {
|
2018-06-27 23:19:09 +00:00
|
|
|
|
breadcrumbItems[i].addEventListener('click', function() {
|
2018-07-02 19:40:27 +00:00
|
|
|
|
appGoto('Browse', 'Filesystem', undefined, '0/' + app.current.filter + '/' + this.getAttribute('data-uri'));
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}, false);
|
|
|
|
|
}
|
2018-06-28 22:51:24 +00:00
|
|
|
|
doSetFilterLetter('BrowseFilesystemFilter');
|
2018-06-07 18:47:40 +00:00
|
|
|
|
}
|
2018-06-10 21:15:33 +00:00
|
|
|
|
else if (app.current.app == 'Search') {
|
2018-11-27 19:45:35 +00:00
|
|
|
|
domCache.searchstr.focus();
|
2018-11-27 13:05:51 +00:00
|
|
|
|
if (settings.featAdvsearch) {
|
|
|
|
|
var crumbs = '';
|
|
|
|
|
var elements = app.current.search.substring(1, app.current.search.length - 1).split(' AND ');
|
|
|
|
|
for (var i = 0; i < elements.length - 1 ; i++) {
|
|
|
|
|
var value = elements[i].substring(1, elements[i].length - 1);
|
|
|
|
|
crumbs += '<button data-filter="' + encodeURI(value) + '" class="btn btn-light mr-2">' + value + '<span class="ml-2 badge badge-secondary">×</span></button>';
|
|
|
|
|
}
|
2018-11-27 19:45:35 +00:00
|
|
|
|
domCache.searchCrumb.innerHTML = crumbs;
|
|
|
|
|
if (domCache.searchstr.value == '' && elements.length >= 1) {
|
2018-11-27 13:05:51 +00:00
|
|
|
|
var lastEl = elements[elements.length - 1].substring(1, elements[elements.length - 1].length - 1);
|
|
|
|
|
var lastElValue = lastEl.substring(lastEl.indexOf('\'') + 1, lastEl.length - 1);
|
2018-11-27 19:45:35 +00:00
|
|
|
|
if (domCache.searchstr.value != lastElValue)
|
|
|
|
|
domCache.searchCrumb.innerHTML += '<button data-filter="' + encodeURI(lastEl) +'" class="btn btn-light mr-2">' + lastEl + '<span href="#" class="ml-2 badge badge-secondary">×</span></button>';
|
2018-11-27 13:05:51 +00:00
|
|
|
|
var match = lastEl.substring(lastEl.indexOf(' ') + 1);
|
|
|
|
|
match = match.substring(0, match.indexOf(' '));
|
|
|
|
|
if (match == '')
|
|
|
|
|
match = 'contains';
|
|
|
|
|
document.getElementById('searchMatch').value = match;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-11-27 19:45:35 +00:00
|
|
|
|
if (domCache.searchstr.value == '' && app.current.search != '')
|
|
|
|
|
domCache.searchstr.value = app.current.search;
|
2018-11-27 13:05:51 +00:00
|
|
|
|
}
|
2018-06-10 21:15:33 +00:00
|
|
|
|
if (app.last.app != app.current.app) {
|
2018-11-12 23:48:29 +00:00
|
|
|
|
if (app.current.search != '') {
|
|
|
|
|
var colspan = settings['cols' + app.current.app].length;
|
|
|
|
|
colspan--;
|
2018-06-25 22:41:44 +00:00
|
|
|
|
document.getElementById('SearchList').getElementsByTagName('tbody')[0].innerHTML=
|
|
|
|
|
'<tr><td><span class="material-icons">search</span></td>' +
|
2018-11-12 23:48:29 +00:00
|
|
|
|
'<td colspan="' + colspan + '">Searching...</td></tr>';
|
|
|
|
|
}
|
2018-05-29 20:12:11 +00:00
|
|
|
|
}
|
2018-06-25 22:41:44 +00:00
|
|
|
|
|
2018-11-27 19:45:35 +00:00
|
|
|
|
if (domCache.searchstr.value.length >= 2 || domCache.searchCrumb.children.length > 0) {
|
2018-11-27 13:05:51 +00:00
|
|
|
|
if (settings.featAdvsearch) {
|
|
|
|
|
var sort = document.getElementById('SearchList').getAttribute('data-sort');
|
|
|
|
|
var sortdesc = false;
|
|
|
|
|
if (sort == '') {
|
|
|
|
|
if (settings.tags.includes('Title'))
|
|
|
|
|
sort = 'Title';
|
|
|
|
|
else
|
2018-12-03 22:03:03 +00:00
|
|
|
|
sort = '';
|
2018-11-27 13:05:51 +00:00
|
|
|
|
document.getElementById('SearchList').setAttribute('data-sort', sort);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (sort.indexOf('-') == 0) {
|
|
|
|
|
sortdesc = true;
|
|
|
|
|
sort = sort.substring(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_SEARCH_ADV", "data": { "plist": "", "offset": app.current.page, "sort": sort, "sortdesc": sortdesc, "expression": app.current.search}}, parseSearch);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_SEARCH", "data": { "plist": "", "offset": app.current.page, "filter": app.current.filter, "searchstr": app.current.search}}, parseSearch);
|
|
|
|
|
}
|
2018-05-29 23:12:47 +00:00
|
|
|
|
} else {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById('SearchList').getElementsByTagName('tbody')[0].innerHTML = '';
|
|
|
|
|
document.getElementById('searchAddAllSongs').setAttribute('disabled', 'disabled');
|
2018-07-31 20:46:53 +00:00
|
|
|
|
document.getElementById('searchAddAllSongsBtn').setAttribute('disabled', 'disabled');
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById('panel-heading-search').innerText = '';
|
2018-11-27 13:05:51 +00:00
|
|
|
|
document.getElementById('cardFooterSearch').innerText = '';
|
2018-07-05 21:56:42 +00:00
|
|
|
|
document.getElementById('SearchList').classList.remove('opacity05');
|
2018-11-28 14:23:05 +00:00
|
|
|
|
setPagination(0, 0);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
2018-09-11 18:59:22 +00:00
|
|
|
|
selectTag('searchtags', 'searchtagsdesc', app.current.filter);
|
2018-06-07 18:47:40 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-07-02 19:40:27 +00:00
|
|
|
|
appGoto("Playback");
|
2018-06-07 18:47:40 +00:00
|
|
|
|
}
|
2018-06-10 21:15:33 +00:00
|
|
|
|
|
2018-06-27 23:19:09 +00:00
|
|
|
|
app.last.app = app.current.app;
|
|
|
|
|
app.last.tab = app.current.tab;
|
|
|
|
|
app.last.view = app.current.view;
|
2018-06-07 18:47:40 +00:00
|
|
|
|
};
|
2013-11-07 12:47:31 +00:00
|
|
|
|
|
2018-07-02 19:59:56 +00:00
|
|
|
|
function appInit() {
|
2018-11-28 14:23:05 +00:00
|
|
|
|
webSocketConnect();
|
2018-06-21 17:28:07 +00:00
|
|
|
|
getSettings();
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_STATE"}, parseState);
|
2018-06-14 19:56:12 +00:00
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
domCache.volumeBar.value = 0;
|
2018-09-24 21:45:35 +00:00
|
|
|
|
|
|
|
|
|
document.getElementById('btnChVolumeDown').addEventListener('click', function(event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
}, false);
|
|
|
|
|
document.getElementById('btnChVolumeUp').addEventListener('click', function(event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
}, false);
|
|
|
|
|
|
2018-08-27 19:34:21 +00:00
|
|
|
|
domCache.volumeBar.addEventListener('click', function(event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
}, false);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
domCache.volumeBar.addEventListener('change', function(event) {
|
2018-10-11 19:50:26 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_VOLUME_SET", "data": {"volume": domCache.volumeBar.value}});
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}, false);
|
2018-05-21 23:36:05 +00:00
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
domCache.progressBar.value = 0;
|
|
|
|
|
domCache.progressBar.addEventListener('change', function(event) {
|
2018-08-14 14:10:00 +00:00
|
|
|
|
if (currentSong && currentSong.currentSongId >= 0) {
|
2018-12-03 22:22:28 +00:00
|
|
|
|
var seekVal = Math.ceil(currentSong.totalTime * (domCache.progressBar.value / 1000));
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_SEEK", "data": {"songid": currentSong.currentSongId, "seek": seekVal}});
|
2014-01-16 17:32:20 +00:00
|
|
|
|
}
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}, false);
|
2018-09-23 21:48:12 +00:00
|
|
|
|
|
|
|
|
|
document.getElementById('navDBupdate').addEventListener('click', function(event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
var icon = this.getElementsByTagName('span')[0];
|
|
|
|
|
if (icon.innerText == 'keyboard_arrow_right')
|
|
|
|
|
icon.innerText = 'keyboard_arrow_down';
|
|
|
|
|
else
|
|
|
|
|
icon.innerText = 'keyboard_arrow_right';
|
|
|
|
|
}, false);
|
2018-11-06 23:59:44 +00:00
|
|
|
|
|
|
|
|
|
document.getElementById('volumeMenu').parentNode.addEventListener('show.bs.dropdown', function () {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_OUTPUT_LIST"}, parseOutputs);
|
2018-08-06 18:57:42 +00:00
|
|
|
|
});
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
2018-07-02 22:02:02 +00:00
|
|
|
|
document.getElementById('modalAbout').addEventListener('shown.bs.modal', function () {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_STATS"}, parseStats);
|
2018-07-09 17:28:28 +00:00
|
|
|
|
});
|
2018-11-06 23:59:44 +00:00
|
|
|
|
|
|
|
|
|
document.getElementById('modalAddToPlaylist').addEventListener('shown.bs.modal', function () {
|
|
|
|
|
if (!document.getElementById('addStreamFrm').classList.contains('hide'))
|
|
|
|
|
document.getElementById('streamUrl').focus();
|
|
|
|
|
else
|
|
|
|
|
document.getElementById('addToPlaylistPlaylist').focus();
|
|
|
|
|
});
|
2018-08-24 10:11:27 +00:00
|
|
|
|
|
2018-11-08 22:42:45 +00:00
|
|
|
|
document.getElementById('modalHelp').addEventListener('show.bs.modal', function () {
|
|
|
|
|
var trs = '';
|
|
|
|
|
for (var key in keymap) {
|
2018-11-15 21:56:36 +00:00
|
|
|
|
if (keymap[key].req == undefined || settings[keymap[key].req] == true)
|
|
|
|
|
trs += '<tr><td><div class="key' + (keymap[key].key && keymap[key].key.length > 1 ? ' material-icons material-icons-small' : '') +
|
|
|
|
|
'">' + (keymap[key].key != undefined ? keymap[key].key : key ) + '</div></td><td>' + keymap[key].desc + '</td></tr>';
|
2018-11-08 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
document.getElementById('tbodyShortcuts').innerHTML = trs;
|
|
|
|
|
});
|
|
|
|
|
|
2018-08-24 10:11:27 +00:00
|
|
|
|
document.getElementById('modalUpdateDB').addEventListener('hidden.bs.modal', function () {
|
|
|
|
|
document.getElementById('updateDBprogress').classList.remove('updateDBprogressAnimate');
|
|
|
|
|
});
|
2018-07-22 19:42:01 +00:00
|
|
|
|
|
|
|
|
|
document.getElementById('modalSaveQueue').addEventListener('shown.bs.modal', function () {
|
|
|
|
|
var plName = document.getElementById('saveQueueName');
|
|
|
|
|
plName.focus();
|
|
|
|
|
plName.value = '';
|
|
|
|
|
plName.classList.remove('is-invalid');
|
|
|
|
|
document.getElementById('saveQueueFrm').classList.remove('was-validated');
|
|
|
|
|
});
|
2018-07-09 17:28:28 +00:00
|
|
|
|
|
2018-07-02 22:02:02 +00:00
|
|
|
|
document.getElementById('modalSettings').addEventListener('shown.bs.modal', function () {
|
2018-07-02 19:40:27 +00:00
|
|
|
|
getSettings();
|
|
|
|
|
document.getElementById('settingsFrm').classList.remove('was-validated');
|
|
|
|
|
document.getElementById('inputCrossfade').classList.remove('is-invalid');
|
|
|
|
|
document.getElementById('inputMixrampdb').classList.remove('is-invalid');
|
|
|
|
|
document.getElementById('inputMixrampdelay').classList.remove('is-invalid');
|
2018-07-09 17:28:28 +00:00
|
|
|
|
});
|
2018-05-27 21:34:39 +00:00
|
|
|
|
|
2018-09-30 22:18:55 +00:00
|
|
|
|
document.getElementById('selectJukeboxMode').addEventListener('change', function () {
|
|
|
|
|
var value = this.options[this.selectedIndex].value;
|
|
|
|
|
if (value == 0 || value == 2) {
|
|
|
|
|
document.getElementById('inputJukeboxQueueLength').setAttribute('disabled', 'disabled');
|
|
|
|
|
document.getElementById('selectJukeboxPlaylist').setAttribute('disabled', 'disabled');
|
|
|
|
|
}
|
|
|
|
|
else if (value == 1) {
|
|
|
|
|
document.getElementById('inputJukeboxQueueLength').removeAttribute('disabled');
|
|
|
|
|
document.getElementById('selectJukeboxPlaylist').removeAttribute('disabled');
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-07-31 20:46:53 +00:00
|
|
|
|
|
2018-09-30 22:18:55 +00:00
|
|
|
|
document.getElementById('addToPlaylistPlaylist').addEventListener('change', function (event) {
|
2018-07-31 20:46:53 +00:00
|
|
|
|
if (this.options[this.selectedIndex].text == 'New Playlist') {
|
|
|
|
|
document.getElementById('addToPlaylistNewPlaylistDiv').classList.remove('hide');
|
|
|
|
|
document.getElementById('addToPlaylistNewPlaylist').focus();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('addToPlaylistNewPlaylistDiv').classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
}, false);
|
2018-05-29 21:05:34 +00:00
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
addFilterLetter('BrowseFilesystemFilterLetters');
|
|
|
|
|
addFilterLetter('BrowseDatabaseFilterLetters');
|
|
|
|
|
addFilterLetter('BrowsePlaylistsFilterLetters');
|
|
|
|
|
|
2018-10-15 22:34:25 +00:00
|
|
|
|
document.getElementById('syscmds').addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'A') {
|
2018-11-11 23:48:49 +00:00
|
|
|
|
parseCmd(event, event.target.getAttribute('data-href'));
|
2018-10-15 22:34:25 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
|
2018-08-06 18:08:30 +00:00
|
|
|
|
var hrefs = document.querySelectorAll('[data-href]');
|
2018-07-02 19:40:27 +00:00
|
|
|
|
var hrefsLen = hrefs.length;
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < hrefsLen; i++) {
|
2018-08-06 18:08:30 +00:00
|
|
|
|
hrefs[i].classList.add('clickable');
|
2018-07-02 19:40:27 +00:00
|
|
|
|
hrefs[i].addEventListener('click', function(event) {
|
2018-11-11 23:48:49 +00:00
|
|
|
|
parseCmd(event, this.getAttribute('data-href'));
|
2018-07-02 19:40:27 +00:00
|
|
|
|
}, false);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var pd = document.getElementsByClassName('pages');
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var pdLen = pd.length;
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < pdLen; i++) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
pd[i].addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'BUTTON') {
|
|
|
|
|
gotoPage(event.target.getAttribute('data-page'));
|
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-04 23:26:59 +00:00
|
|
|
|
document.getElementById('cardPlaybackTags').addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'H4')
|
|
|
|
|
gotoBrowse(event.target);
|
|
|
|
|
}, false);
|
2018-11-11 22:43:25 +00:00
|
|
|
|
|
|
|
|
|
document.getElementById('modalSongDetails').getElementsByTagName('tbody')[0].addEventListener('click', function(event) {
|
2018-11-11 23:38:46 +00:00
|
|
|
|
if (event.target.nodeName == 'A') {
|
2018-11-11 22:43:25 +00:00
|
|
|
|
if (event.target.parentNode.getAttribute('data-tag') != undefined) {
|
|
|
|
|
modalSongDetails.hide();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
gotoBrowse(event.target);
|
2018-11-11 23:38:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (event.target.nodeName == 'BUTTON') {
|
|
|
|
|
if (event.target.getAttribute('data-href'))
|
|
|
|
|
parseCmd(event, event.target.getAttribute('data-href'));
|
2018-11-11 22:43:25 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
2018-11-04 23:26:59 +00:00
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById('outputs').addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'BUTTON')
|
2018-07-02 19:40:27 +00:00
|
|
|
|
event.stopPropagation();
|
2018-08-27 19:34:21 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_TOGGLE_OUTPUT", "data": {"output": event.target.getAttribute('data-output-id'), "state": (event.target.classList.contains('active') ? 0 : 1)}});
|
2018-07-05 21:56:42 +00:00
|
|
|
|
toggleBtn(event.target.id);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}, false);
|
|
|
|
|
|
2018-11-14 23:14:47 +00:00
|
|
|
|
document.getElementById('QueueCurrentList').addEventListener('click', function(event) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
if (event.target.nodeName == 'TD')
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_PLAY_TRACK","data": {"track": event.target.parentNode.getAttribute('data-trackid')}});
|
2018-11-12 23:48:29 +00:00
|
|
|
|
else if (event.target.nodeName == 'A')
|
2018-09-03 20:01:50 +00:00
|
|
|
|
showMenu(event.target, event);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}, false);
|
2018-11-12 23:48:29 +00:00
|
|
|
|
|
2018-11-14 23:14:47 +00:00
|
|
|
|
document.getElementById('QueueLastPlayedList').addEventListener('click', function(event) {
|
2018-11-12 23:48:29 +00:00
|
|
|
|
if (event.target.nodeName == 'A')
|
|
|
|
|
showMenu(event.target, event);
|
|
|
|
|
}, false);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
|
|
|
|
document.getElementById('BrowseFilesystemList').addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'TD') {
|
|
|
|
|
switch(event.target.parentNode.getAttribute('data-type')) {
|
|
|
|
|
case 'dir':
|
2018-07-02 19:40:27 +00:00
|
|
|
|
appGoto('Browse', 'Filesystem', undefined, '0/' + app.current.filter +'/' + decodeURI(event.target.parentNode.getAttribute("data-uri")));
|
2018-06-28 22:51:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'song':
|
2018-07-05 19:34:16 +00:00
|
|
|
|
appendQueue('song', decodeURI(event.target.parentNode.getAttribute("data-uri")), event.target.parentNode.getAttribute("data-name"));
|
2018-06-28 22:51:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'plist':
|
2018-07-05 19:34:16 +00:00
|
|
|
|
appendQueue('plist', decodeURI(event.target.parentNode.getAttribute("data-uri")), event.target.parentNode.getAttribute("data-name"));
|
2018-06-28 22:51:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (event.target.nodeName == 'A') {
|
2018-09-03 20:01:50 +00:00
|
|
|
|
showMenu(event.target, event);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
|
2018-07-22 19:00:26 +00:00
|
|
|
|
document.getElementById('BrowsePlaylistsAllList').addEventListener('click', function(event) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
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') {
|
2018-09-03 20:01:50 +00:00
|
|
|
|
showMenu(event.target, event);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
2018-07-22 19:00:26 +00:00
|
|
|
|
|
|
|
|
|
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') {
|
2018-09-03 20:01:50 +00:00
|
|
|
|
showMenu(event.target, event);
|
2018-07-22 19:00:26 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
2018-09-10 20:32:15 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseTagList').addEventListener('click', function(event) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
if (event.target.nodeName == 'TD') {
|
2018-09-10 20:32:15 +00:00
|
|
|
|
appGoto('Browse', 'Database', app.current.view, '0/-/' + event.target.parentNode.getAttribute('data-uri'));
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
document.getElementById('SearchList').addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'TD') {
|
|
|
|
|
appendQueue('song', decodeURI(event.target.parentNode.getAttribute("data-uri")), event.target.parentNode.getAttribute("data-name"));
|
|
|
|
|
}
|
|
|
|
|
else if (event.target.nodeName == 'A') {
|
2018-09-03 20:01:50 +00:00
|
|
|
|
showMenu(event.target, event);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
|
2018-07-31 20:46:53 +00:00
|
|
|
|
document.getElementById('BrowseFilesystemAddAllSongsDropdown').addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'BUTTON') {
|
|
|
|
|
if (event.target.innerText == 'Add all to queue') {
|
|
|
|
|
addAllFromBrowse();
|
|
|
|
|
}
|
|
|
|
|
else if (event.target.innerText == 'Add all to playlist') {
|
|
|
|
|
showAddToPlaylist(app.current.search);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
document.getElementById('searchAddAllSongsDropdown').addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'BUTTON') {
|
|
|
|
|
if (event.target.innerText == 'Add all to queue') {
|
2018-09-11 18:59:22 +00:00
|
|
|
|
addAllFromSearchPlist('queue');
|
2018-07-31 20:46:53 +00:00
|
|
|
|
}
|
|
|
|
|
else if (event.target.innerText == 'Add all to playlist') {
|
|
|
|
|
showAddToPlaylist('SEARCH');
|
|
|
|
|
}
|
2018-09-29 18:41:58 +00:00
|
|
|
|
else if (event.target.innerText == 'Save as smart playlist') {
|
2018-10-01 17:07:38 +00:00
|
|
|
|
saveSearchAsSmartPlaylist();
|
2018-09-29 18:41:58 +00:00
|
|
|
|
}
|
2018-07-31 20:46:53 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
2018-09-11 18:59:22 +00:00
|
|
|
|
|
|
|
|
|
document.getElementById('BrowseDatabaseAddAllSongsDropdown').addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'BUTTON') {
|
|
|
|
|
if (event.target.innerText == 'Add all to queue') {
|
|
|
|
|
addAllFromBrowseDatabasePlist('queue');
|
|
|
|
|
}
|
|
|
|
|
else if (event.target.innerText == 'Add all to playlist') {
|
|
|
|
|
showAddToPlaylist('DATABASE');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, false);
|
2018-07-31 20:46:53 +00:00
|
|
|
|
|
2018-07-15 23:56:58 +00:00
|
|
|
|
document.getElementById('searchtags').addEventListener('click', function(event) {
|
2018-11-28 14:41:13 +00:00
|
|
|
|
if (event.target.nodeName == 'BUTTON') {
|
|
|
|
|
app.current.filter = event.target.getAttribute('data-tag');
|
|
|
|
|
search(domCache.searchstr.value);
|
|
|
|
|
}
|
2018-06-28 23:44:52 +00:00
|
|
|
|
}, false);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
2018-06-28 23:44:52 +00:00
|
|
|
|
document.getElementById('searchqueuestr').addEventListener('keyup', function(event) {
|
2018-11-08 22:42:45 +00:00
|
|
|
|
if (event.key == 'Escape')
|
|
|
|
|
this.blur();
|
|
|
|
|
else
|
|
|
|
|
appGoto(app.current.app, app.current.tab, app.current.view, '0/' + app.current.filter + '/' + this.value);
|
2018-06-28 23:44:52 +00:00
|
|
|
|
}, false);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
document.getElementById('searchqueuetags').addEventListener('click', function(event) {
|
2018-06-28 23:44:52 +00:00
|
|
|
|
if (event.target.nodeName == 'BUTTON')
|
2018-09-03 18:02:12 +00:00
|
|
|
|
appGoto(app.current.app, app.current.tab, app.current.view, app.current.page + '/' + event.target.getAttribute('data-tag') + '/' + app.current.search);
|
2018-06-28 23:44:52 +00:00
|
|
|
|
}, false);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
2018-11-14 23:14:47 +00:00
|
|
|
|
var dropdowns = ['QueueCurrentColsDropdown', 'BrowseFilesystemColsDropdown', 'SearchColsDropdown', 'BrowsePlaylistsDetailColsDropdown',
|
|
|
|
|
'BrowseDatabaseColsDropdown', 'PlaybackColsDropdown', 'QueueLastPlayedColsDropdown'];
|
2018-11-11 23:56:42 +00:00
|
|
|
|
for (var i = 0; i < dropdowns.length; i++) {
|
|
|
|
|
document.getElementById(dropdowns[i]).addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'INPUT')
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
}, false);
|
|
|
|
|
}
|
2018-10-22 22:20:57 +00:00
|
|
|
|
|
2018-09-03 20:01:50 +00:00
|
|
|
|
document.getElementById('search').addEventListener('submit', function() {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
return false;
|
|
|
|
|
}, false);
|
|
|
|
|
|
2018-09-03 20:01:50 +00:00
|
|
|
|
document.getElementById('searchqueue').addEventListener('submit', function() {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
return false;
|
|
|
|
|
}, false);
|
|
|
|
|
|
2018-11-27 19:45:35 +00:00
|
|
|
|
domCache.searchstr.addEventListener('keyup', function(event) {
|
2018-11-08 22:42:45 +00:00
|
|
|
|
if (event.key == 'Escape')
|
|
|
|
|
this.blur();
|
2018-11-27 13:05:51 +00:00
|
|
|
|
else if (event.key == 'Enter' && settings.featAdvsearch) {
|
|
|
|
|
if (this.value != '') {
|
|
|
|
|
var match = document.getElementById('searchMatch');
|
|
|
|
|
var li = document.createElement('button');
|
|
|
|
|
li.classList.add('btn', 'btn-light', 'mr-2');
|
|
|
|
|
li.setAttribute('data-filter', encodeURI(app.current.filter + ' ' + match.options[match.selectedIndex].value +' \'' + this.value + '\''));
|
|
|
|
|
li.innerHTML = app.current.filter + ' ' + match.options[match.selectedIndex].value + ' \'' + this.value + '\'<span class="ml-2 badge badge-secondary">×</span>';
|
|
|
|
|
this.value = '';
|
2018-11-27 19:45:35 +00:00
|
|
|
|
domCache.searchCrumb.appendChild(li);
|
2018-11-27 13:05:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
search(this.value);
|
|
|
|
|
}
|
2018-11-08 22:42:45 +00:00
|
|
|
|
else
|
2018-11-27 13:05:51 +00:00
|
|
|
|
search(this.value);
|
|
|
|
|
}, false);
|
|
|
|
|
|
2018-11-27 19:45:35 +00:00
|
|
|
|
domCache.searchCrumb.addEventListener('click', function(event) {
|
2018-11-27 13:05:51 +00:00
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
if (event.target.nodeName == 'SPAN') {
|
|
|
|
|
event.target.parentNode.remove();
|
|
|
|
|
search('');
|
|
|
|
|
}
|
|
|
|
|
else if (event.target.nodeName == 'BUTTON') {
|
|
|
|
|
var value = decodeURI(event.target.getAttribute('data-filter'));
|
2018-11-27 19:45:35 +00:00
|
|
|
|
domCache.searchstr.value = value.substring(value.indexOf('\'') + 1, value.length - 1);
|
2018-11-27 13:05:51 +00:00
|
|
|
|
var filter = value.substring(0, value.indexOf(' '));
|
|
|
|
|
selectTag('searchtags', 'searchtagsdesc', filter);
|
|
|
|
|
var match = value.substring(value.indexOf(' ') + 1);
|
|
|
|
|
match = match.substring(0, match.indexOf(' '));
|
|
|
|
|
document.getElementById('searchMatch').value = match;
|
|
|
|
|
event.target.remove();
|
2018-11-27 19:45:35 +00:00
|
|
|
|
search(domCache.searchstr.value);
|
2018-11-27 13:05:51 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
document.getElementById('searchMatch').addEventListener('change', function(event) {
|
2018-11-27 19:45:35 +00:00
|
|
|
|
search(domCache.searchstr.value);
|
2018-11-27 13:05:51 +00:00
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
document.getElementById('SearchList').getElementsByTagName('tr')[0].addEventListener('click', function(event) {
|
|
|
|
|
if (settings.featAdvsearch) {
|
|
|
|
|
if (event.target.nodeName == 'TH') {
|
|
|
|
|
var col = event.target.getAttribute('data-col');
|
|
|
|
|
if (col == 'Duration')
|
|
|
|
|
return;
|
|
|
|
|
var sortcol = document.getElementById('SearchList').getAttribute('data-sort');
|
|
|
|
|
var sortdesc = true;
|
|
|
|
|
|
|
|
|
|
if (sortcol == col || sortcol == '-' + col) {
|
|
|
|
|
if (sortcol.indexOf('-') == 0) {
|
|
|
|
|
sortdesc = true;
|
|
|
|
|
sortcol = sortcol.substring(1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
sortdesc = false;
|
|
|
|
|
}
|
|
|
|
|
if (sortdesc == false) {
|
|
|
|
|
sortcol = '-' + col;
|
|
|
|
|
sortdesc = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sortdesc = false;
|
|
|
|
|
sortcol = col;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var s = document.getElementById('SearchList').getElementsByClassName('sort-dir');
|
|
|
|
|
for (var i = 0; i < s.length; i++)
|
|
|
|
|
s[i].remove();
|
|
|
|
|
document.getElementById('SearchList').setAttribute('data-sort', sortcol);
|
|
|
|
|
event.target.innerHTML = col + '<span class="sort-dir material-icons pull-right">' + (sortdesc == true ? 'arrow_drop_up' : 'arrow_drop_down') + '</span>';
|
|
|
|
|
appRoute();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}, false);
|
|
|
|
|
|
2018-09-10 20:32:15 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseByTagDropdown').addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'BUTTON')
|
|
|
|
|
appGoto(app.current.app, app.current.tab, event.target.getAttribute('data-tag') , '0/' + app.current.filter + '/' + app.current.search);
|
|
|
|
|
}, false);
|
2018-09-03 20:01:50 +00:00
|
|
|
|
|
|
|
|
|
document.getElementsByTagName('body')[0].addEventListener('click', function(event) {
|
2018-09-29 23:03:00 +00:00
|
|
|
|
hideMenu();
|
2018-09-03 20:01:50 +00:00
|
|
|
|
}, false);
|
|
|
|
|
|
2018-11-14 23:14:47 +00:00
|
|
|
|
dragAndDropTable('QueueCurrentList');
|
2018-07-26 21:48:03 +00:00
|
|
|
|
dragAndDropTable('BrowsePlaylistsDetailList');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
dragAndDropTableHeader('QueueCurrent');
|
|
|
|
|
dragAndDropTableHeader('QueueLastPlayed');
|
2018-10-22 22:20:57 +00:00
|
|
|
|
dragAndDropTableHeader('Search');
|
|
|
|
|
dragAndDropTableHeader('BrowseFilesystem');
|
|
|
|
|
dragAndDropTableHeader('BrowsePlaylistsDetail');
|
2018-07-26 21:48:03 +00:00
|
|
|
|
|
2018-07-02 19:40:27 +00:00
|
|
|
|
window.addEventListener('hashchange', appRoute, false);
|
2018-09-03 20:01:50 +00:00
|
|
|
|
|
2018-08-21 19:28:13 +00:00
|
|
|
|
window.addEventListener('focus', function() {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_STATE"}, parseState);
|
2018-08-21 19:28:13 +00:00
|
|
|
|
}, false);
|
2018-11-27 13:05:51 +00:00
|
|
|
|
|
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.addEventListener('keydown', function(event) {
|
2018-11-08 22:42:45 +00:00
|
|
|
|
if (event.target.tagName == 'INPUT' || event.target.tagName == 'SELECT' ||
|
|
|
|
|
event.ctrlKey || event.altKey)
|
2018-11-05 21:49:57 +00:00
|
|
|
|
return;
|
2018-11-08 22:42:45 +00:00
|
|
|
|
var cmd = keymap[event.key];
|
2018-11-05 23:13:22 +00:00
|
|
|
|
if (cmd && typeof window[cmd.cmd] === 'function') {
|
2018-11-15 21:56:36 +00:00
|
|
|
|
if (keymap[event.key].req == undefined || settings[keymap[event.key].req] == true)
|
|
|
|
|
parseCmd(event, cmd);
|
2018-11-05 23:13:22 +00:00
|
|
|
|
}
|
2018-11-07 23:52:28 +00:00
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}, false);
|
2018-07-16 17:33:20 +00:00
|
|
|
|
|
2018-07-19 16:33:53 +00:00
|
|
|
|
if ('serviceWorker' in navigator && document.URL.substring(0, 5) == 'https') {
|
2018-07-16 17:33:20 +00:00
|
|
|
|
window.addEventListener('load', function() {
|
2018-09-20 22:04:35 +00:00
|
|
|
|
navigator.serviceWorker.register('/sw.min.js', {scope: '/'}).then(function(registration) {
|
2018-07-16 17:33:20 +00:00
|
|
|
|
// Registration was successful
|
|
|
|
|
console.log('ServiceWorker registration successful with scope: ', registration.scope);
|
2018-07-24 22:52:59 +00:00
|
|
|
|
registration.update();
|
2018-07-16 17:33:20 +00:00
|
|
|
|
}, function(err) {
|
2018-08-22 12:06:22 +00:00
|
|
|
|
// Registration failed
|
2018-07-16 17:33:20 +00:00
|
|
|
|
console.log('ServiceWorker registration failed: ', err);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-24 22:52:59 +00:00
|
|
|
|
window.addEventListener('beforeinstallprompt', function(event) {
|
2018-07-16 17:33:20 +00:00
|
|
|
|
// Prevent Chrome 67 and earlier from automatically showing the prompt
|
2018-07-24 22:52:59 +00:00
|
|
|
|
event.preventDefault();
|
2018-07-16 17:33:20 +00:00
|
|
|
|
// Stash the event so it can be triggered later.
|
2018-07-24 22:52:59 +00:00
|
|
|
|
deferredPrompt = event;
|
2018-07-16 17:33:20 +00:00
|
|
|
|
});
|
|
|
|
|
|
2018-07-24 22:52:59 +00:00
|
|
|
|
window.addEventListener('beforeinstallprompt', function(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
deferredPrompt = event;
|
2018-07-16 17:33:20 +00:00
|
|
|
|
// Update UI notify the user they can add to home screen
|
|
|
|
|
domCache.btnAdd.classList.remove('hide');
|
|
|
|
|
});
|
|
|
|
|
|
2018-07-24 22:52:59 +00:00
|
|
|
|
domCache.btnAdd.addEventListener('click', function(event) {
|
2018-08-22 12:06:22 +00:00
|
|
|
|
// Hide our user interface that shows our A2HS button
|
2018-07-16 17:33:20 +00:00
|
|
|
|
domCache.btnAdd.classList.add('hide');
|
|
|
|
|
// Show the prompt
|
|
|
|
|
deferredPrompt.prompt();
|
|
|
|
|
// Wait for the user to respond to the prompt
|
|
|
|
|
deferredPrompt.userChoice.then((choiceResult) => {
|
|
|
|
|
if (choiceResult.outcome === 'accepted')
|
|
|
|
|
console.log('User accepted the A2HS prompt');
|
|
|
|
|
else
|
|
|
|
|
console.log('User dismissed the A2HS prompt');
|
|
|
|
|
deferredPrompt = null;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2018-07-24 22:52:59 +00:00
|
|
|
|
window.addEventListener('appinstalled', function(event) {
|
|
|
|
|
console.log('myMPD installed as app');
|
2018-07-16 17:33:20 +00:00
|
|
|
|
});
|
2018-07-02 19:59:56 +00:00
|
|
|
|
}
|
2013-11-07 09:09:40 +00:00
|
|
|
|
|
2018-11-11 23:38:46 +00:00
|
|
|
|
function parseCmd(event, href) {
|
|
|
|
|
event.preventDefault();
|
2018-11-11 23:48:49 +00:00
|
|
|
|
var cmd = href;
|
|
|
|
|
if (typeof(href) == 'string')
|
|
|
|
|
cmd = JSON.parse(href);
|
|
|
|
|
|
2018-11-11 23:38:46 +00:00
|
|
|
|
if (typeof window[cmd.cmd] === 'function') {
|
|
|
|
|
switch(cmd.cmd) {
|
|
|
|
|
case 'sendAPI':
|
|
|
|
|
sendAPI(... cmd.options);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
window[cmd.cmd](... cmd.options);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-27 13:05:51 +00:00
|
|
|
|
function search(x) {
|
|
|
|
|
if (settings.featAdvsearch) {
|
|
|
|
|
var expression = '(';
|
2018-11-27 19:45:35 +00:00
|
|
|
|
var crumbs = domCache.searchCrumb.children;
|
2018-11-27 13:05:51 +00:00
|
|
|
|
for (var i = 0; i < crumbs.length; i++) {
|
|
|
|
|
expression += '(' + decodeURI(crumbs[i].getAttribute('data-filter')) + ')';
|
|
|
|
|
if (x != '') expression += ' AND ';
|
|
|
|
|
}
|
|
|
|
|
if (x != '') {
|
|
|
|
|
var match = document.getElementById('searchMatch');
|
|
|
|
|
expression += '(' + app.current.filter + ' ' + match.options[match.selectedIndex].value + ' \'' + x +'\'))';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
expression += ')';
|
|
|
|
|
if (expression.length <= 2)
|
|
|
|
|
expression = '';
|
|
|
|
|
appGoto('Search', undefined, undefined, '0/' + app.current.filter + '/' + encodeURI(expression));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
appGoto('Search', undefined, undefined, '0/' + app.current.filter + '/' + x);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-26 21:48:03 +00:00
|
|
|
|
function dragAndDropTable(table) {
|
|
|
|
|
var tableBody=document.getElementById(table).getElementsByTagName('tbody')[0];
|
|
|
|
|
tableBody.addEventListener('dragstart', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'TR') {
|
|
|
|
|
event.target.classList.add('opacity05');
|
|
|
|
|
event.dataTransfer.setDragImage(event.target, 0, 0);
|
|
|
|
|
event.dataTransfer.effectAllowed = 'move';
|
|
|
|
|
event.dataTransfer.setData('Text', event.target.getAttribute('id'));
|
|
|
|
|
dragEl = event.target.cloneNode(true);
|
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
tableBody.addEventListener('dragleave', function(event) {
|
2018-10-22 20:03:45 +00:00
|
|
|
|
event.preventDefault();
|
|
|
|
|
if (dragEl.nodeName != 'TR')
|
|
|
|
|
return;
|
2018-07-26 21:48:03 +00:00
|
|
|
|
var target = event.target;
|
|
|
|
|
if (event.target.nodeName == 'TD')
|
|
|
|
|
target = event.target.parentNode;
|
|
|
|
|
if (target.nodeName == 'TR')
|
|
|
|
|
target.classList.remove('dragover');
|
|
|
|
|
}, false);
|
|
|
|
|
tableBody.addEventListener('dragover', function(event) {
|
|
|
|
|
event.preventDefault();
|
2018-10-22 20:03:45 +00:00
|
|
|
|
if (dragEl.nodeName != 'TR')
|
|
|
|
|
return;
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var tr = tableBody.getElementsByClassName('dragover');
|
2018-07-26 21:48:03 +00:00
|
|
|
|
var trLen = tr.length;
|
|
|
|
|
for (var i = 0; i < trLen; i++) {
|
|
|
|
|
tr[i].classList.remove('dragover');
|
|
|
|
|
}
|
|
|
|
|
var target = event.target;
|
|
|
|
|
if (event.target.nodeName == 'TD')
|
|
|
|
|
target = event.target.parentNode;
|
|
|
|
|
if (target.nodeName == 'TR')
|
|
|
|
|
target.classList.add('dragover');
|
|
|
|
|
event.dataTransfer.dropEffect = 'move';
|
|
|
|
|
}, false);
|
|
|
|
|
tableBody.addEventListener('dragend', function(event) {
|
2018-10-22 20:03:45 +00:00
|
|
|
|
event.preventDefault();
|
|
|
|
|
if (dragEl.nodeName != 'TR')
|
|
|
|
|
return;
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var tr = tableBody.getElementsByClassName('dragover');
|
2018-07-26 21:48:03 +00:00
|
|
|
|
var trLen = tr.length;
|
|
|
|
|
for (var i = 0; i < trLen; i++) {
|
|
|
|
|
tr[i].classList.remove('dragover');
|
|
|
|
|
}
|
|
|
|
|
if (document.getElementById(event.dataTransfer.getData('Text')))
|
|
|
|
|
document.getElementById(event.dataTransfer.getData('Text')).classList.remove('opacity05');
|
|
|
|
|
}, false);
|
|
|
|
|
tableBody.addEventListener('drop', function(event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
2018-10-22 20:03:45 +00:00
|
|
|
|
if (dragEl.nodeName != 'TR')
|
|
|
|
|
return;
|
2018-07-26 21:48:03 +00:00
|
|
|
|
var target = event.target;
|
|
|
|
|
if (event.target.nodeName == 'TD')
|
|
|
|
|
target = event.target.parentNode;
|
|
|
|
|
var oldSongpos = document.getElementById(event.dataTransfer.getData('Text')).getAttribute('data-songpos');
|
|
|
|
|
var newSongpos = target.getAttribute('data-songpos');
|
|
|
|
|
document.getElementById(event.dataTransfer.getData('Text')).remove();
|
|
|
|
|
dragEl.classList.remove('opacity05');
|
|
|
|
|
tableBody.insertBefore(dragEl, target);
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var tr = tableBody.getElementsByClassName('dragover');
|
2018-07-26 21:48:03 +00:00
|
|
|
|
var trLen = tr.length;
|
|
|
|
|
for (var i = 0; i < trLen; i++) {
|
|
|
|
|
tr[i].classList.remove('dragover');
|
|
|
|
|
}
|
|
|
|
|
document.getElementById(table).classList.add('opacity05');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
if (app.current.app == 'Queue' && app.current.tab == 'Current')
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_MOVE_TRACK","data": {"from": oldSongpos, "to": newSongpos}});
|
2018-07-26 21:48:03 +00:00
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail')
|
|
|
|
|
playlistMoveTrack(oldSongpos, newSongpos);
|
|
|
|
|
}, false);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-22 20:03:45 +00:00
|
|
|
|
function dragAndDropTableHeader(table) {
|
2018-11-04 18:34:46 +00:00
|
|
|
|
var tableHeader;
|
|
|
|
|
if (document.getElementById(table + 'List'))
|
|
|
|
|
tableHeader = document.getElementById(table + 'List').getElementsByTagName('tr')[0];
|
|
|
|
|
else {
|
|
|
|
|
tableHeader = table.getElementsByTagName('tr')[0];
|
|
|
|
|
table = 'BrowseDatabase';
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-22 20:03:45 +00:00
|
|
|
|
tableHeader.addEventListener('dragstart', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'TH') {
|
|
|
|
|
event.target.classList.add('opacity05');
|
|
|
|
|
event.dataTransfer.setDragImage(event.target, 0, 0);
|
|
|
|
|
event.dataTransfer.effectAllowed = 'move';
|
|
|
|
|
event.dataTransfer.setData('Text', event.target.getAttribute('data-col'));
|
|
|
|
|
dragEl = event.target.cloneNode(true);
|
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
tableHeader.addEventListener('dragleave', function(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
if (dragEl.nodeName != 'TH')
|
|
|
|
|
return;
|
|
|
|
|
if (event.target.nodeName == 'TH')
|
|
|
|
|
event.target.classList.remove('dragover-th');
|
|
|
|
|
}, false);
|
|
|
|
|
tableHeader.addEventListener('dragover', function(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
if (dragEl.nodeName != 'TH')
|
|
|
|
|
return;
|
|
|
|
|
var th = tableHeader.getElementsByClassName('dragover-th');
|
|
|
|
|
var thLen = th.length;
|
|
|
|
|
for (var i = 0; i < thLen; i++) {
|
|
|
|
|
th[i].classList.remove('dragover-th');
|
|
|
|
|
}
|
|
|
|
|
if (event.target.nodeName == 'TH')
|
|
|
|
|
event.target.classList.add('dragover-th');
|
|
|
|
|
event.dataTransfer.dropEffect = 'move';
|
|
|
|
|
}, false);
|
|
|
|
|
tableHeader.addEventListener('dragend', function(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
if (dragEl.nodeName != 'TH')
|
|
|
|
|
return;
|
|
|
|
|
var th = tableHeader.getElementsByClassName('dragover-th');
|
|
|
|
|
var thLen = th.length;
|
|
|
|
|
for (var i = 0; i < thLen; i++) {
|
|
|
|
|
th[i].classList.remove('dragover-th');
|
|
|
|
|
}
|
|
|
|
|
if (this.querySelector('[data-col=' + event.dataTransfer.getData('Text') + ']'))
|
|
|
|
|
this.querySelector('[data-col=' + event.dataTransfer.getData('Text') + ']').classList.remove('opacity05');
|
|
|
|
|
}, false);
|
|
|
|
|
tableHeader.addEventListener('drop', function(event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
if (dragEl.nodeName != 'TH')
|
|
|
|
|
return;
|
|
|
|
|
this.querySelector('[data-col=' + event.dataTransfer.getData('Text') + ']').remove();
|
|
|
|
|
dragEl.classList.remove('opacity05');
|
|
|
|
|
tableHeader.insertBefore(dragEl, event.target);
|
|
|
|
|
var th = tableHeader.getElementsByClassName('dragover-th');
|
|
|
|
|
var thLen = th.length;
|
|
|
|
|
for (var i = 0; i < thLen; i++) {
|
|
|
|
|
th[i].classList.remove('dragover-th');
|
|
|
|
|
}
|
2018-11-04 18:34:46 +00:00
|
|
|
|
if (document.getElementById(table + 'List')) {
|
|
|
|
|
document.getElementById(table + 'List').classList.add('opacity05');
|
|
|
|
|
saveCols(table);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
saveCols(table, this.parentNode.parentNode);
|
|
|
|
|
}
|
2018-10-22 20:03:45 +00:00
|
|
|
|
}, false);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-26 21:48:03 +00:00
|
|
|
|
function playlistMoveTrack(from, to) {
|
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_MOVE_TRACK","data": { "plist": app.current.search, "from": from, "to": to}});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 13:59:12 +00:00
|
|
|
|
function webSocketConnect() {
|
2018-09-29 17:52:37 +00:00
|
|
|
|
var wsUrl = getWsUrl();
|
|
|
|
|
socket = new WebSocket(wsUrl);
|
2014-01-16 17:32:20 +00:00
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
socket.onopen = function() {
|
2018-07-05 19:34:16 +00:00
|
|
|
|
console.log('connected');
|
2018-09-29 17:52:37 +00:00
|
|
|
|
showNotification('Connected to myMPD: ' + wsUrl, '', '', 'success');
|
2018-07-02 22:02:02 +00:00
|
|
|
|
modalConnectionError.hide();
|
2018-07-02 19:40:27 +00:00
|
|
|
|
appRoute();
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_STATE"}, parseState);
|
2014-01-16 17:32:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-22 01:11:45 +00:00
|
|
|
|
socket.onmessage = function got_packet(msg) {
|
2018-08-14 14:10:00 +00:00
|
|
|
|
if (msg.data === lastState || msg.data.length == 0)
|
2014-02-22 00:57:26 +00:00
|
|
|
|
return;
|
2018-07-05 21:56:42 +00:00
|
|
|
|
|
2018-05-17 22:10:57 +00:00
|
|
|
|
try {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var obj = JSON.parse(msg.data);
|
2018-05-17 22:10:57 +00:00
|
|
|
|
} catch(e) {
|
2018-07-05 19:34:16 +00:00
|
|
|
|
console.log('Invalid JSON data received: ' + msg.data);
|
2018-05-17 22:10:57 +00:00
|
|
|
|
}
|
2014-01-16 17:32:20 +00:00
|
|
|
|
|
|
|
|
|
switch (obj.type) {
|
2018-08-14 14:32:52 +00:00
|
|
|
|
case 'update_state':
|
2018-06-14 19:56:12 +00:00
|
|
|
|
parseState(obj);
|
|
|
|
|
break;
|
|
|
|
|
case 'disconnected':
|
2018-09-29 17:52:37 +00:00
|
|
|
|
showNotification('Lost connection to myMPD: ' + wsUrl, '', '', 'danger');
|
2018-06-14 19:56:12 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'update_queue':
|
2018-07-24 22:58:29 +00:00
|
|
|
|
if (app.current.app === 'Queue')
|
2018-06-14 19:56:12 +00:00
|
|
|
|
getQueue();
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_STATE"}, parseState);
|
2018-06-14 19:56:12 +00:00
|
|
|
|
break;
|
2018-08-09 22:52:58 +00:00
|
|
|
|
case 'update_options':
|
|
|
|
|
getSettings();
|
|
|
|
|
break;
|
|
|
|
|
case 'update_outputs':
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_OUTPUT_LIST"}, parseOutputs);
|
2018-08-09 22:52:58 +00:00
|
|
|
|
break;
|
2018-08-24 10:11:27 +00:00
|
|
|
|
case 'update_started':
|
2018-08-27 16:56:40 +00:00
|
|
|
|
updateDBstarted(false);
|
2018-08-24 10:11:27 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'update_database':
|
|
|
|
|
case 'update_finished':
|
|
|
|
|
updateDBfinished(obj.type);
|
|
|
|
|
break;
|
2018-10-11 19:50:26 +00:00
|
|
|
|
case 'update_volume':
|
|
|
|
|
parseVolume(obj);
|
|
|
|
|
break;
|
2018-10-14 21:38:34 +00:00
|
|
|
|
case 'update_stored_playlist':
|
|
|
|
|
if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'All')
|
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST","data": {"offset": app.current.page, "filter": app.current.filter}}, parsePlaylists);
|
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail')
|
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_CONTENT_LIST", "data": {"offset": app.current.page, "filter": app.current.filter, "uri": app.current.search}}, parsePlaylists);
|
|
|
|
|
break;
|
2018-06-14 19:56:12 +00:00
|
|
|
|
case 'error':
|
2018-07-05 19:34:16 +00:00
|
|
|
|
showNotification(obj.data, '', '', 'danger');
|
2018-08-22 16:29:47 +00:00
|
|
|
|
break;
|
2018-06-14 19:56:12 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
socket.onclose = function(){
|
|
|
|
|
console.log('disconnected');
|
2018-07-02 22:02:02 +00:00
|
|
|
|
modalConnectionError.show();
|
2018-06-14 19:56:12 +00:00
|
|
|
|
setTimeout(function() {
|
2018-07-29 22:19:35 +00:00
|
|
|
|
console.log('reconnect');
|
|
|
|
|
webSocketConnect();
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}, 3000);
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch(exception) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
alert('Error: ' + exception);
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 19:34:16 +00:00
|
|
|
|
function getWsUrl() {
|
2018-09-29 17:52:37 +00:00
|
|
|
|
var hostname = window.location.hostname;
|
|
|
|
|
var protocol = window.location.protocol;
|
|
|
|
|
var port = window.location.port;
|
|
|
|
|
|
|
|
|
|
if (protocol == 'https:')
|
|
|
|
|
protocol = 'wss://';
|
2018-07-05 21:56:42 +00:00
|
|
|
|
else
|
2018-09-29 17:52:37 +00:00
|
|
|
|
protocol = 'ws://';
|
2018-07-05 21:56:42 +00:00
|
|
|
|
|
2018-09-29 17:52:37 +00:00
|
|
|
|
var wsUrl = protocol + hostname + (port != '' ? ':' + port : '') + '/ws';
|
|
|
|
|
document.getElementById('wsUrl').innerText = wsUrl;
|
|
|
|
|
return wsUrl;
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseStats(obj) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
document.getElementById('mpdstats_artists').innerText = obj.data.artists;
|
|
|
|
|
document.getElementById('mpdstats_albums').innerText = obj.data.albums;
|
|
|
|
|
document.getElementById('mpdstats_songs').innerText = obj.data.songs;
|
2018-08-21 22:56:17 +00:00
|
|
|
|
document.getElementById('mpdstats_dbPlaytime').innerText = beautifyDuration(obj.data.dbPlaytime);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
document.getElementById('mpdstats_playtime').innerText = beautifyDuration(obj.data.playtime);
|
|
|
|
|
document.getElementById('mpdstats_uptime').innerText = beautifyDuration(obj.data.uptime);
|
2018-08-21 22:56:17 +00:00
|
|
|
|
var d = new Date(obj.data.dbUpdated * 1000);
|
|
|
|
|
document.getElementById('mpdstats_dbUpdated').innerText = d.toUTCString();
|
|
|
|
|
document.getElementById('mympdVersion').innerText = obj.data.mympdVersion;
|
|
|
|
|
document.getElementById('mpdVersion').innerText = obj.data.mpdVersion;
|
2018-11-22 22:15:25 +00:00
|
|
|
|
document.getElementById('libmpdclientVersion').innerText = obj.data.libmpdclientVersion;
|
2018-06-19 22:43:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
function toggleBtn(btn, state) {
|
|
|
|
|
var b = document.getElementById(btn);
|
2018-08-22 12:06:22 +00:00
|
|
|
|
if (!b)
|
|
|
|
|
return;
|
2018-07-03 21:46:07 +00:00
|
|
|
|
if (state == undefined)
|
|
|
|
|
state = b.classList.contains('active') ? 0 : 1;
|
2018-08-22 12:06:22 +00:00
|
|
|
|
|
2018-09-17 22:25:50 +00:00
|
|
|
|
if (state == 1 || state == true)
|
2018-06-28 22:51:24 +00:00
|
|
|
|
b.classList.add('active');
|
2018-08-22 12:06:22 +00:00
|
|
|
|
else
|
2018-06-28 22:51:24 +00:00
|
|
|
|
b.classList.remove('active');
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-25 20:03:33 +00:00
|
|
|
|
function filterCols(x) {
|
|
|
|
|
var tags = settings.tags.slice();
|
|
|
|
|
if (settings.featTags == false)
|
|
|
|
|
tags.push('Title');
|
|
|
|
|
tags.push('Duration');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
if (x == 'colsQueueCurrent' || x == 'colsBrowsePlaylistsDetail' || x == 'colsQueueLastPlayed')
|
2018-10-25 20:03:33 +00:00
|
|
|
|
tags.push('Pos');
|
2018-11-05 19:57:06 +00:00
|
|
|
|
else if (x == 'colsBrowseFilesystem')
|
2018-10-25 20:03:33 +00:00
|
|
|
|
tags.push('Type');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
if (x == 'colsQueueLastPlayed')
|
2018-11-13 23:50:30 +00:00
|
|
|
|
tags.push('LastPlayed');
|
2018-10-25 20:03:33 +00:00
|
|
|
|
|
|
|
|
|
var cols = [];
|
|
|
|
|
for (var i = 0; i < settings[x].length; i++) {
|
2018-11-05 19:57:06 +00:00
|
|
|
|
if (tags.includes(settings[x][i]))
|
2018-10-25 20:03:33 +00:00
|
|
|
|
cols.push(settings[x][i]);
|
|
|
|
|
}
|
|
|
|
|
settings[x] = cols;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 19:56:12 +00:00
|
|
|
|
function parseSettings(obj) {
|
2018-10-29 18:17:04 +00:00
|
|
|
|
settings = obj.data;
|
|
|
|
|
|
|
|
|
|
toggleBtn('btnRandom', settings.random);
|
|
|
|
|
toggleBtn('btnConsume', settings.consume);
|
|
|
|
|
toggleBtn('btnSingle', settings.single);
|
|
|
|
|
toggleBtn('btnRepeat', settings.repeat);
|
2018-09-20 16:59:29 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
if (settings.crossfade != undefined) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById('inputCrossfade').removeAttribute('disabled');
|
2018-10-29 18:17:04 +00:00
|
|
|
|
document.getElementById('inputCrossfade').value = settings.crossfade;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
document.getElementById('inputCrossfade').setAttribute('disabled', 'disabled');
|
|
|
|
|
}
|
2018-10-29 18:17:04 +00:00
|
|
|
|
if (settings.mixrampdb != undefined) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById('inputMixrampdb').removeAttribute('disabled');
|
2018-10-29 18:17:04 +00:00
|
|
|
|
document.getElementById('inputMixrampdb').value = settings.mixrampdb;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
document.getElementById('inputMixrampdb').setAttribute('disabled', 'disabled');
|
|
|
|
|
}
|
2018-10-29 18:17:04 +00:00
|
|
|
|
if (settings.mixrampdelay != undefined) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById('inputMixrampdelay').removeAttribute('disabled');
|
2018-10-29 18:17:04 +00:00
|
|
|
|
document.getElementById('inputMixrampdelay').value = settings.mixrampdelay;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
document.getElementById('inputMixrampdelay').setAttribute('disabled', 'disabled');
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
document.getElementById('selectReplaygain').value = settings.replaygain;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
|
|
|
|
var btnnotifyWeb = document.getElementById('btnnotifyWeb');
|
|
|
|
|
if (notificationsSupported()) {
|
2018-10-29 18:17:04 +00:00
|
|
|
|
if (settings.notificationWeb) {
|
|
|
|
|
toggleBtn('btnnotifyWeb', settings.notificationWeb);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
Notification.requestPermission(function (permission) {
|
|
|
|
|
if (!('permission' in Notification))
|
|
|
|
|
Notification.permission = permission;
|
|
|
|
|
if (permission === 'granted') {
|
|
|
|
|
toggleBtn('btnnotifyWeb', 1);
|
|
|
|
|
} else {
|
|
|
|
|
toggleBtn('btnnotifyWeb', 0);
|
2018-10-29 18:17:04 +00:00
|
|
|
|
settings.notificationWeb = true;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
toggleBtn('btnnotifyWeb', 0);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
btnnotifyWeb.setAttribute('disabled', 'disabled');
|
|
|
|
|
toggleBtn('btnnotifyWeb', 0);
|
|
|
|
|
}
|
2018-06-21 16:57:40 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
toggleBtn('btnnotifyPage', settings.notificationPage);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
2018-11-27 13:05:51 +00:00
|
|
|
|
var features = ["featStickers", "featSmartpls", "featPlaylists", "featTags", "featLocalplayer", "featSyscmds", "featCoverimage", "featAdvsearch"];
|
2018-08-21 19:28:13 +00:00
|
|
|
|
|
2018-10-25 20:03:33 +00:00
|
|
|
|
for (var j = 0; j < features.length; j++) {
|
|
|
|
|
var Els = document.getElementsByClassName(features[j]);
|
|
|
|
|
var ElsLen = Els.length;
|
2018-10-29 18:17:04 +00:00
|
|
|
|
var displayEl = settings[features[j]] == true ? '' : 'none';
|
2018-10-25 20:03:33 +00:00
|
|
|
|
for (var i = 0; i < ElsLen; i++)
|
|
|
|
|
Els[i].style.display = displayEl;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
if (settings.featTags == false) {
|
2018-10-25 20:03:33 +00:00
|
|
|
|
app.apps.Browse.active = 'Filesystem';
|
|
|
|
|
app.apps.Search.state = '0/filename/';
|
2018-10-29 18:39:55 +00:00
|
|
|
|
app.apps.Queue.state = '0/filename/';
|
2018-11-14 23:14:47 +00:00
|
|
|
|
settings.colsQueueCurrent = ["Pos", "Title", "Duration"];
|
|
|
|
|
settings.colsQueueLastPlayed = ["Pos", "Title", "LastPlayed"];
|
2018-10-29 18:39:55 +00:00
|
|
|
|
settings.colsSearch = ["Title", "Duration"];
|
|
|
|
|
settings.colsBrowseFilesystem = ["Type", "Title", "Duration"];
|
2018-11-04 18:34:46 +00:00
|
|
|
|
settings.colsBrowseDatabase = ["Track", "Title", "Duration"];
|
2018-11-05 21:49:57 +00:00
|
|
|
|
settings.colsPlayback = [];
|
2018-10-25 20:03:33 +00:00
|
|
|
|
}
|
2018-11-04 23:26:59 +00:00
|
|
|
|
else {
|
|
|
|
|
var pbtl = '';
|
|
|
|
|
for (var i = 0; i < settings.colsPlayback.length; i++) {
|
2018-11-05 19:57:06 +00:00
|
|
|
|
pbtl += '<div id="current' + settings.colsPlayback[i] + '" data-tag="' + settings.colsPlayback[i] + '" '+
|
|
|
|
|
'data-name="' + encodeURI((lastSongObj.data ? lastSongObj.data[settings.colsPlayback[i]] : '')) + '">' +
|
|
|
|
|
'<small>' + settings.colsPlayback[i] + '</small>' +
|
|
|
|
|
'<h4';
|
2018-11-04 23:26:59 +00:00
|
|
|
|
if (settings.browsetags.includes(settings.colsPlayback[i]))
|
2018-11-05 19:57:06 +00:00
|
|
|
|
pbtl += ' class="clickable"';
|
|
|
|
|
pbtl += '>' + (lastSongObj.data ? lastSongObj.data[settings.colsPlayback[i]] : '') + '</h4></div>';
|
2018-11-04 23:26:59 +00:00
|
|
|
|
}
|
|
|
|
|
document.getElementById('cardPlaybackTags').innerHTML = pbtl;
|
|
|
|
|
}
|
2018-10-25 20:03:33 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
if (settings.mixramp == true)
|
2018-08-21 19:28:13 +00:00
|
|
|
|
document.getElementsByClassName('mixramp')[0].style.display = '';
|
2018-09-30 01:03:33 +00:00
|
|
|
|
else
|
2018-08-21 19:28:13 +00:00
|
|
|
|
document.getElementsByClassName('mixramp')[0].style.display = 'none';
|
2018-10-25 20:27:54 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
if (!settings.tags.includes('AlbumArtist') && settings.featTags) {
|
|
|
|
|
if (settings.tags.includes('Artist'))
|
2018-10-25 20:27:54 +00:00
|
|
|
|
app.apps.Browse.tabs.Database.active = 'Artist';
|
|
|
|
|
else
|
|
|
|
|
app.apps.Browse.tabs.Database.active = settings.tags[0];
|
|
|
|
|
}
|
2018-09-30 01:03:33 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
document.getElementById('selectJukeboxMode').value = settings.jukeboxMode;
|
|
|
|
|
document.getElementById('inputJukeboxQueueLength').value = settings.jukeboxQueueLength;
|
|
|
|
|
if (settings.jukeboxMode == 0 || settings.jukeboxMode == 2) {
|
2018-09-30 22:18:55 +00:00
|
|
|
|
document.getElementById('inputJukeboxQueueLength').setAttribute('disabled', 'disabled');
|
|
|
|
|
document.getElementById('selectJukeboxPlaylist').setAttribute('disabled', 'disabled');
|
|
|
|
|
}
|
2018-10-29 18:17:04 +00:00
|
|
|
|
else if (settings.jukeboxMode == 1) {
|
2018-09-30 22:18:55 +00:00
|
|
|
|
document.getElementById('inputJukeboxQueueLength').removeAttribute('disabled');
|
|
|
|
|
document.getElementById('selectJukeboxPlaylist').removeAttribute('disabled');
|
|
|
|
|
}
|
2018-08-21 19:28:13 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
if (settings.featPlaylists) {
|
2018-10-25 20:03:33 +00:00
|
|
|
|
playlistEl = 'selectJukeboxPlaylist';
|
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST", "data": {"offset": 0, "filter": "-"}}, getAllPlaylists);
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementById('selectJukeboxPlaylist').innerHTML = '<option>Database</option>';
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-25 20:27:54 +00:00
|
|
|
|
settings.tags.sort();
|
2018-10-29 18:39:55 +00:00
|
|
|
|
settings.searchtags.sort();
|
|
|
|
|
settings.browsetags.sort();
|
2018-10-25 20:03:33 +00:00
|
|
|
|
filterCols('colsSearch');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
filterCols('colsQueueCurrent');
|
|
|
|
|
filterCols('colsQueueLastPlayed');
|
2018-10-25 20:03:33 +00:00
|
|
|
|
filterCols('colsBrowsePlaylistsDetail');
|
|
|
|
|
filterCols('colsBrowseFilesystem');
|
2018-11-04 18:34:46 +00:00
|
|
|
|
filterCols('colsBrowseDatabase');
|
2018-11-04 23:26:59 +00:00
|
|
|
|
filterCols('colsPlayback');
|
2018-09-20 16:59:29 +00:00
|
|
|
|
|
2018-10-29 19:41:04 +00:00
|
|
|
|
if (settings.featLocalplayer) {
|
2018-10-29 18:17:04 +00:00
|
|
|
|
if (settings.streamurl == '') {
|
|
|
|
|
settings.mpdstream = 'http://';
|
|
|
|
|
if (settings.mpdhost == '127.0.0.1' || settings.mpdhost == 'localhost')
|
|
|
|
|
settings.mpdstream += window.location.hostname;
|
|
|
|
|
else
|
|
|
|
|
settings.mpdstream += settings.mpdhost;
|
|
|
|
|
settings.mpdstream += ':' + settings.streamport + '/';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
settings.mpdstream = settings.streamurl;
|
|
|
|
|
}
|
2018-09-11 18:59:22 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
addTagList('BrowseDatabaseByTagDropdown', 'browsetags');
|
|
|
|
|
addTagList('searchqueuetags', 'searchtags');
|
|
|
|
|
addTagList('searchtags', 'searchtags');
|
2018-10-10 21:40:04 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
for (var i = 0; i < settings.tags.length; i++)
|
|
|
|
|
app.apps.Browse.tabs.Database.views[settings.tags[i]] = { "state": "0/-/", "scrollPos": 0 };
|
|
|
|
|
|
|
|
|
|
if (settings.featSyscmds) {
|
2018-11-07 23:52:28 +00:00
|
|
|
|
var mainMenuDropdown = document.getElementById('mainMenuDropdown');
|
2018-10-29 18:17:04 +00:00
|
|
|
|
var syscmdsList = '';
|
|
|
|
|
var syscmdsListLen = settings.syscmds.length;
|
|
|
|
|
if (syscmdsListLen > 0) {
|
|
|
|
|
syscmdsList = '<div class="dropdown-divider"></div>';
|
2018-11-07 23:52:28 +00:00
|
|
|
|
for (var i = 0; i < syscmdsListLen; i++) {
|
2018-10-29 18:17:04 +00:00
|
|
|
|
syscmdsList += '<a class="dropdown-item text-light bg-dark" href="#" data-href=\'{"cmd": "execSyscmd", "options": ["' +
|
|
|
|
|
settings.syscmds[i] + '"]}\'>' + settings.syscmds[i] + '</a>';
|
2018-11-07 23:52:28 +00:00
|
|
|
|
}
|
2018-10-29 18:17:04 +00:00
|
|
|
|
}
|
|
|
|
|
document.getElementById('syscmds').innerHTML = syscmdsList;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
document.getElementById('syscmds').innerHTML = '';
|
2018-11-07 23:52:28 +00:00
|
|
|
|
dropdownMainMenu = new Dropdown(document.getElementById('mainMenu'));
|
2018-10-22 20:03:45 +00:00
|
|
|
|
|
2018-11-14 23:14:47 +00:00
|
|
|
|
setCols('QueueCurrent');
|
2018-10-22 22:20:57 +00:00
|
|
|
|
setCols('Search');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
setCols('QueueLastPlayed');
|
2018-10-22 22:20:57 +00:00
|
|
|
|
setCols('BrowseFilesystem');
|
|
|
|
|
setCols('BrowsePlaylistsDetail');
|
2018-11-04 18:34:46 +00:00
|
|
|
|
setCols('BrowseDatabase', '.tblAlbumTitles');
|
2018-11-05 19:57:06 +00:00
|
|
|
|
setCols('Playback');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
if (app.current.app == 'Queue' && app.current.tab == 'Current')
|
2018-10-22 22:20:57 +00:00
|
|
|
|
getQueue();
|
2018-11-14 23:14:47 +00:00
|
|
|
|
else if (app.current.app == 'Queue' && app.current.tab == 'LastPlayed')
|
2018-11-12 23:48:29 +00:00
|
|
|
|
appRoute();
|
2018-10-22 22:20:57 +00:00
|
|
|
|
else if (app.current.app == 'Search')
|
|
|
|
|
appRoute();
|
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Filesystem')
|
|
|
|
|
appRoute();
|
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail')
|
|
|
|
|
appRoute();
|
2018-11-04 18:34:46 +00:00
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Database' && app.current.search != '')
|
|
|
|
|
appRoute();
|
2018-10-22 20:03:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-04 18:34:46 +00:00
|
|
|
|
function setCols(table, className) {
|
2018-10-22 20:03:45 +00:00
|
|
|
|
var tagChks = '';
|
2018-10-22 22:20:57 +00:00
|
|
|
|
var tags = settings.tags.slice();
|
2018-10-25 20:03:33 +00:00
|
|
|
|
if (settings.featTags == false)
|
|
|
|
|
tags.push('Title');
|
2018-10-22 20:03:45 +00:00
|
|
|
|
tags.push('Duration');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
if (table == 'QueueCurrent' || table == 'BrowsePlaylistsDetail' || table == 'QueueLastPlayed')
|
2018-10-22 20:03:45 +00:00
|
|
|
|
tags.push('Pos');
|
2018-10-25 20:03:33 +00:00
|
|
|
|
if (table == 'BrowseFilesystem')
|
|
|
|
|
tags.push('Type');
|
2018-11-14 23:14:47 +00:00
|
|
|
|
if (table == 'QueueLastPlayed')
|
2018-11-13 23:50:30 +00:00
|
|
|
|
tags.push('LastPlayed');
|
2018-10-22 20:03:45 +00:00
|
|
|
|
|
2018-10-25 20:27:54 +00:00
|
|
|
|
tags.sort();
|
|
|
|
|
|
2018-10-22 20:03:45 +00:00
|
|
|
|
for (var i = 0; i < tags.length; i++) {
|
2018-11-05 19:57:06 +00:00
|
|
|
|
if (table == 'Playback' && tags[i] == 'Title')
|
|
|
|
|
continue;
|
2018-10-22 20:03:45 +00:00
|
|
|
|
tagChks += '<div class="form-check">' +
|
|
|
|
|
'<input class="form-check-input" type="checkbox" value="1" name="' + tags[i] + '"';
|
|
|
|
|
if (settings['cols' + table].includes(tags[i]))
|
|
|
|
|
tagChks += 'checked';
|
|
|
|
|
tagChks += '>' +
|
|
|
|
|
'<label class="form-check-label text-light" for="' + tags[i] + '"> ' + tags[i] + '</label>' +
|
|
|
|
|
'</div>';
|
|
|
|
|
}
|
|
|
|
|
document.getElementById(table + 'ColsDropdown').firstChild.innerHTML = tagChks;
|
|
|
|
|
|
2018-11-27 13:05:51 +00:00
|
|
|
|
var sort = document.getElementById('SearchList').getAttribute('data-sort');
|
|
|
|
|
if (sort == '') {
|
|
|
|
|
if (settings.featTags)
|
|
|
|
|
sort = 'Title';
|
|
|
|
|
else
|
|
|
|
|
sort = 'Filename';
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-05 19:57:06 +00:00
|
|
|
|
if (table != 'Playback') {
|
|
|
|
|
var heading = '';
|
|
|
|
|
for (var i = 0; i < settings['cols' + table].length; i++) {
|
|
|
|
|
var h = settings['cols' + table][i];
|
|
|
|
|
heading += '<th draggable="true" data-col="' + h + '">';
|
|
|
|
|
if (h == 'Track' || h == 'Pos')
|
|
|
|
|
h = '#';
|
2018-11-27 13:05:51 +00:00
|
|
|
|
heading += h;
|
|
|
|
|
|
|
|
|
|
if (table == 'Search' && h == sort ) {
|
|
|
|
|
var sortdesc = false;
|
|
|
|
|
if (sort.indexOf('-') == 0) {
|
|
|
|
|
sortdesc = true;
|
|
|
|
|
sort = sort.substring(1);
|
|
|
|
|
}
|
|
|
|
|
heading += '<span class="sort-dir material-icons pull-right">' + (sortdesc == true ? 'arrow_drop_up' : 'arrow_drop_down') + '</span>';
|
|
|
|
|
}
|
|
|
|
|
heading += '</th>';
|
2018-11-05 19:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
heading += '<th></th>';
|
2018-11-27 13:05:51 +00:00
|
|
|
|
|
2018-11-05 19:57:06 +00:00
|
|
|
|
if (className == undefined)
|
|
|
|
|
document.getElementById(table + 'List').getElementsByTagName('tr')[0].innerHTML = heading;
|
|
|
|
|
else {
|
|
|
|
|
var tbls = document.querySelectorAll(className);
|
|
|
|
|
for (var i = 0; i < tbls.length; i++) {
|
|
|
|
|
tbls[i].getElementsByTagName('tr')[0].innerHTML = heading;
|
|
|
|
|
}
|
2018-11-04 18:34:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-21 17:28:07 +00:00
|
|
|
|
function getSettings() {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_SETTINGS_GET"}, parseSettings);
|
2018-06-21 17:28:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-04 18:34:46 +00:00
|
|
|
|
function saveCols(table, tableEl) {
|
2018-10-22 20:03:45 +00:00
|
|
|
|
var colInputs = document.getElementById(table + 'ColsDropdown').firstChild.getElementsByTagName('input');
|
2018-11-04 18:34:46 +00:00
|
|
|
|
var header;
|
|
|
|
|
if (tableEl == undefined)
|
|
|
|
|
header = document.getElementById(table + 'List').getElementsByTagName('tr')[0];
|
|
|
|
|
else if (typeof(tableEl) == 'string')
|
|
|
|
|
header = document.querySelector(tableEl).getElementsByTagName('tr')[0];
|
|
|
|
|
else
|
|
|
|
|
header = tableEl.getElementsByTagName('tr')[0];
|
2018-10-22 20:03:45 +00:00
|
|
|
|
|
|
|
|
|
for (var i = 0; i < colInputs.length; i++) {
|
|
|
|
|
var th = header.querySelector('[data-col=' + colInputs[i].name + ']');
|
|
|
|
|
if (colInputs[i].checked == false) {
|
|
|
|
|
if (th)
|
|
|
|
|
th.remove();
|
|
|
|
|
}
|
|
|
|
|
else if (!th) {
|
|
|
|
|
th = document.createElement('th');
|
|
|
|
|
th.innerText = colInputs[i].name;
|
|
|
|
|
th.setAttribute('data-col', colInputs[i].name);
|
|
|
|
|
header.appendChild(th);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cols = {"cmd": "MPD_API_COLS_SAVE", "data": {"table": "cols" + table, "cols": []}};
|
|
|
|
|
var ths = header.getElementsByTagName('th');
|
|
|
|
|
for (var i = 0; i < ths.length; i++) {
|
|
|
|
|
var name = ths[i].getAttribute('data-col');
|
|
|
|
|
if (name)
|
|
|
|
|
cols.data.cols.push(name);
|
|
|
|
|
}
|
2018-10-22 22:20:57 +00:00
|
|
|
|
sendAPI(cols, getSettings);
|
2018-10-22 20:03:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-05 19:57:06 +00:00
|
|
|
|
function saveColsPlayback(table) {
|
|
|
|
|
var colInputs = document.getElementById(table + 'ColsDropdown').firstChild.getElementsByTagName('input');
|
|
|
|
|
var header = document.getElementById('cardPlaybackTags');
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < colInputs.length; i++) {
|
|
|
|
|
var th = document.getElementById('current' + colInputs[i].name);
|
|
|
|
|
if (colInputs[i].checked == false) {
|
|
|
|
|
if (th)
|
|
|
|
|
th.remove();
|
|
|
|
|
}
|
|
|
|
|
else if (!th) {
|
|
|
|
|
th = document.createElement('div');
|
|
|
|
|
th.innerHTML = '<small>' + colInputs[i].name + '</small><h4></h4>';
|
|
|
|
|
th.setAttribute('id', 'current'+ colInputs[i].name);
|
|
|
|
|
th.setAttribute('data-tag', colInputs[i].name);
|
|
|
|
|
header.appendChild(th);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cols = {"cmd": "MPD_API_COLS_SAVE", "data": {"table": "cols" + table, "cols": []}};
|
|
|
|
|
var ths = header.getElementsByTagName('div');
|
|
|
|
|
for (var i = 0; i < ths.length; i++) {
|
|
|
|
|
var name = ths[i].getAttribute('data-tag');
|
|
|
|
|
if (name)
|
|
|
|
|
cols.data.cols.push(name);
|
|
|
|
|
}
|
|
|
|
|
sendAPI(cols, getSettings);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-09 22:52:58 +00:00
|
|
|
|
function parseOutputs(obj) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var btns = '';
|
|
|
|
|
var outputsLen = obj.data.outputs.length;
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < outputsLen; i++) {
|
2018-08-27 19:34:21 +00:00
|
|
|
|
btns += '<button id="btnOutput' + obj.data.outputs[i].id +'" data-output-id="' + obj.data.outputs[i].id + '" class="btn btn-secondary btn-block';
|
2018-08-06 18:57:42 +00:00
|
|
|
|
if (obj.data.outputs[i].state == 1)
|
|
|
|
|
btns += ' active';
|
|
|
|
|
btns += '"><span class="material-icons float-left">volume_up</span> ' + obj.data.outputs[i].name + '</button>';
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}
|
2018-06-29 06:52:32 +00:00
|
|
|
|
domCache.outputs.innerHTML = btns;
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-14 14:10:00 +00:00
|
|
|
|
function setCounter(currentSongId, totalTime, elapsedTime) {
|
|
|
|
|
currentSong.totalTime = totalTime;
|
|
|
|
|
currentSong.elapsedTime = elapsedTime;
|
|
|
|
|
currentSong.currentSongId = currentSongId;
|
|
|
|
|
var total_minutes = Math.floor(totalTime / 60);
|
|
|
|
|
var total_seconds = totalTime - total_minutes * 60;
|
|
|
|
|
var elapsed_minutes = Math.floor(elapsedTime / 60);
|
|
|
|
|
var elapsed_seconds = elapsedTime - elapsed_minutes * 60;
|
|
|
|
|
|
2018-11-22 23:44:55 +00:00
|
|
|
|
domCache.progressBar.value = Math.floor(1000 * elapsedTime / totalTime);
|
2018-08-14 14:10:00 +00:00
|
|
|
|
|
|
|
|
|
var counterText = elapsed_minutes + ":" +
|
|
|
|
|
(elapsed_seconds < 10 ? '0' : '') + elapsed_seconds + " / " +
|
|
|
|
|
total_minutes + ":" + (total_seconds < 10 ? '0' : '') + total_seconds;
|
|
|
|
|
domCache.counter.innerText = counterText;
|
|
|
|
|
|
|
|
|
|
//Set playing track in queue view
|
|
|
|
|
if (lastState) {
|
2018-10-22 22:20:57 +00:00
|
|
|
|
if (lastState.data.currentSongId != currentSongId) {
|
|
|
|
|
var tr = document.getElementById('queueTrackId' + lastState.data.currentSongId);
|
|
|
|
|
if (tr) {
|
|
|
|
|
var durationTd = tr.querySelector('[data-col=Duration]');
|
|
|
|
|
if (durationTd)
|
|
|
|
|
durationTd.innerText = tr.getAttribute('data-duration');
|
|
|
|
|
var posTd = tr.querySelector('[data-col=Pos]');
|
|
|
|
|
if (posTd) {
|
|
|
|
|
posTd.classList.remove('material-icons');
|
|
|
|
|
posTd.innerText = tr.getAttribute('data-songpos');
|
|
|
|
|
}
|
|
|
|
|
tr.classList.remove('font-weight-bold');
|
2018-10-22 20:03:45 +00:00
|
|
|
|
}
|
2018-08-14 14:10:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var tr = document.getElementById('queueTrackId' + currentSongId);
|
|
|
|
|
if (tr) {
|
2018-10-22 20:03:45 +00:00
|
|
|
|
var durationTd = tr.querySelector('[data-col=Duration]');
|
|
|
|
|
if (durationTd)
|
|
|
|
|
durationTd.innerText = counterText;
|
|
|
|
|
var posTd = tr.querySelector('[data-col=Pos]');
|
|
|
|
|
if (posTd) {
|
2018-10-22 22:20:57 +00:00
|
|
|
|
if (!posTd.classList.contains('material-icons')) {
|
|
|
|
|
posTd.classList.add('material-icons');
|
|
|
|
|
posTd.innerText = 'play_arrow';
|
|
|
|
|
}
|
2018-10-22 20:03:45 +00:00
|
|
|
|
}
|
2018-08-14 14:10:00 +00:00
|
|
|
|
tr.classList.add('font-weight-bold');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (progressTimer)
|
|
|
|
|
clearTimeout(progressTimer);
|
|
|
|
|
if (playstate == 'play') {
|
|
|
|
|
progressTimer = setTimeout(function() {
|
|
|
|
|
currentSong.elapsedTime ++;
|
|
|
|
|
setCounter(currentSong.currentSongId, currentSong.totalTime, currentSong.elapsedTime);
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 19:56:12 +00:00
|
|
|
|
function parseState(obj) {
|
2018-08-14 14:10:00 +00:00
|
|
|
|
if (JSON.stringify(obj) === JSON.stringify(lastState))
|
2018-06-25 22:41:44 +00:00
|
|
|
|
return;
|
2018-06-14 19:56:12 +00:00
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
//Set playstate
|
2018-06-29 06:52:32 +00:00
|
|
|
|
if (obj.data.state == 1) {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
for (var i = 0; i < domCache.btnsPlayLen; i++)
|
2018-08-18 13:23:02 +00:00
|
|
|
|
domCache.btnsPlay[i].innerText = 'play_arrow';
|
2018-06-28 22:51:24 +00:00
|
|
|
|
playstate = 'stop';
|
2018-06-29 06:52:32 +00:00
|
|
|
|
} else if (obj.data.state == 2) {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
for (var i = 0; i < domCache.btnsPlayLen; i++)
|
2018-08-18 13:23:02 +00:00
|
|
|
|
domCache.btnsPlay[i].innerText = 'pause';
|
2018-06-28 22:51:24 +00:00
|
|
|
|
playstate = 'play';
|
|
|
|
|
} else {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
for (var i = 0; i < domCache.btnsPlayLen; i++)
|
2018-08-18 13:23:02 +00:00
|
|
|
|
domCache.btnsPlay[i].innerText = 'play_arrow';
|
2018-06-28 22:51:24 +00:00
|
|
|
|
playstate = 'pause';
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-17 22:25:50 +00:00
|
|
|
|
if (obj.data.nextSongPos == -1 && settings.jukeboxMode == false)
|
2018-06-28 22:51:24 +00:00
|
|
|
|
domCache.btnNext.setAttribute('disabled','disabled');
|
|
|
|
|
else
|
|
|
|
|
domCache.btnNext.removeAttribute('disabled');
|
|
|
|
|
|
2018-08-14 14:10:00 +00:00
|
|
|
|
if (obj.data.songPos <= 0)
|
2018-06-28 22:51:24 +00:00
|
|
|
|
domCache.btnPrev.setAttribute('disabled','disabled');
|
|
|
|
|
else
|
|
|
|
|
domCache.btnPrev.removeAttribute('disabled');
|
|
|
|
|
|
2018-08-14 14:10:00 +00:00
|
|
|
|
if (obj.data.queueLength == 0)
|
2018-08-21 22:02:22 +00:00
|
|
|
|
for (var i = 0; i < domCache.btnsPlayLen; i++)
|
2018-08-18 13:23:02 +00:00
|
|
|
|
domCache.btnsPlay[i].setAttribute('disabled','disabled');
|
2018-06-28 22:51:24 +00:00
|
|
|
|
else
|
2018-08-21 22:02:22 +00:00
|
|
|
|
for (var i = 0; i < domCache.btnsPlayLen; i++)
|
2018-08-18 13:23:02 +00:00
|
|
|
|
domCache.btnsPlay[i].removeAttribute('disabled');
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
2018-11-11 22:22:48 +00:00
|
|
|
|
domCache.badgeQueueItems.innerText = obj.data.queueLength;
|
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
//Set volume
|
2018-10-11 19:50:26 +00:00
|
|
|
|
parseVolume(obj);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
|
|
|
|
//Set play counters
|
2018-08-14 14:10:00 +00:00
|
|
|
|
setCounter(obj.data.currentSongId, obj.data.totalTime, obj.data.elapsedTime);
|
2018-08-06 18:33:52 +00:00
|
|
|
|
|
2018-08-14 14:10:00 +00:00
|
|
|
|
//Get current song
|
2018-10-08 20:58:25 +00:00
|
|
|
|
if (lastState && lastState.data.currentSongId != obj.data.currentSongId)
|
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_CURRENT_SONG"}, songChange);
|
2018-08-06 18:33:52 +00:00
|
|
|
|
//clear playback card if not playing
|
2018-08-14 14:10:00 +00:00
|
|
|
|
if (obj.data.songPos == '-1') {
|
2018-11-04 23:26:59 +00:00
|
|
|
|
domCache.currentTitle.innerText = 'Not playing';
|
2018-08-21 22:02:22 +00:00
|
|
|
|
domCache.currentCover.style.backgroundImage = '';
|
2018-11-04 23:26:59 +00:00
|
|
|
|
var pb = document.getElementById('cardPlaybackTags').getElementsByTagName('h4');
|
|
|
|
|
for (var i = 0; i < pb.length; i++)
|
|
|
|
|
pb[i].innerText = '';
|
2018-08-06 18:33:52 +00:00
|
|
|
|
}
|
2018-11-12 23:48:29 +00:00
|
|
|
|
|
2018-11-28 16:57:55 +00:00
|
|
|
|
if (app.current.app == 'Queue' && app.current.tab == 'LastPlayed')
|
2018-11-12 23:48:29 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_LAST_PLAYED", "data": {"offset": app.current.page}}, parseLastPlayed);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
2018-08-14 14:10:00 +00:00
|
|
|
|
lastState = obj;
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-11 19:50:26 +00:00
|
|
|
|
function parseVolume(obj) {
|
|
|
|
|
if (obj.data.volume == -1) {
|
|
|
|
|
domCache.volumePrct.innerText = 'Volumecontrol disabled';
|
|
|
|
|
domCache.volumeControl.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
domCache.volumeControl.classList.remove('hide');
|
|
|
|
|
domCache.volumePrct.innerText = obj.data.volume + ' %';
|
|
|
|
|
if (obj.data.volume == 0)
|
2018-11-06 23:59:44 +00:00
|
|
|
|
domCache.volumeMenu.innerText = 'volume_off';
|
2018-10-11 19:50:26 +00:00
|
|
|
|
else if (obj.data.volume < 50)
|
2018-11-06 23:59:44 +00:00
|
|
|
|
domCache.volumeMenu.innerText = 'volume_down';
|
2018-10-11 19:50:26 +00:00
|
|
|
|
else
|
2018-11-06 23:59:44 +00:00
|
|
|
|
domCache.volumeMenu.innerText = 'volume_up';
|
2018-10-11 19:50:26 +00:00
|
|
|
|
}
|
|
|
|
|
domCache.volumeBar.value = obj.data.volume;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 19:56:12 +00:00
|
|
|
|
function getQueue() {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
if (app.current.search.length >= 2)
|
2018-09-03 18:02:12 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_SEARCH", "data": {"filter": app.current.filter, "offset": app.current.page, "searchstr": app.current.search}}, parseQueue);
|
2018-10-10 21:40:04 +00:00
|
|
|
|
else
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_LIST", "data": {"offset": app.current.page}}, parseQueue);
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseQueue(obj) {
|
2018-08-21 22:56:17 +00:00
|
|
|
|
if (typeof(obj.totalTime) != undefined && obj.totalTime > 0 && obj.totalEntities <= settings.maxElementsPerPage )
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('cardFooterQueue').innerText = obj.totalEntities + ' ' + (obj.totalEntities > 1 ? 'Songs' : 'Song') + ' – ' + beautifyDuration(obj.totalTime);
|
2018-06-26 22:46:29 +00:00
|
|
|
|
else if (obj.totalEntities > 0)
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('cardFooterQueue').innerText = obj.totalEntities + ' ' + (obj.totalEntities > 1 ? 'Songs' : 'Song');
|
2018-06-26 22:46:29 +00:00
|
|
|
|
else
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('cardFooterQueue').innerText = '';
|
2018-06-26 22:46:29 +00:00
|
|
|
|
|
2018-06-27 23:19:09 +00:00
|
|
|
|
var nrItems = obj.data.length;
|
2018-11-14 23:14:47 +00:00
|
|
|
|
var table = document.getElementById('QueueCurrentList');
|
2018-08-14 14:10:00 +00:00
|
|
|
|
table.setAttribute('data-version', obj.queueVersion);
|
2018-07-15 21:49:57 +00:00
|
|
|
|
var tbody = table.getElementsByTagName('tbody')[0];
|
2018-06-26 22:46:29 +00:00
|
|
|
|
var tr = tbody.getElementsByTagName('tr');
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < nrItems; i++) {
|
2018-10-22 20:03:45 +00:00
|
|
|
|
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;
|
2018-11-15 20:57:00 +00:00
|
|
|
|
obj.data[i].Pos++;
|
2018-06-26 22:46:29 +00:00
|
|
|
|
var row = document.createElement('tr');
|
2018-07-22 23:07:25 +00:00
|
|
|
|
row.setAttribute('draggable','true');
|
2018-06-27 23:19:09 +00:00
|
|
|
|
row.setAttribute('data-trackid', obj.data[i].id);
|
|
|
|
|
row.setAttribute('id','queueTrackId' + obj.data[i].id);
|
2018-11-15 20:57:00 +00:00
|
|
|
|
row.setAttribute('data-songpos', obj.data[i].Pos);
|
2018-10-22 20:03:45 +00:00
|
|
|
|
row.setAttribute('data-duration', obj.data[i].Duration);
|
2018-07-09 17:28:28 +00:00
|
|
|
|
row.setAttribute('data-uri', obj.data[i].uri);
|
2018-10-22 20:03:45 +00:00
|
|
|
|
var tds = '';
|
2018-11-14 23:14:47 +00:00
|
|
|
|
for (var c = 0; c < settings.colsQueueCurrent.length; c++) {
|
|
|
|
|
tds += '<td data-col="' + settings.colsQueueCurrent[c] + '">' + obj.data[i][settings.colsQueueCurrent[c]] + '</td>';
|
2018-10-22 20:03:45 +00:00
|
|
|
|
}
|
2018-10-22 22:20:57 +00:00
|
|
|
|
tds += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
2018-10-22 20:03:45 +00:00
|
|
|
|
row.innerHTML = tds;
|
2018-06-27 23:19:09 +00:00
|
|
|
|
if (i < tr.length)
|
|
|
|
|
tr[i].replaceWith(row);
|
2018-06-26 22:46:29 +00:00
|
|
|
|
else
|
|
|
|
|
tbody.append(row);
|
|
|
|
|
}
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var trLen = tr.length - 1;
|
|
|
|
|
for (var i = trLen; i >= nrItems; i --) {
|
2018-06-26 22:46:29 +00:00
|
|
|
|
tr[i].remove();
|
|
|
|
|
}
|
2018-07-22 23:07:25 +00:00
|
|
|
|
|
2018-11-14 23:14:47 +00:00
|
|
|
|
var colspan = settings['colsQueueCurrent'].length;
|
2018-11-12 23:48:29 +00:00
|
|
|
|
colspan--;
|
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
if (obj.type == 'queuesearch' && nrItems == 0)
|
2018-06-26 22:46:29 +00:00
|
|
|
|
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
2018-11-12 23:48:29 +00:00
|
|
|
|
'<td colspan="' + colspan + '">No results, please refine your search!</td></tr>';
|
2018-06-28 22:51:24 +00:00
|
|
|
|
else if (obj.type == 'queue' && nrItems == 0)
|
2018-06-26 22:46:29 +00:00
|
|
|
|
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
2018-11-12 23:48:29 +00:00
|
|
|
|
'<td colspan="' + colspan + '">Empty queue</td></tr>';
|
2018-06-26 22:46:29 +00:00
|
|
|
|
|
2018-11-28 14:23:05 +00:00
|
|
|
|
setPagination(obj.totalEntities, obj.returnedEntities);
|
2018-11-14 23:14:47 +00:00
|
|
|
|
document.getElementById('QueueCurrentList').classList.remove('opacity05');
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-12 23:48:29 +00:00
|
|
|
|
function parseLastPlayed(obj) {
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('cardFooterQueue').innerText = obj.totalEntities + ' Songs';
|
2018-11-12 23:48:29 +00:00
|
|
|
|
var nrItems = obj.data.length;
|
2018-11-14 23:14:47 +00:00
|
|
|
|
var table = document.getElementById('QueueLastPlayedList');
|
2018-11-12 23:48:29 +00:00
|
|
|
|
table.setAttribute('data-version', obj.queueVersion);
|
|
|
|
|
var tbody = table.getElementsByTagName('tbody')[0];
|
|
|
|
|
var tr = tbody.getElementsByTagName('tr');
|
|
|
|
|
for (var i = 0; i < nrItems; i++) {
|
|
|
|
|
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;
|
2018-11-13 23:50:30 +00:00
|
|
|
|
obj.data[i].LastPlayed = new Date(obj.data[i].LastPlayed * 1000).toUTCString();
|
2018-11-12 23:48:29 +00:00
|
|
|
|
var row = document.createElement('tr');
|
|
|
|
|
row.setAttribute('data-songpos', (obj.data[i].Pos + 1));
|
|
|
|
|
row.setAttribute('data-uri', obj.data[i].uri);
|
2018-11-15 21:15:15 +00:00
|
|
|
|
row.setAttribute('data-name', obj.data[i].Title);
|
|
|
|
|
row.setAttribute('data-type', 'song');
|
2018-11-12 23:48:29 +00:00
|
|
|
|
var tds = '';
|
2018-11-14 23:14:47 +00:00
|
|
|
|
for (var c = 0; c < settings.colsQueueLastPlayed.length; c++) {
|
|
|
|
|
tds += '<td data-col="' + settings.colsQueueLastPlayed[c] + '">' + obj.data[i][settings.colsQueueLastPlayed[c]] + '</td>';
|
2018-11-12 23:48:29 +00:00
|
|
|
|
}
|
|
|
|
|
tds += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
|
|
|
|
row.innerHTML = tds;
|
|
|
|
|
if (i < tr.length)
|
|
|
|
|
tr[i].replaceWith(row);
|
|
|
|
|
else
|
|
|
|
|
tbody.append(row);
|
|
|
|
|
}
|
|
|
|
|
var trLen = tr.length - 1;
|
|
|
|
|
for (var i = trLen; i >= nrItems; i --) {
|
|
|
|
|
tr[i].remove();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-14 23:14:47 +00:00
|
|
|
|
var colspan = settings['colsQueueLastPlayed'].length;
|
2018-11-12 23:48:29 +00:00
|
|
|
|
colspan--;
|
|
|
|
|
|
|
|
|
|
if (nrItems == 0)
|
|
|
|
|
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
|
|
|
|
'<td colspan="' + colspan + '">Empty list</td></tr>';
|
|
|
|
|
|
2018-11-28 14:23:05 +00:00
|
|
|
|
setPagination(obj.totalEntities, obj.returnedEntities);
|
2018-11-14 23:14:47 +00:00
|
|
|
|
document.getElementById('QueueLastPlayedList').classList.remove('opacity05');
|
2018-11-12 23:48:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 19:56:12 +00:00
|
|
|
|
function parseSearch(obj) {
|
2018-11-28 14:23:05 +00:00
|
|
|
|
if (obj.totalEntities > -1) {
|
|
|
|
|
document.getElementById('panel-heading-search').innerText = obj.totalEntities + ' Songs found';
|
|
|
|
|
document.getElementById('cardFooterSearch').innerText = obj.totalEntities + ' Songs found';
|
|
|
|
|
}
|
2018-11-28 14:41:13 +00:00
|
|
|
|
else if (obj.returnedEntities + app.current.page < settings.maxElementsPerPage) {
|
2018-11-28 14:23:05 +00:00
|
|
|
|
document.getElementById('panel-heading-search').innerText = obj.returnedEntities + ' Songs found';
|
|
|
|
|
document.getElementById('cardFooterSearch').innerText = obj.returnedEntities + ' Songs found';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('panel-heading-search').innerHTML = '≥ ' + settings.maxElementsPerPage + ' Songs found';
|
|
|
|
|
document.getElementById('cardFooterSearch').innerHTML = '≥ ' + settings.maxElementsPerPage + ' Songs found';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (obj.returnedEntities > 0) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
document.getElementById('searchAddAllSongs').removeAttribute('disabled');
|
2018-07-31 20:46:53 +00:00
|
|
|
|
document.getElementById('searchAddAllSongsBtn').removeAttribute('disabled');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('searchAddAllSongs').setAttribute('disabled','disabled');
|
|
|
|
|
document.getElementById('searchAddAllSongsBtn').setAttribute('disabled','disabled');
|
|
|
|
|
}
|
2018-06-14 19:56:12 +00:00
|
|
|
|
parseFilesystem(obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseFilesystem(obj) {
|
2018-10-22 22:20:57 +00:00
|
|
|
|
var list = app.current.app + (app.current.tab == 'Filesystem' ? app.current.tab : '');
|
|
|
|
|
var colspan = settings['cols' + list].length;
|
|
|
|
|
colspan--;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var nrItems = obj.data.length;
|
2018-10-22 22:20:57 +00:00
|
|
|
|
var tbody = document.getElementById(app.current.app + (app.current.tab == undefined ? '' : app.current.tab) + 'List').getElementsByTagName('tbody')[0];
|
2018-06-25 22:41:44 +00:00
|
|
|
|
var tr = tbody.getElementsByTagName('tr');
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < nrItems; i++) {
|
2018-06-27 23:19:09 +00:00
|
|
|
|
var uri = encodeURI(obj.data[i].uri);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
var row = document.createElement('tr');
|
2018-10-22 22:20:57 +00:00
|
|
|
|
row.setAttribute('data-type', obj.data[i].Type);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
row.setAttribute('data-uri', uri);
|
2018-10-25 21:49:02 +00:00
|
|
|
|
if (obj.data[i].Type == 'song')
|
2018-10-18 21:33:35 +00:00
|
|
|
|
row.setAttribute('data-name', obj.data[i].Title);
|
|
|
|
|
else
|
|
|
|
|
row.setAttribute('data-name', obj.data[i].name);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
|
2018-10-22 22:20:57 +00:00
|
|
|
|
switch(obj.data[i].Type) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
case 'dir':
|
2018-10-25 20:03:33 +00:00
|
|
|
|
case 'smartpls':
|
|
|
|
|
case 'plist':
|
|
|
|
|
var tds = '';
|
|
|
|
|
for (var c = 0; c < settings['cols' + list].length; c++) {
|
|
|
|
|
tds += '<td data-col="' + settings['cols' + list][c] + '">';
|
|
|
|
|
if (settings['cols' + list][c] == 'Type') {
|
|
|
|
|
if (obj.data[i].Type == 'dir')
|
|
|
|
|
tds += '<span class="material-icons">folder_open</span>';
|
|
|
|
|
else
|
2018-11-26 16:17:46 +00:00
|
|
|
|
tds += '<span class="material-icons">' + (obj.data[i].Type == 'smartpls' ? 'queue_music' :'list') + '</span>';
|
2018-10-25 20:03:33 +00:00
|
|
|
|
}
|
|
|
|
|
else if (settings['cols' + list][c] == 'Title')
|
|
|
|
|
tds += obj.data[i].name;
|
|
|
|
|
tds += '</td>';
|
|
|
|
|
}
|
|
|
|
|
tds += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
|
|
|
|
row.innerHTML = tds;
|
2018-06-25 22:41:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'song':
|
2018-10-22 20:03:45 +00:00
|
|
|
|
var minutes = Math.floor(obj.data[i].Duration / 60);
|
|
|
|
|
var seconds = obj.data[i].Duration - minutes * 60;
|
2018-10-22 22:20:57 +00:00
|
|
|
|
obj.data[i].Duration = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
|
|
|
|
var tds = '';
|
|
|
|
|
for (var c = 0; c < settings['cols' + list].length; c++) {
|
|
|
|
|
tds += '<td data-col="' + settings['cols' + list][c] + '">';
|
|
|
|
|
if (settings['cols' + list][c] == 'Type')
|
|
|
|
|
tds += '<span class="material-icons">music_note</span>';
|
|
|
|
|
else
|
|
|
|
|
tds += obj.data[i][settings['cols' + list][c]];
|
|
|
|
|
tds += '</td>';
|
|
|
|
|
}
|
|
|
|
|
tds += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
|
|
|
|
row.innerHTML = tds;
|
2018-06-25 22:41:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-06-27 23:19:09 +00:00
|
|
|
|
if (i < tr.length)
|
|
|
|
|
tr[i].replaceWith(row);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
else
|
|
|
|
|
tbody.append(row);
|
|
|
|
|
}
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var trLen = tr.length - 1;
|
|
|
|
|
for (var i = trLen; i >= nrItems; i --) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
tr[i].remove();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-28 14:23:05 +00:00
|
|
|
|
setPagination(obj.totalEntities, obj.returnedEntities);
|
2018-06-14 19:56:12 +00:00
|
|
|
|
|
2018-06-25 22:41:44 +00:00
|
|
|
|
if (nrItems == 0)
|
2018-06-28 22:51:24 +00:00
|
|
|
|
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
2018-11-12 23:48:29 +00:00
|
|
|
|
'<td colspan="' + colspan + '">No results</td></tr>';
|
2018-11-14 23:14:47 +00:00
|
|
|
|
document.getElementById(app.current.app + (app.current.tab == undefined ? '' : app.current.tab) + 'List').classList.remove('opacity05');
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('cardFooterBrowse').innerText = obj.totalEntities + ' Entries';
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parsePlaylists(obj) {
|
2018-07-22 19:00:26 +00:00
|
|
|
|
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');
|
2018-10-22 22:20:57 +00:00
|
|
|
|
document.getElementById('BrowsePlaylistsDetailColsBtn').parentNode.classList.add('hide');
|
2018-07-22 19:00:26 +00:00
|
|
|
|
} else {
|
2018-09-29 23:03:00 +00:00
|
|
|
|
if (obj.uri.indexOf('.') > -1 || obj.smartpls == true) {
|
2018-07-22 19:00:26 +00:00
|
|
|
|
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);
|
2018-09-29 23:03:00 +00:00
|
|
|
|
if (obj.smartpls == true)
|
2018-10-15 16:15:09 +00:00
|
|
|
|
document.getElementById('BrowsePlaylistsDetailList').getElementsByTagName('caption')[0].innerHTML = 'Smart playlist: ' + obj.uri +
|
|
|
|
|
'<small class="pull-right">' + obj.totalEntities + ' Songs </small>';
|
2018-09-29 23:03:00 +00:00
|
|
|
|
else
|
2018-10-15 16:15:09 +00:00
|
|
|
|
document.getElementById('BrowsePlaylistsDetailList').getElementsByTagName('caption')[0].innerHTML = 'Playlist: ' + obj.uri +
|
|
|
|
|
'<small class="pull-right">' + obj.totalEntities + ' Songs </small>';
|
2018-07-22 19:00:26 +00:00
|
|
|
|
document.getElementById('BrowsePlaylistsDetailList').classList.remove('hide');
|
|
|
|
|
document.getElementById('BrowsePlaylistsAllList').classList.add('hide');
|
|
|
|
|
document.getElementById('btnBrowsePlaylistsAll').parentNode.classList.remove('hide');
|
2018-10-25 21:49:02 +00:00
|
|
|
|
if (settings.featTags)
|
|
|
|
|
document.getElementById('BrowsePlaylistsDetailColsBtn').parentNode.classList.remove('hide');
|
2018-07-22 19:00:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-27 23:19:09 +00:00
|
|
|
|
var nrItems = obj.data.length;
|
2018-07-22 19:00:26 +00:00
|
|
|
|
var tbody = document.getElementById(app.current.app + app.current.tab + app.current.view + 'List').getElementsByTagName('tbody')[0];
|
2018-06-25 22:41:44 +00:00
|
|
|
|
var tr = tbody.getElementsByTagName('tr');
|
2018-07-22 19:00:26 +00:00
|
|
|
|
if (app.current.view == 'All') {
|
|
|
|
|
for (var i = 0; i < nrItems; i++) {
|
|
|
|
|
var uri = encodeURI(obj.data[i].uri);
|
|
|
|
|
var d = new Date(obj.data[i].last_modified * 1000);
|
|
|
|
|
var row = document.createElement('tr');
|
|
|
|
|
row.setAttribute('data-uri', uri);
|
2018-10-22 22:20:57 +00:00
|
|
|
|
row.setAttribute('data-type', obj.data[i].Type);
|
2018-07-22 19:00:26 +00:00
|
|
|
|
row.setAttribute('data-name', obj.data[i].name);
|
2018-11-26 16:17:46 +00:00
|
|
|
|
row.innerHTML = '<td data-col="Type"><span class="material-icons">' + (obj.data[i].Type == 'smartpls' ? 'queue_music' :'list') + '</span></td>' +
|
2018-07-22 19:00:26 +00:00
|
|
|
|
'<td>' + obj.data[i].name + '</td>' +
|
|
|
|
|
'<td>'+ d.toUTCString() + '</td>' +
|
2018-10-22 22:20:57 +00:00
|
|
|
|
'<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
2018-07-22 19:00:26 +00:00
|
|
|
|
if (i < tr.length)
|
|
|
|
|
tr[i].replaceWith(row);
|
|
|
|
|
else
|
|
|
|
|
tbody.append(row);
|
|
|
|
|
}
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('cardFooterBrowse').innerText = obj.totalEntities + ' Playlists';
|
2018-07-22 19:00:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if (app.current.view == 'Detail') {
|
|
|
|
|
for (var i = 0; i < nrItems; i++) {
|
|
|
|
|
var uri = encodeURI(obj.data[i].uri);
|
|
|
|
|
var row = document.createElement('tr');
|
2018-09-29 23:03:00 +00:00
|
|
|
|
if (obj.smartpls == false)
|
|
|
|
|
row.setAttribute('draggable','true');
|
2018-10-22 22:20:57 +00:00
|
|
|
|
row.setAttribute('id','playlistTrackId' + obj.data[i].Pos);
|
|
|
|
|
row.setAttribute('data-type', obj.data[i].Type);
|
2018-07-22 19:00:26 +00:00
|
|
|
|
row.setAttribute('data-uri', uri);
|
2018-10-18 21:33:35 +00:00
|
|
|
|
row.setAttribute('data-name', obj.data[i].Title);
|
2018-10-22 22:20:57 +00:00
|
|
|
|
row.setAttribute('data-songpos', obj.data[i].Pos);
|
2018-10-22 20:03:45 +00:00
|
|
|
|
var minutes = Math.floor(obj.data[i].Duration / 60);
|
|
|
|
|
var seconds = obj.data[i].Duration - minutes * 60;
|
2018-10-22 22:20:57 +00:00
|
|
|
|
obj.data[i].Duration = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
|
|
|
|
var tds = '';
|
|
|
|
|
for (var c = 0; c < settings.colsBrowsePlaylistsDetail.length; c++) {
|
|
|
|
|
tds += '<td data-col="' + settings.colsBrowsePlaylistsDetail[c] + '">' + obj.data[i][settings.colsBrowsePlaylistsDetail[c]] + '</td>';
|
|
|
|
|
}
|
|
|
|
|
tds += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
|
|
|
|
row.innerHTML = tds;
|
|
|
|
|
|
2018-07-22 19:00:26 +00:00
|
|
|
|
if (i < tr.length)
|
|
|
|
|
tr[i].replaceWith(row);
|
|
|
|
|
else
|
|
|
|
|
tbody.append(row);
|
|
|
|
|
}
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('cardFooterBrowse').innerText = obj.totalEntities + ' Songs';
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var trLen = tr.length - 1;
|
|
|
|
|
for (var i = trLen; i >= nrItems; i --) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
tr[i].remove();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-28 14:23:05 +00:00
|
|
|
|
setPagination(obj.totalEntities, obj.returnedEntities);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
|
2018-11-12 23:48:29 +00:00
|
|
|
|
if (nrItems == 0) {
|
|
|
|
|
var colspan = settings['cols' + list].length;
|
|
|
|
|
colspan--;
|
2018-07-22 19:00:26 +00:00
|
|
|
|
if (app.current.view == 'All')
|
|
|
|
|
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
2018-11-12 23:48:29 +00:00
|
|
|
|
'<td colspan="' + colspan + '">No playlists found.</td></tr>';
|
2018-07-22 19:00:26 +00:00
|
|
|
|
else
|
|
|
|
|
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
2018-11-12 23:48:29 +00:00
|
|
|
|
'<td colspan="' + colspan + '">Empty playlist.</td></tr>';
|
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
|
|
|
|
|
document.getElementById(app.current.app + app.current.tab + app.current.view + 'List').classList.remove('opacity05');
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseListDBtags(obj) {
|
2018-10-10 21:40:04 +00:00
|
|
|
|
scrollTo(0);
|
2018-09-10 20:32:15 +00:00
|
|
|
|
if (app.current.search != '') {
|
2018-08-06 18:08:30 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseAlbumList').classList.remove('hide');
|
2018-09-10 20:32:15 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseTagList').classList.add('hide');
|
|
|
|
|
document.getElementById('btnBrowseDatabaseByTag').parentNode.classList.add('hide');
|
|
|
|
|
document.getElementById('btnBrowseDatabaseTag').parentNode.classList.remove('hide');
|
2018-09-10 20:51:53 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseAddAllSongs').parentNode.parentNode.classList.remove('hide');
|
2018-11-04 18:34:46 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseColsBtn').parentNode.classList.remove('hide');
|
2018-09-10 20:32:15 +00:00
|
|
|
|
document.getElementById('btnBrowseDatabaseTag').innerHTML = '« ' + app.current.view;
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseAlbumListCaption').innerHTML = '<h2>' + obj.searchtagtype + ': ' + obj.searchstr + '</h2><hr/>';
|
|
|
|
|
document.getElementById('cardFooterBrowse').innerText = obj.totalEntities + ' Entries';
|
2018-06-27 23:19:09 +00:00
|
|
|
|
var nrItems = obj.data.length;
|
2018-08-06 18:08:30 +00:00
|
|
|
|
var cardContainer = document.getElementById('BrowseDatabaseAlbumList');
|
2018-11-04 18:34:46 +00:00
|
|
|
|
var cards = cardContainer.getElementsByClassName('card');
|
2018-06-27 23:19:09 +00:00
|
|
|
|
for (var i = 0; i < nrItems; i++) {
|
2018-10-10 21:40:04 +00:00
|
|
|
|
var id = genId(obj.data[i].value);
|
2018-11-04 18:34:46 +00:00
|
|
|
|
var card = document.createElement('div');
|
|
|
|
|
card.classList.add('card', 'ml-4', 'mr-4', 'mb-4', 'w-100');
|
|
|
|
|
card.setAttribute('id', 'card' + id);
|
2018-10-10 21:40:04 +00:00
|
|
|
|
card.setAttribute('data-album', encodeURI(obj.data[i].value));
|
2018-11-04 18:34:46 +00:00
|
|
|
|
var html = '<div class="card-header"><span id="albumartist' + id + '"></span> – ' + obj.data[i].value + '</div>' +
|
|
|
|
|
' <div class="card-body"><div class="row">';
|
|
|
|
|
if (settings.featCoverimage)
|
|
|
|
|
html += ' <div class="col-md-auto"><a class="card-img-left"></a></div>';
|
|
|
|
|
html += ' <div class="col"><table class="tblAlbumTitles table table-sm table-hover" id="tbl' + id + '"><thead><tr></tr></thead><tbody></tbody></table></div>' +
|
|
|
|
|
' </div></div>' +
|
|
|
|
|
'</div>';
|
|
|
|
|
|
|
|
|
|
card.innerHTML = html;
|
2018-06-27 23:19:09 +00:00
|
|
|
|
if (i < cards.length)
|
|
|
|
|
cards[i].replaceWith(card);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
else
|
|
|
|
|
cardContainer.append(card);
|
2018-10-10 21:40:04 +00:00
|
|
|
|
|
|
|
|
|
if ('IntersectionObserver' in window)
|
2018-11-04 18:34:46 +00:00
|
|
|
|
createListTitleObserver(document.getElementById('card' + id));
|
2018-10-10 21:40:04 +00:00
|
|
|
|
else
|
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_TAG_ALBUM_TITLE_LIST", "data": { "album": obj.data[i].value, "search": app.current.search, "tag": app.current.view}}, parseListTitles);
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var cardsLen = cards.length - 1;
|
|
|
|
|
for (var i = cardsLen; i >= nrItems; i --) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
cards[i].remove();
|
|
|
|
|
}
|
2018-11-28 14:23:05 +00:00
|
|
|
|
setPagination(obj.totalEntities, obj.returnedEntities);
|
2018-11-04 18:34:46 +00:00
|
|
|
|
setCols('BrowseDatabase', '.tblAlbumTitles');
|
|
|
|
|
var tbls = document.querySelectorAll('.tblAlbumTitles');
|
|
|
|
|
for (var i = 0; i < tbls.length; i++)
|
|
|
|
|
dragAndDropTableHeader(tbls[i]);
|
2018-08-06 18:08:30 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseAlbumList').classList.remove('opacity05');
|
2018-09-10 20:32:15 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('BrowseDatabaseAlbumList').classList.add('hide');
|
|
|
|
|
document.getElementById('BrowseDatabaseTagList').classList.remove('hide');
|
|
|
|
|
document.getElementById('btnBrowseDatabaseByTag').parentNode.classList.remove('hide');
|
2018-09-10 20:51:53 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseAddAllSongs').parentNode.parentNode.classList.add('hide');
|
2018-11-04 18:34:46 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseColsBtn').parentNode.classList.add('hide');
|
2018-09-10 20:32:15 +00:00
|
|
|
|
document.getElementById('btnBrowseDatabaseTag').parentNode.classList.add('hide');
|
2018-11-14 23:35:39 +00:00
|
|
|
|
document.getElementById('BrowseDatabaseTagListCaption').innerText = app.current.view;
|
|
|
|
|
document.getElementById('cardFooterBrowse').innerText = obj.totalEntities + ' Tags';
|
2018-09-10 20:32:15 +00:00
|
|
|
|
var nrItems = obj.data.length;
|
|
|
|
|
var tbody = document.getElementById(app.current.app + app.current.tab + 'TagList').getElementsByTagName('tbody')[0];
|
|
|
|
|
var tr = tbody.getElementsByTagName('tr');
|
|
|
|
|
for (var i = 0; i < nrItems; i++) {
|
|
|
|
|
var uri = encodeURI(obj.data[i].value);
|
|
|
|
|
var row = document.createElement('tr');
|
|
|
|
|
row.setAttribute('data-uri', uri);
|
2018-10-22 22:20:57 +00:00
|
|
|
|
row.innerHTML='<td data-col="Type"><span class="material-icons">album</span></td>' +
|
2018-09-10 20:32:15 +00:00
|
|
|
|
'<td>' + obj.data[i].value + '</td>';
|
|
|
|
|
|
|
|
|
|
if (i < tr.length)
|
|
|
|
|
tr[i].replaceWith(row);
|
|
|
|
|
else
|
|
|
|
|
tbody.append(row);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var trLen = tr.length - 1;
|
|
|
|
|
for (var i = trLen; i >= nrItems; i --) {
|
|
|
|
|
tr[i].remove();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-28 14:23:05 +00:00
|
|
|
|
setPagination(obj.totalEntities, obj.returnedEntities);
|
2018-09-10 20:32:15 +00:00
|
|
|
|
|
|
|
|
|
if (nrItems == 0)
|
|
|
|
|
tbody.innerHTML = '<tr><td><span class="material-icons">error_outline</span></td>' +
|
|
|
|
|
'<td>No entries found.</td></tr>';
|
|
|
|
|
document.getElementById('BrowseDatabaseTagList').classList.remove('opacity05');
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-10 21:40:04 +00:00
|
|
|
|
function createListTitleObserver(ele) {
|
|
|
|
|
var options = {
|
|
|
|
|
root: null,
|
|
|
|
|
rootMargin: "0px",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var observer = new IntersectionObserver(getListTitles, options);
|
|
|
|
|
observer.observe(ele);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getListTitles(changes, observer) {
|
|
|
|
|
changes.forEach(change => {
|
|
|
|
|
if (change.intersectionRatio > 0) {
|
2018-10-10 22:01:21 +00:00
|
|
|
|
observer.unobserve(change.target);
|
|
|
|
|
var album = decodeURI(change.target.getAttribute('data-album'));
|
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_TAG_ALBUM_TITLE_LIST", "data": { "album": album, "search": app.current.search, "tag": app.current.view}}, parseListTitles);
|
2018-10-10 21:40:04 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 19:56:12 +00:00
|
|
|
|
function parseListTitles(obj) {
|
2018-10-17 22:04:06 +00:00
|
|
|
|
var id = genId(obj.Album);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var card = document.getElementById('card' + id)
|
|
|
|
|
var tbody = card.getElementsByTagName('tbody')[0];
|
2018-11-04 18:34:46 +00:00
|
|
|
|
var cardHeader = card.querySelector('.card-header');
|
|
|
|
|
cardHeader.setAttribute('data-uri', encodeURI(obj.data[0].uri.replace(/\/[^\/]+$/, '')));
|
|
|
|
|
cardHeader.setAttribute('data-name', obj.Album);
|
|
|
|
|
cardHeader.setAttribute('data-type', 'dir');
|
|
|
|
|
cardHeader.addEventListener('click', function(event) {
|
2018-10-29 19:41:04 +00:00
|
|
|
|
showMenu(this, event);
|
|
|
|
|
}, false);
|
2018-11-04 18:34:46 +00:00
|
|
|
|
cardHeader.classList.add('clickable');
|
|
|
|
|
var img = card.getElementsByTagName('a')[0];
|
|
|
|
|
if (img) {
|
|
|
|
|
img.style.backgroundImage = 'url("' + obj.cover + '")';
|
|
|
|
|
img.setAttribute('data-uri', encodeURI(obj.data[0].uri.replace(/\/[^\/]+$/, '')));
|
|
|
|
|
img.setAttribute('data-name', obj.Album);
|
|
|
|
|
img.setAttribute('data-type', 'dir');
|
|
|
|
|
img.addEventListener('click', function(event) {
|
|
|
|
|
showMenu(this, event);
|
|
|
|
|
}, false);
|
|
|
|
|
}
|
2018-10-29 19:41:04 +00:00
|
|
|
|
|
2018-10-17 22:04:06 +00:00
|
|
|
|
document.getElementById('albumartist' + id).innerText = obj.AlbumArtist;
|
2018-06-25 22:41:44 +00:00
|
|
|
|
|
2018-07-01 22:49:47 +00:00
|
|
|
|
var titleList = '';
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var nrItems = obj.data.length;
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < nrItems; i++) {
|
2018-11-04 18:34:46 +00:00
|
|
|
|
if (obj.data[i].Duration) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
titleList += '<tr data-type="song" data-name="' + obj.data[i].Title + '" data-uri="' + encodeURI(obj.data[i].uri) + '">';
|
|
|
|
|
for (var c = 0; c < settings.colsBrowseDatabase.length; c++) {
|
|
|
|
|
titleList += '<td data-col="' + settings.colsBrowseDatabase[c] + '">' + obj.data[i][settings.colsBrowseDatabase[c]] + '</td>';
|
|
|
|
|
}
|
|
|
|
|
titleList += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td></tr>';
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}
|
2018-07-01 22:49:47 +00:00
|
|
|
|
tbody.innerHTML = titleList;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
|
|
|
|
|
tbody.parentNode.addEventListener('click', function(event) {
|
|
|
|
|
if (event.target.nodeName == 'TD') {
|
|
|
|
|
appendQueue('song', decodeURI(event.target.parentNode.getAttribute('data-uri')), event.target.parentNode.getAttribute('data-name'));
|
|
|
|
|
}
|
|
|
|
|
else if (event.target.nodeName == 'A') {
|
2018-09-03 20:01:50 +00:00
|
|
|
|
showMenu(event.target, event);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
2013-11-04 17:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-28 14:23:05 +00:00
|
|
|
|
function setPagination(total, returned) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var cat = app.current.app + (app.current.tab == undefined ? '': app.current.tab);
|
2018-11-28 14:23:05 +00:00
|
|
|
|
var totalPages = Math.ceil(total / settings.maxElementsPerPage);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
if (totalPages == 0)
|
|
|
|
|
totalPages = 1;
|
|
|
|
|
var p = ['PaginationTop', 'PaginationBottom'];
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < 2; i++) {
|
2018-08-21 22:56:17 +00:00
|
|
|
|
document.getElementById(cat + p[i] + 'Page').innerText = (app.current.page / settings.maxElementsPerPage + 1) + ' / ' + totalPages;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
if (totalPages > 1) {
|
|
|
|
|
document.getElementById(cat + p[i] + 'Page').removeAttribute('disabled');
|
|
|
|
|
var pl = '';
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var j = 0; j < totalPages; j++) {
|
2018-08-21 22:56:17 +00:00
|
|
|
|
pl += '<button data-page="' + (j * settings.maxElementsPerPage) + '" type="button" class="mr-1 mb-1 btn-sm btn btn-secondary">' +
|
2018-06-28 22:51:24 +00:00
|
|
|
|
( j + 1) + '</button>';
|
|
|
|
|
}
|
|
|
|
|
document.getElementById(cat + p[i] + 'Pages').innerHTML = pl;
|
2018-11-28 16:39:55 +00:00
|
|
|
|
document.getElementById(cat + p[i] + 'Page').classList.remove('nodropdown');
|
2018-11-28 14:23:05 +00:00
|
|
|
|
}
|
|
|
|
|
else if (total == -1) {
|
|
|
|
|
document.getElementById(cat + p[i] + 'Page').setAttribute('disabled', 'disabled');
|
|
|
|
|
document.getElementById(cat + p[i] + 'Page').innerText = (app.current.page / settings.maxElementsPerPage + 1);
|
2018-11-28 16:39:55 +00:00
|
|
|
|
document.getElementById(cat + p[i] + 'Page').classList.add('nodropdown');
|
2018-11-28 14:23:05 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById(cat + p[i] + 'Page').setAttribute('disabled', 'disabled');
|
2018-11-28 16:39:55 +00:00
|
|
|
|
document.getElementById(cat + p[i] + 'Page').classList.add('nodropdown');
|
2018-05-28 22:05:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-28 14:23:05 +00:00
|
|
|
|
if (total > app.current.page + settings.maxElementsPerPage || total == -1 && returned >= settings.maxElementsPerPage) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById(cat + p[i] + 'Next').removeAttribute('disabled');
|
2018-07-31 20:46:53 +00:00
|
|
|
|
document.getElementById(cat + p[i]).classList.remove('hide');
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById(cat + 'ButtonsBottom').classList.remove('hide');
|
2018-11-28 14:23:05 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById(cat + p[i] + 'Next').setAttribute('disabled', 'disabled');
|
2018-07-31 20:46:53 +00:00
|
|
|
|
document.getElementById(cat + p[i]).classList.add('hide');
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById(cat + 'ButtonsBottom').classList.add('hide');
|
|
|
|
|
}
|
2018-05-28 22:05:56 +00:00
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
if (app.current.page > 0) {
|
|
|
|
|
document.getElementById(cat + p[i] + 'Prev').removeAttribute('disabled');
|
2018-07-31 20:46:53 +00:00
|
|
|
|
document.getElementById(cat + p[i]).classList.remove('hide');
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById(cat + 'ButtonsBottom').classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementById(cat + p[i] + 'Prev').setAttribute('disabled', 'disabled');
|
|
|
|
|
}
|
2018-05-28 22:05:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
function appendQueue(type, uri, name) {
|
2018-06-25 22:41:44 +00:00
|
|
|
|
switch(type) {
|
|
|
|
|
case 'song':
|
2018-07-05 20:04:25 +00:00
|
|
|
|
case 'dir':
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_ADD_TRACK", "data": {"uri": uri}});
|
2018-07-09 17:28:28 +00:00
|
|
|
|
showNotification('"' + name + '" added', '', '', 'success');
|
2018-07-05 20:04:25 +00:00
|
|
|
|
break;
|
2018-06-25 22:41:44 +00:00
|
|
|
|
case 'plist':
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_ADD_PLAYLIST", "data": {"plist": uri}});
|
2018-07-09 17:28:28 +00:00
|
|
|
|
showNotification('"' + name + '" added', '', '', 'success');
|
2018-06-25 22:41:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-24 21:39:37 +00:00
|
|
|
|
|
2018-07-05 19:34:16 +00:00
|
|
|
|
function appendAfterQueue(type, uri, to, name) {
|
|
|
|
|
switch(type) {
|
|
|
|
|
case 'song':
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_ADD_TRACK_AFTER", "data": {"uri": uri, "to": to}});
|
2018-07-19 16:33:53 +00:00
|
|
|
|
showNotification('"' + name + '" added to pos ' + to, '', '', 'success');
|
2018-07-05 20:04:25 +00:00
|
|
|
|
break;
|
2018-07-05 19:34:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function replaceQueue(type, uri, name) {
|
|
|
|
|
switch(type) {
|
|
|
|
|
case 'song':
|
2018-07-05 20:04:25 +00:00
|
|
|
|
case 'dir':
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_REPLACE_TRACK", "data": {"uri": uri}});
|
2018-07-09 17:28:28 +00:00
|
|
|
|
showNotification('"' + name + '" replaced', '', '', 'success');
|
2018-07-05 20:04:25 +00:00
|
|
|
|
break;
|
2018-07-05 19:34:16 +00:00
|
|
|
|
case 'plist':
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_REPLACE_PLAYLIST", "data": {"plist": uri}});
|
2018-07-09 17:28:28 +00:00
|
|
|
|
showNotification('"' + name + '" replaced', '', '', 'success');
|
2018-07-05 19:34:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-12 17:34:28 +00:00
|
|
|
|
function clickTitle() {
|
2018-11-04 23:26:59 +00:00
|
|
|
|
var uri = decodeURI(domCache.currentTitle.getAttribute('data-uri'));
|
2018-08-21 19:28:13 +00:00
|
|
|
|
if (uri != '')
|
|
|
|
|
songDetails(uri);
|
2018-08-06 18:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-04 23:26:59 +00:00
|
|
|
|
function gotoBrowse(x) {
|
2018-11-05 19:57:06 +00:00
|
|
|
|
var tag = x.parentNode.getAttribute('data-tag');
|
|
|
|
|
var name = decodeURI(x.parentNode.getAttribute('data-name'));
|
2018-11-05 21:49:57 +00:00
|
|
|
|
if (tag != '' && name != '' && name != '-' && settings.browsetags.includes(tag))
|
2018-11-04 23:26:59 +00:00
|
|
|
|
appGoto('Browse', 'Database', tag, '0/-/' + name);
|
2018-08-06 18:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-09 17:28:28 +00:00
|
|
|
|
function songDetails(uri) {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_SONGDETAILS", "data": {"uri": uri}}, parseSongDetails);
|
2018-07-09 17:28:28 +00:00
|
|
|
|
modalSongDetails.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseSongDetails(obj) {
|
|
|
|
|
var modal = document.getElementById('modalSongDetails');
|
2018-08-21 22:02:22 +00:00
|
|
|
|
modal.getElementsByClassName('album-cover')[0].style.backgroundImage = 'url("' + obj.data.cover + '")';
|
2018-10-17 22:04:06 +00:00
|
|
|
|
modal.getElementsByTagName('h1')[0].innerText = obj.data.Title;
|
2018-09-11 19:59:33 +00:00
|
|
|
|
|
|
|
|
|
var songDetails = '';
|
2018-10-09 21:51:47 +00:00
|
|
|
|
for (var i = 0; i < settings.tags.length; i++) {
|
2018-11-11 22:43:25 +00:00
|
|
|
|
songDetails += '<tr><th>' + settings.tags[i] + '</th><td data-tag="' + settings.tags[i] + '" data-name="' + encodeURI(obj.data[settings.tags[i]]) + '">';
|
|
|
|
|
if (settings.browsetags.includes(settings.tags[i]))
|
|
|
|
|
songDetails += '<a class="text-success" href="#">' + obj.data[settings.tags[i]] + '</a>';
|
|
|
|
|
else
|
|
|
|
|
songDetails += obj.data[settings.tags[i]];
|
|
|
|
|
songDetails += '</td></tr>';
|
2018-07-09 17:28:28 +00:00
|
|
|
|
}
|
2018-10-22 20:03:45 +00:00
|
|
|
|
var duration = obj.data.Duration;
|
2018-10-17 22:04:06 +00:00
|
|
|
|
var minutes = Math.floor(duration / 60);
|
|
|
|
|
var seconds = duration - minutes * 60;
|
|
|
|
|
duration = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
|
|
|
|
songDetails += '<tr><th>Duration</th><td>' + duration + '</td></tr>';
|
2018-10-29 20:00:50 +00:00
|
|
|
|
if (settings.featLibrary)
|
2018-11-11 22:43:25 +00:00
|
|
|
|
songDetails += '<tr><th>Filename</th><td><a class="text-success" href="/library/' + encodeURI(obj.data.uri) + '">' + obj.data.uri + '</a></td></tr>';
|
2018-10-29 20:00:50 +00:00
|
|
|
|
else
|
|
|
|
|
songDetails += '<tr><th>Filename</th><td>' + obj.data.uri + '</td></tr>';
|
2018-09-11 19:59:33 +00:00
|
|
|
|
|
2018-10-25 20:03:33 +00:00
|
|
|
|
if (settings.featStickers == true) {
|
2018-09-11 20:08:48 +00:00
|
|
|
|
songDetails += '<tr><th colspan="2">Statistics</th></tr>' +
|
2018-09-11 19:59:33 +00:00
|
|
|
|
'<tr><th>Play count</th><td>' + obj.data.playCount + '</td></tr>' +
|
|
|
|
|
'<tr><th>Skip count</th><td>' + obj.data.skipCount + '</td></tr>' +
|
2018-09-20 18:56:24 +00:00
|
|
|
|
'<tr><th>Last played</th><td>' + (obj.data.lastPlayed == 0 ? 'never' : new Date(obj.data.lastPlayed * 1000).toUTCString()) + '</td></tr>' +
|
2018-11-11 23:38:46 +00:00
|
|
|
|
'<tr><th>Like</th><td>' +
|
|
|
|
|
'<div class="btn-group btn-group-sm">' +
|
|
|
|
|
'<button title="Dislike song" id="btnVoteDown2" data-href=\'{"cmd": "voteSong", "options": [0]}\' class="btn btn-sm btn-light material-icons">thumb_down</button>' +
|
|
|
|
|
'<button title="Like song" id="btnVoteUp2" data-href=\'{"cmd": "voteSong", "options": [2]}\' class="btn btn-sm btn-light material-icons">thumb_up</button>' +
|
|
|
|
|
'</div>' +
|
|
|
|
|
'</td></tr>';
|
2018-09-11 19:59:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modal.getElementsByTagName('tbody')[0].innerHTML = songDetails;
|
2018-11-11 23:38:46 +00:00
|
|
|
|
setVoteSongBtns(obj.data.like, obj.data.uri);
|
2018-07-09 17:28:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 22:34:25 +00:00
|
|
|
|
function execSyscmd(cmd) {
|
|
|
|
|
sendAPI({"cmd": "MPD_API_SYSCMD", "data": {"cmd": cmd}});
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-22 19:00:26 +00:00
|
|
|
|
function playlistDetails(uri) {
|
2018-09-30 21:12:16 +00:00
|
|
|
|
document.getElementById('BrowsePlaylistsAllList').classList.add('opacity05');
|
2018-07-22 19:00:26 +00:00
|
|
|
|
appGoto('Browse', 'Playlists', 'Detail', '0/-/' + uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeFromPlaylist(uri, pos) {
|
2018-08-01 21:54:53 +00:00
|
|
|
|
pos--;
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_RM_TRACK", "data": {"uri": uri, "track": pos}});
|
2018-07-22 19:00:26 +00:00
|
|
|
|
document.getElementById('BrowsePlaylistsDetailList').classList.add('opacity05');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function playlistClear() {
|
|
|
|
|
var uri = document.getElementById('BrowsePlaylistsDetailList').getAttribute('data-uri');
|
2018-10-14 21:38:34 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_CLEAR_AND_LIST", "data": {"uri": uri}});
|
2018-07-22 19:00:26 +00:00
|
|
|
|
document.getElementById('BrowsePlaylistsDetailList').classList.add('opacity05');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAllPlaylists(obj) {
|
|
|
|
|
var nrItems = obj.data.length;
|
2018-09-20 16:59:29 +00:00
|
|
|
|
var playlists = '';
|
|
|
|
|
if (obj.offset == 0) {
|
|
|
|
|
if (playlistEl == 'addToPlaylistPlaylist')
|
|
|
|
|
playlists = '<option></option><option>New Playlist</option>';
|
2018-09-30 01:03:33 +00:00
|
|
|
|
else if (playlistEl == 'selectJukeboxPlaylist')
|
2018-09-20 16:59:29 +00:00
|
|
|
|
playlists = '<option>Database</option>';
|
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
for (var i = 0; i < nrItems; i++) {
|
2018-09-20 16:59:29 +00:00
|
|
|
|
playlists += '<option';
|
2018-09-30 01:03:33 +00:00
|
|
|
|
if (playlistEl == 'selectJukeboxPlaylist' && obj.data[i].uri == settings.jukeboxPlaylist)
|
2018-09-20 16:59:29 +00:00
|
|
|
|
playlists += ' selected';
|
|
|
|
|
playlists += '>' + obj.data[i].uri + '</option>';
|
2018-07-22 19:00:26 +00:00
|
|
|
|
}
|
2018-09-20 16:59:29 +00:00
|
|
|
|
if (obj.offset == 0)
|
|
|
|
|
document.getElementById(playlistEl).innerHTML = playlists;
|
|
|
|
|
else
|
|
|
|
|
document.getElementById(playlistEl).innerHTML += playlists;
|
2018-07-22 19:00:26 +00:00
|
|
|
|
if (obj.totalEntities > obj.returnedEntities) {
|
2018-08-21 22:56:17 +00:00
|
|
|
|
obj.offset += settings.maxElementsPerPage;
|
2018-09-20 16:59:29 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST", "data": {"offset": obj.offset, "filter": "-"}}, getAllPlaylists);
|
2018-07-22 19:00:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-24 20:55:53 +00:00
|
|
|
|
function updateSmartPlaylists() {
|
2018-09-29 23:03:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_SMARTPLS_UPDATE_ALL"});
|
2018-09-24 20:55:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 14:26:12 +00:00
|
|
|
|
function voteSong(vote) {
|
2018-12-03 17:55:24 +00:00
|
|
|
|
var uri = decodeURI(domCache.currentTitle.getAttribute('data-uri'));
|
2018-08-18 14:26:12 +00:00
|
|
|
|
if (uri == '')
|
|
|
|
|
return;
|
|
|
|
|
|
2018-08-21 22:02:22 +00:00
|
|
|
|
if (vote == 2 && domCache.btnVoteUp.classList.contains('active-fg-green'))
|
2018-08-18 14:26:12 +00:00
|
|
|
|
vote = 1;
|
2018-08-21 22:02:22 +00:00
|
|
|
|
else if (vote == 0 && domCache.btnVoteDown.classList.contains('active-fg-red'))
|
2018-08-18 14:26:12 +00:00
|
|
|
|
vote = 1;
|
2018-09-20 16:59:29 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_LIKE", "data": {"uri": uri, "like": vote}});
|
2018-08-21 22:02:22 +00:00
|
|
|
|
setVoteSongBtns(vote, uri);
|
2018-08-18 14:26:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 22:02:22 +00:00
|
|
|
|
function setVoteSongBtns(vote, uri) {
|
2018-11-11 23:38:46 +00:00
|
|
|
|
domCache.btnVoteUp2 = document.getElementById('btnVoteUp2');
|
|
|
|
|
domCache.btnVoteDown2 = document.getElementById('btnVoteDown2');
|
|
|
|
|
|
|
|
|
|
|
2018-08-21 22:02:22 +00:00
|
|
|
|
if (uri == '' || uri.indexOf('http://') == 0 || uri.indexOf('https://') == 0) {
|
|
|
|
|
domCache.btnVoteUp.setAttribute('disabled', 'disabled');
|
|
|
|
|
domCache.btnVoteDown.setAttribute('disabled', 'disabled');
|
2018-11-11 23:38:46 +00:00
|
|
|
|
if (domCache.btnVoteUp2) {
|
|
|
|
|
domCache.btnVoteUp2.setAttribute('disabled', 'disabled');
|
|
|
|
|
domCache.btnVoteDown2.setAttribute('disabled', 'disabled');
|
|
|
|
|
}
|
2018-08-21 22:02:22 +00:00
|
|
|
|
} else {
|
|
|
|
|
domCache.btnVoteUp.removeAttribute('disabled');
|
2018-11-11 23:38:46 +00:00
|
|
|
|
domCache.btnVoteDown.removeAttribute('disabled');
|
|
|
|
|
if (domCache.btnVoteUp2) {
|
|
|
|
|
domCache.btnVoteUp2.removeAttribute('disabled');
|
|
|
|
|
domCache.btnVoteDown2.removeAttribute('disabled');
|
|
|
|
|
}
|
2018-08-21 22:02:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 14:26:12 +00:00
|
|
|
|
if (vote == 0) {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
domCache.btnVoteUp.classList.remove('active-fg-green');
|
|
|
|
|
domCache.btnVoteDown.classList.add('active-fg-red');
|
2018-11-11 23:38:46 +00:00
|
|
|
|
if (domCache.btnVoteUp2) {
|
|
|
|
|
domCache.btnVoteUp2.classList.remove('active-fg-green');
|
|
|
|
|
domCache.btnVoteDown2.classList.add('active-fg-red');
|
|
|
|
|
}
|
2018-08-18 14:26:12 +00:00
|
|
|
|
} else if (vote == 1) {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
domCache.btnVoteUp.classList.remove('active-fg-green');
|
|
|
|
|
domCache.btnVoteDown.classList.remove('active-fg-red');
|
2018-11-11 23:38:46 +00:00
|
|
|
|
if (domCache.btnVoteUp2) {
|
|
|
|
|
domCache.btnVoteUp2.classList.remove('active-fg-green');
|
|
|
|
|
domCache.btnVoteDown2.classList.remove('active-fg-red');
|
|
|
|
|
}
|
2018-08-18 14:26:12 +00:00
|
|
|
|
} else if (vote == 2) {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
domCache.btnVoteUp.classList.add('active-fg-green');
|
|
|
|
|
domCache.btnVoteDown.classList.remove('active-fg-red');
|
2018-11-11 23:38:46 +00:00
|
|
|
|
if (domCache.btnVoteUp2) {
|
|
|
|
|
domCache.btnVoteUp2.classList.add('active-fg-green');
|
|
|
|
|
domCache.btnVoteDown2.classList.remove('active-fg-red');
|
|
|
|
|
}
|
2018-08-18 14:26:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-01 21:54:53 +00:00
|
|
|
|
function toggleAddToPlaylistFrm() {
|
|
|
|
|
var btn = document.getElementById('toggleAddToPlaylistBtn');
|
|
|
|
|
toggleBtn('toggleAddToPlaylistBtn');
|
|
|
|
|
if (btn.classList.contains('active')) {
|
|
|
|
|
document.getElementById('addToPlaylistFrm').classList.remove('hide');
|
|
|
|
|
document.getElementById('addStreamFooter').classList.add('hide');
|
|
|
|
|
document.getElementById('addToPlaylistFooter').classList.remove('hide');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('addToPlaylistFrm').classList.add('hide');
|
|
|
|
|
document.getElementById('addStreamFooter').classList.remove('hide');
|
|
|
|
|
document.getElementById('addToPlaylistFooter').classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-31 20:46:53 +00:00
|
|
|
|
|
2018-10-01 17:07:38 +00:00
|
|
|
|
function saveSearchAsSmartPlaylist() {
|
|
|
|
|
parseSmartPlaylist({"type": "smartpls", "data": {"playlist": "", "type": "search", "tag": app.current.filter, "searchstr": app.current.search}});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseSmartPlaylist(obj) {
|
2018-09-29 18:41:58 +00:00
|
|
|
|
var nameEl = document.getElementById('saveSmartPlaylistName');
|
2018-10-01 17:07:38 +00:00
|
|
|
|
nameEl.value = obj.data.playlist;
|
2018-09-29 18:41:58 +00:00
|
|
|
|
nameEl.classList.remove('is-invalid');
|
2018-10-29 18:17:04 +00:00
|
|
|
|
document.getElementById('saveSmartPlaylistType').value = obj.data.type;
|
2018-09-29 18:41:58 +00:00
|
|
|
|
document.getElementById('saveSmartPlaylistFrm').classList.remove('was-validated');
|
2018-10-01 17:07:38 +00:00
|
|
|
|
document.getElementById('saveSmartPlaylistSearch').classList.add('hide');
|
|
|
|
|
document.getElementById('saveSmartPlaylistSticker').classList.add('hide');
|
|
|
|
|
document.getElementById('saveSmartPlaylistNewest').classList.add('hide');
|
2018-10-29 18:39:55 +00:00
|
|
|
|
var tagList;
|
|
|
|
|
if (settings.featTags)
|
|
|
|
|
tagList = '<option value="any">Any Tag</option>';
|
|
|
|
|
tagList += '<option value="filename">Filename</option>';
|
2018-10-29 18:17:04 +00:00
|
|
|
|
for (var i = 0; i < settings.searchtags.length; i++)
|
|
|
|
|
tagList += '<option value="' + settings.searchtags[i] + '">' + settings.searchtags[i] + '</option>';
|
2018-10-01 17:07:38 +00:00
|
|
|
|
document.getElementById('selectSaveSmartPlaylistTag').innerHTML = tagList;
|
|
|
|
|
if (obj.data.type == 'search') {
|
|
|
|
|
document.getElementById('saveSmartPlaylistSearch').classList.remove('hide');
|
|
|
|
|
document.getElementById('selectSaveSmartPlaylistTag').value = obj.data.tag;
|
|
|
|
|
document.getElementById('inputSaveSmartPlaylistSearchstr').value = obj.data.searchstr;
|
2018-11-27 15:37:17 +00:00
|
|
|
|
if (settings.featAdvsearch) {
|
|
|
|
|
document.getElementById('selectSaveSmartPlaylistTag').parentNode.classList.add('hide');
|
|
|
|
|
document.getElementById('inputSaveSmartPlaylistSearchstr').parentNode.classList.replace('col-md-6','col-md-12');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('selectSaveSmartPlaylistTag').parentNode.classList.remove('hide');
|
|
|
|
|
document.getElementById('inputSaveSmartPlaylistSearchstr').parentNode.classList.replace('col-md-12','col-md-6');
|
|
|
|
|
}
|
2018-10-01 17:07:38 +00:00
|
|
|
|
}
|
|
|
|
|
else if (obj.data.type == 'sticker') {
|
|
|
|
|
document.getElementById('saveSmartPlaylistSticker').classList.remove('hide');
|
2018-11-26 16:17:46 +00:00
|
|
|
|
document.getElementById('selectSaveSmartPlaylistSticker').value = obj.data.sticker;
|
2018-10-01 17:07:38 +00:00
|
|
|
|
document.getElementById('inputSaveSmartPlaylistStickerMaxentries').value = obj.data.maxentries;
|
|
|
|
|
}
|
|
|
|
|
else if (obj.data.type == 'newest') {
|
|
|
|
|
document.getElementById('saveSmartPlaylistNewest').classList.remove('hide');
|
|
|
|
|
var timerange = obj.data.timerange / 24 / 60 / 60;
|
|
|
|
|
document.getElementById('inputSaveSmartPlaylistNewestTimerange').value = timerange;
|
|
|
|
|
}
|
2018-09-29 18:41:58 +00:00
|
|
|
|
modalSaveSmartPlaylist.show();
|
|
|
|
|
nameEl.focus();
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-01 17:07:38 +00:00
|
|
|
|
function chkInt(el, frm) {
|
|
|
|
|
var value = el.value.replace(/\d/g,'');
|
|
|
|
|
if (value != '') {
|
|
|
|
|
el.classList.add('is-invalid');
|
|
|
|
|
frm.classList.add('was-validated');
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
el.classList.remove('is-invalid');
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 18:41:58 +00:00
|
|
|
|
function saveSmartPlaylist() {
|
2018-10-01 17:07:38 +00:00
|
|
|
|
var name = document.getElementById('saveSmartPlaylistName').value;
|
|
|
|
|
var type = document.getElementById('saveSmartPlaylistType').value;
|
|
|
|
|
var valid = name.replace(/[\w\-]/g, '');
|
|
|
|
|
var frm = document.getElementById('saveSmartPlaylistFrm');
|
|
|
|
|
if (name != '' && valid == '') {
|
|
|
|
|
if (type == 'search') {
|
|
|
|
|
var tagEl = document.getElementById('selectSaveSmartPlaylistTag');
|
|
|
|
|
var tag = tagEl.options[tagEl.selectedIndex].value;
|
2018-11-27 15:37:17 +00:00
|
|
|
|
if (settings.featAdvsearch)
|
|
|
|
|
tag = 'expression';
|
2018-10-01 17:07:38 +00:00
|
|
|
|
var searchstr = document.getElementById('inputSaveSmartPlaylistSearchstr').value;
|
|
|
|
|
sendAPI({"cmd": "MPD_API_SMARTPLS_SAVE", "data": {"type": type, "playlist": name, "tag": tag, "searchstr": searchstr}});
|
|
|
|
|
} else if (type == 'sticker') {
|
|
|
|
|
var stickerEl = document.getElementById('selectSaveSmartPlaylistSticker');
|
|
|
|
|
var sticker = stickerEl.options[stickerEl.selectedIndex].value;
|
|
|
|
|
var maxentriesEl = document.getElementById('inputSaveSmartPlaylistStickerMaxentries');
|
|
|
|
|
if (!chkInt(maxentriesEl, frm))
|
|
|
|
|
return;
|
|
|
|
|
var maxentries = maxentriesEl.value;
|
|
|
|
|
sendAPI({"cmd": "MPD_API_SMARTPLS_SAVE", "data": {"type": type, "playlist": name, "sticker": sticker, "maxentries": maxentries}});
|
|
|
|
|
} else if (type == 'newest') {
|
|
|
|
|
var timerangeEl = document.getElementById('inputSaveSmartPlaylistNewestTimerange');
|
|
|
|
|
if (!chkInt(timerangeEl, frm))
|
|
|
|
|
return;
|
|
|
|
|
var timerange = parseInt(timerangeEl.value) * 60 * 60 * 24;
|
2018-10-08 20:45:10 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_SMARTPLS_SAVE", "data": {"type": type, "playlist": name, "timerange": timerange}});
|
2018-10-01 17:07:38 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('saveSmartPlaylistType').classList.add('is-invalid');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-09-29 18:41:58 +00:00
|
|
|
|
modalSaveSmartPlaylist.hide();
|
2018-10-01 17:07:38 +00:00
|
|
|
|
showNotification('Saved smart playlist ' + name, '', '', 'success');
|
2018-09-29 18:41:58 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('saveSmartPlaylistName').classList.add('is-invalid');
|
2018-10-01 17:07:38 +00:00
|
|
|
|
frm.classList.add('was-validated');
|
2018-09-29 18:41:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-22 19:00:26 +00:00
|
|
|
|
function showAddToPlaylist(uri) {
|
|
|
|
|
document.getElementById('addToPlaylistUri').value = uri;
|
|
|
|
|
document.getElementById('addToPlaylistPlaylist').innerHTML = '';
|
2018-08-27 19:34:21 +00:00
|
|
|
|
document.getElementById('addToPlaylistNewPlaylist').value = '';
|
2018-07-31 20:46:53 +00:00
|
|
|
|
document.getElementById('addToPlaylistNewPlaylistDiv').classList.add('hide');
|
|
|
|
|
document.getElementById('addToPlaylistFrm').classList.remove('was-validated');
|
|
|
|
|
document.getElementById('addToPlaylistNewPlaylist').classList.remove('is-invalid');
|
2018-08-01 21:54:53 +00:00
|
|
|
|
toggleBtn('toggleAddToPlaylistBtn',0);
|
|
|
|
|
var streamUrl = document.getElementById('streamUrl')
|
|
|
|
|
streamUrl.focus();
|
|
|
|
|
streamUrl.value = '';
|
|
|
|
|
streamUrl.classList.remove('is-invalid');
|
|
|
|
|
document.getElementById('addStreamFrm').classList.remove('was-validated');
|
|
|
|
|
if (uri != 'stream') {
|
|
|
|
|
document.getElementById('addStreamFooter').classList.add('hide');
|
|
|
|
|
document.getElementById('addStreamFrm').classList.add('hide');
|
|
|
|
|
document.getElementById('addToPlaylistFooter').classList.remove('hide');
|
|
|
|
|
document.getElementById('addToPlaylistFrm').classList.remove('hide');
|
|
|
|
|
document.getElementById('addToPlaylistLabel').innerText = 'Add to playlist';
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementById('addStreamFooter').classList.remove('hide');
|
|
|
|
|
document.getElementById('addStreamFrm').classList.remove('hide');
|
|
|
|
|
document.getElementById('addToPlaylistFooter').classList.add('hide');
|
|
|
|
|
document.getElementById('addToPlaylistFrm').classList.add('hide');
|
|
|
|
|
document.getElementById('addToPlaylistLabel').innerText = 'Add Stream';
|
|
|
|
|
}
|
2018-08-24 10:11:27 +00:00
|
|
|
|
modalAddToPlaylist.show();
|
2018-10-25 20:03:33 +00:00
|
|
|
|
if (settings.featPlaylists) {
|
|
|
|
|
playlistEl = 'addToPlaylistPlaylist';
|
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST","data": {"offset": 0, "filter": "-"}}, getAllPlaylists);
|
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addToPlaylist() {
|
|
|
|
|
var uri = document.getElementById('addToPlaylistUri').value;
|
2018-08-01 21:54:53 +00:00
|
|
|
|
if (uri == 'stream') {
|
|
|
|
|
uri = document.getElementById('streamUrl').value;
|
|
|
|
|
if (uri == '' || uri.indexOf('http') == -1) {
|
|
|
|
|
document.getElementById('streamUrl').classList.add('is-invalid');
|
|
|
|
|
document.getElementById('addStreamFrm').classList.add('was-validated');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
var plistEl = document.getElementById('addToPlaylistPlaylist');
|
|
|
|
|
var plist = plistEl.options[plistEl.selectedIndex].text;
|
2018-07-31 20:46:53 +00:00
|
|
|
|
if (plist == 'New Playlist') {
|
|
|
|
|
var newPl = document.getElementById('addToPlaylistNewPlaylist').value;
|
2018-09-29 08:38:25 +00:00
|
|
|
|
var valid = newPl.replace(/[\w\-]/g, '');
|
2018-07-31 20:46:53 +00:00
|
|
|
|
if (newPl != '' && valid == '') {
|
|
|
|
|
plist = newPl;
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementById('addToPlaylistNewPlaylist').classList.add('is-invalid');
|
|
|
|
|
document.getElementById('addToPlaylistFrm').classList.add('was-validated');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (plist != '') {
|
2018-09-11 18:59:22 +00:00
|
|
|
|
if (uri == 'SEARCH')
|
|
|
|
|
addAllFromSearchPlist(plist);
|
|
|
|
|
else if (uri == 'DATABASE')
|
|
|
|
|
addAllFromBrowseDatabasePlist(plist);
|
2018-07-31 20:46:53 +00:00
|
|
|
|
else
|
2018-09-11 18:59:22 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_ADD_TRACK", "data": {"uri": uri, "plist": plist}});
|
2018-07-31 20:46:53 +00:00
|
|
|
|
modalAddToPlaylist.hide();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('addToPlaylistPlaylist').classList.add('is-invalid');
|
|
|
|
|
document.getElementById('addToPlaylistFrm').classList.add('was-validated');
|
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-01 21:54:53 +00:00
|
|
|
|
function addStream() {
|
|
|
|
|
var streamUrl = document.getElementById('streamUrl').value;
|
|
|
|
|
if (streamUrl != '' && streamUrl.indexOf('http') == 0) {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_ADD_TRACK", "data": {"uri": streamUrl}});
|
2018-08-01 21:54:53 +00:00
|
|
|
|
modalAddToPlaylist.hide();
|
|
|
|
|
showNotification('Added stream ' + streamUrl + 'to queue', '', '', 'success');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('streamUrl').classList.add('is-invalid');
|
|
|
|
|
document.getElementById('addStreamFrm').classList.add('was-validated');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-22 19:00:26 +00:00
|
|
|
|
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;
|
2018-09-29 08:38:25 +00:00
|
|
|
|
var valid = to.replace(/[\w\-]/g, '');
|
2018-07-22 19:00:26 +00:00
|
|
|
|
if (to != '' && to != from && valid == '') {
|
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_RENAME", "data": {"from": from, "to": to}});
|
|
|
|
|
modalRenamePlaylist.hide();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementById('renamePlaylistTo').classList.add('is-invalid');
|
|
|
|
|
document.getElementById('renamePlaylistFrm').classList.add('was-validated');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-01 17:07:38 +00:00
|
|
|
|
function showSmartPlaylist(playlist) {
|
|
|
|
|
sendAPI({"cmd": "MPD_API_SMARTPLS_GET", "data": {"playlist": playlist}}, parseSmartPlaylist);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-03 20:01:50 +00:00
|
|
|
|
function dirname(uri) {
|
|
|
|
|
return uri.replace(/\/[^\/]*$/, '');
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-26 21:25:51 +00:00
|
|
|
|
function b64EncodeUnicode(str) {
|
|
|
|
|
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
|
|
|
|
|
function toSolidBytes(match, p1) {
|
|
|
|
|
return String.fromCharCode('0x' + p1);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function b64DecodeUnicode(str) {
|
|
|
|
|
return decodeURIComponent(atob(str).split('').map(function(c) {
|
|
|
|
|
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
|
|
|
}).join(''));
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 22:03:24 +00:00
|
|
|
|
function addMenuItem(href, text) {
|
2018-09-26 21:25:51 +00:00
|
|
|
|
return '<a class="dropdown-item" href="#" data-href=\'' + b64EncodeUnicode(JSON.stringify(href)) + '\'>' + text +'</a>';
|
2018-09-12 22:03:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 23:03:00 +00:00
|
|
|
|
function hideMenu() {
|
|
|
|
|
var menuEl = document.querySelector('[data-popover]');
|
|
|
|
|
if (menuEl) {
|
2018-09-29 23:12:40 +00:00
|
|
|
|
new Popover(menuEl, {});
|
2018-09-29 23:03:00 +00:00
|
|
|
|
menuEl.Popover.hide();
|
|
|
|
|
menuEl.removeAttribute('data-popover');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-03 20:01:50 +00:00
|
|
|
|
function showMenu(el, event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
2018-10-29 19:41:04 +00:00
|
|
|
|
hideMenu();
|
2018-09-29 23:03:00 +00:00
|
|
|
|
if (el.getAttribute('data-init'))
|
|
|
|
|
return;
|
|
|
|
|
|
2018-07-04 22:49:34 +00:00
|
|
|
|
var type = el.getAttribute('data-type');
|
2018-07-05 19:34:16 +00:00
|
|
|
|
var uri = decodeURI(el.getAttribute('data-uri'));
|
|
|
|
|
var name = el.getAttribute('data-name');
|
2018-07-19 16:33:53 +00:00
|
|
|
|
var nextsongpos = 0;
|
2018-07-04 22:49:34 +00:00
|
|
|
|
if (type == null || uri == null) {
|
|
|
|
|
type = el.parentNode.parentNode.getAttribute('data-type');
|
2018-07-05 19:34:16 +00:00
|
|
|
|
uri = decodeURI(el.parentNode.parentNode.getAttribute('data-uri'));
|
|
|
|
|
name = el.parentNode.parentNode.getAttribute('data-name');
|
2018-07-04 22:49:34 +00:00
|
|
|
|
}
|
2018-07-19 16:33:53 +00:00
|
|
|
|
|
2018-08-14 14:10:00 +00:00
|
|
|
|
if (lastState)
|
2018-09-17 22:25:50 +00:00
|
|
|
|
nextsongpos = lastState.data.nextSongPos;
|
2018-07-04 22:49:34 +00:00
|
|
|
|
|
|
|
|
|
var menu = '';
|
2018-06-25 22:41:44 +00:00
|
|
|
|
if ((app.current.app == 'Browse' && app.current.tab == 'Filesystem') || app.current.app == 'Search' ||
|
2018-09-12 22:03:24 +00:00
|
|
|
|
(app.current.app == 'Browse' && app.current.tab == 'Database')) {
|
|
|
|
|
menu += addMenuItem({"cmd": "appendQueue", "options": [type, uri, name]}, 'Append to queue') +
|
|
|
|
|
(type == 'song' ? addMenuItem({"cmd": "appendAfterQueue", "options": [type, uri, nextsongpos, name]}, 'Add after current playing song') : '') +
|
|
|
|
|
addMenuItem({"cmd": "replaceQueue", "options": [type, uri, name]}, 'Replace queue') +
|
2018-10-25 20:03:33 +00:00
|
|
|
|
(type != 'plist' && type != 'smartpls' && settings.featPlaylists ? addMenuItem({"cmd": "showAddToPlaylist", "options": [uri]}, 'Add to playlist') : '') +
|
2018-09-12 22:03:24 +00:00
|
|
|
|
(type == 'song' ? addMenuItem({"cmd": "songDetails", "options": [uri]}, 'Songdetails') : '') +
|
2018-09-29 23:12:40 +00:00
|
|
|
|
(type == 'plist' || type == 'smartpls' ? addMenuItem({"cmd": "playlistDetails", "options": [uri]}, 'View playlist') : '');
|
2018-09-03 20:01:50 +00:00
|
|
|
|
if (app.current.app == 'Search') {
|
|
|
|
|
var baseuri = dirname(uri);
|
|
|
|
|
menu += '<div class="dropdown-divider"></div>' +
|
2018-09-03 21:49:04 +00:00
|
|
|
|
'<a class="dropdown-item" id="advancedMenuLink" data-toggle="collapse" href="#advancedMenu"><span class="material-icons material-icons-small-left">keyboard_arrow_right</span>Album actions</a>' +
|
2018-09-03 20:01:50 +00:00
|
|
|
|
'<div class="collapse" id="advancedMenu">' +
|
2018-09-12 22:03:24 +00:00
|
|
|
|
addMenuItem({"cmd": "appendQueue", "options": [type, baseuri, name]}, 'Append to queue') +
|
|
|
|
|
addMenuItem({"cmd": "appendAfterQueue", "options": [type, baseuri, nextsongpos, name]}, 'Add after current playing song') +
|
|
|
|
|
addMenuItem({"cmd": "replaceQueue", "options": [type, baseuri, name]}, 'Replace queue') +
|
2018-10-25 20:03:33 +00:00
|
|
|
|
(settings.featPlaylists ? addMenuItem({"cmd": "showAddToPlaylist", "options": [baseuri]}, 'Add to playlist') : '') +
|
2018-09-03 20:01:50 +00:00
|
|
|
|
'</div>';
|
|
|
|
|
}
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'All') {
|
2018-09-12 22:03:24 +00:00
|
|
|
|
menu += addMenuItem({"cmd": "appendQueue", "options": [type, uri, name]}, 'Append to queue') +
|
|
|
|
|
addMenuItem({"cmd": "replaceQueue", "options": [type, uri, name]},'Replace queue') +
|
2018-09-29 23:03:00 +00:00
|
|
|
|
(type == 'smartpls' ? addMenuItem({"cmd": "playlistDetails", "options": [uri]}, 'View playlist') : addMenuItem({"cmd": "playlistDetails", "options": [uri]}, 'Edit playlist'))+
|
2018-10-01 17:07:38 +00:00
|
|
|
|
(type == 'smartpls' ? addMenuItem({"cmd": "showSmartPlaylist", "options": [uri]}, 'Edit smart playlist') : '') +
|
2018-11-27 15:37:17 +00:00
|
|
|
|
addMenuItem({"cmd": "showRenamePlaylist", "options": [uri]}, 'Rename playlist') +
|
|
|
|
|
addMenuItem({"cmd": "showDelPlaylist", "options": [uri]}, 'Delete playlist');
|
2018-06-25 22:41:44 +00:00
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail') {
|
2018-09-12 22:03:24 +00:00
|
|
|
|
var x = document.getElementById('BrowsePlaylistsDetailList');
|
|
|
|
|
menu += addMenuItem({"cmd": "appendQueue", "options": [type, uri, name]}, 'Append to queue') +
|
|
|
|
|
addMenuItem({"cmd": "replaceQueue", "options": [type, uri, name]}, 'Replace queue') +
|
|
|
|
|
(x.getAttribute('data-ro') == 'false' ? addMenuItem({"cmd": "removeFromPlaylist", "options": [x.getAttribute('data-uri'),
|
|
|
|
|
el.parentNode.parentNode.getAttribute('data-songpos')]}, 'Remove') : '') +
|
2018-09-30 01:03:33 +00:00
|
|
|
|
addMenuItem({"cmd": "showAddToPlaylist", "options": [uri]}, 'Add to playlist') +
|
|
|
|
|
(uri.indexOf('http') == -1 ? addMenuItem({"cmd": "songDetails", "options": [uri]}, 'Songdetails') : '');
|
2018-07-22 19:00:26 +00:00
|
|
|
|
}
|
2018-11-14 23:14:47 +00:00
|
|
|
|
else if (app.current.app == 'Queue' && app.current.tab == 'Current') {
|
2018-09-12 22:03:24 +00:00
|
|
|
|
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') +
|
|
|
|
|
(uri.indexOf('http') == -1 ? addMenuItem({"cmd": "songDetails", "options": [uri]}, 'Songdetails') : '');
|
2018-09-18 23:01:37 +00:00
|
|
|
|
}
|
2018-11-15 21:15:15 +00:00
|
|
|
|
else if (app.current.app == 'Queue' && app.current.tab == 'LastPlayed') {
|
|
|
|
|
menu += addMenuItem({"cmd": "appendQueue", "options": [type, uri, name]}, 'Append to queue') +
|
|
|
|
|
addMenuItem({"cmd": "replaceQueue", "options": [type, uri, name]}, 'Replace queue') +
|
|
|
|
|
addMenuItem({"cmd": "showAddToPlaylist", "options": [uri]}, 'Add to playlist') +
|
|
|
|
|
(uri.indexOf('http') == -1 ? addMenuItem({"cmd": "songDetails", "options": [uri]}, 'Songdetails') : '');
|
|
|
|
|
}
|
2018-09-29 23:03:00 +00:00
|
|
|
|
|
2018-09-03 20:01:50 +00:00
|
|
|
|
new Popover(el, { trigger: 'click', delay: 0, dismissible: true, template: '<div class="popover" role="tooltip">' +
|
|
|
|
|
'<div class="arrow"></div>' +
|
|
|
|
|
'<div class="popover-content">' + menu + '</div>' +
|
|
|
|
|
'</div>'});
|
2018-09-03 21:49:04 +00:00
|
|
|
|
var popoverInit = el.Popover;
|
2018-09-18 23:01:37 +00:00
|
|
|
|
el.setAttribute('data-init', 'true');
|
2018-09-03 20:01:50 +00:00
|
|
|
|
el.addEventListener('shown.bs.popover', function(event) {
|
2018-09-29 23:03:00 +00:00
|
|
|
|
event.target.setAttribute('data-popover', 'true');
|
2018-09-03 20:01:50 +00:00
|
|
|
|
document.getElementsByClassName('popover-content')[0].addEventListener('click', function(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
if (event.target.nodeName == 'A') {
|
|
|
|
|
var dh = event.target.getAttribute('data-href');
|
|
|
|
|
if (dh) {
|
2018-09-26 21:25:51 +00:00
|
|
|
|
var cmd = JSON.parse(b64DecodeUnicode(dh));
|
2018-11-11 23:48:49 +00:00
|
|
|
|
parseCmd(event, cmd);
|
2018-09-29 23:03:00 +00:00
|
|
|
|
hideMenu();
|
2018-07-05 19:34:16 +00:00
|
|
|
|
}
|
2018-09-03 20:01:50 +00:00
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
var collapseLink = document.getElementById('advancedMenuLink');
|
|
|
|
|
if (collapseLink) {
|
2018-09-03 21:49:04 +00:00
|
|
|
|
collapseLink.addEventListener('click', function(event) {
|
|
|
|
|
var icon = this.getElementsByTagName('span')[0];
|
|
|
|
|
if (icon.innerText == 'keyboard_arrow_right')
|
|
|
|
|
icon.innerText = 'keyboard_arrow_down';
|
|
|
|
|
else
|
|
|
|
|
icon.innerText = 'keyboard_arrow_right';
|
|
|
|
|
}, false);
|
2018-09-03 20:01:50 +00:00
|
|
|
|
var myCollapseInit = new Collapse(collapseLink);
|
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
|
popoverInit.show();
|
2018-06-24 21:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-19 22:43:36 +00:00
|
|
|
|
function sendAPI(request, callback) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var ajaxRequest=new XMLHttpRequest();
|
|
|
|
|
ajaxRequest.open('POST', '/api', true);
|
|
|
|
|
ajaxRequest.setRequestHeader('Content-type', 'application/json');
|
|
|
|
|
ajaxRequest.onreadystatechange = function() {
|
2018-07-18 22:29:19 +00:00
|
|
|
|
if (ajaxRequest.readyState == 4) {
|
|
|
|
|
if (ajaxRequest.responseText != '') {
|
|
|
|
|
var obj = JSON.parse(ajaxRequest.responseText);
|
|
|
|
|
if (obj.type == 'error') {
|
2018-07-22 19:00:26 +00:00
|
|
|
|
showNotification('Error', obj.data, obj.data, 'danger');
|
2018-07-18 22:29:19 +00:00
|
|
|
|
console.log('Error: ' + obj.data);
|
|
|
|
|
}
|
|
|
|
|
else if (obj.type == 'result' && obj.data != 'ok')
|
|
|
|
|
showNotification(obj.data, '', '', 'success');
|
|
|
|
|
else if (callback != undefined && typeof(callback) == 'function')
|
|
|
|
|
callback(obj);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
console.log('Empty response for request: ' + JSON.stringify(request));
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-28 22:51:24 +00:00
|
|
|
|
};
|
|
|
|
|
ajaxRequest.send(JSON.stringify(request));
|
2018-06-14 19:56:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-02 19:40:27 +00:00
|
|
|
|
function openLocalPlayer() {
|
|
|
|
|
window.open('/player.html#' + settings.mpdstream, 'LocalPlayer');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateDB() {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_UPDATE"});
|
2018-08-27 16:56:40 +00:00
|
|
|
|
updateDBstarted(true);
|
2018-08-24 10:11:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-23 21:48:12 +00:00
|
|
|
|
function rescanDB() {
|
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_RESCAN"});
|
|
|
|
|
updateDBstarted(true);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-27 16:56:40 +00:00
|
|
|
|
function updateDBstarted(showModal) {
|
|
|
|
|
if (showModal == true) {
|
|
|
|
|
document.getElementById('updateDBfinished').innerText = '';
|
|
|
|
|
document.getElementById('updateDBfooter').classList.add('hide');
|
|
|
|
|
updateDBprogress.style.width = '20px';
|
|
|
|
|
updateDBprogress.style.marginLeft = '-20px';
|
|
|
|
|
modalUpdateDB.show();
|
|
|
|
|
document.getElementById('updateDBprogress').classList.add('updateDBprogressAnimate');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
showNotification('Database update started', '', '', 'success');
|
|
|
|
|
}
|
2018-08-24 10:11:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateDBfinished(idleEvent) {
|
2018-08-27 16:56:40 +00:00
|
|
|
|
if (document.getElementById('modalUpdateDB').classList.contains('show')) {
|
|
|
|
|
if (idleEvent == 'update_database')
|
|
|
|
|
document.getElementById('updateDBfinished').innerText = 'Database successfully updated.';
|
|
|
|
|
else if (idleEvent == 'update_finished')
|
|
|
|
|
document.getElementById('updateDBfinished').innerText = 'Database update finished.';
|
|
|
|
|
var updateDBprogress = document.getElementById('updateDBprogress');
|
|
|
|
|
updateDBprogress.classList.remove('updateDBprogressAnimate');
|
|
|
|
|
updateDBprogress.style.width = '100%';
|
|
|
|
|
updateDBprogress.style.marginLeft = '0px';
|
|
|
|
|
document.getElementById('updateDBfooter').classList.remove('hide');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (idleEvent == 'update_database')
|
|
|
|
|
showNotification('Database successfully updated.', '', '', 'success');
|
|
|
|
|
else if (idleEvent == 'update_finished')
|
|
|
|
|
showNotification('Database update finished.', '', '', 'success');
|
|
|
|
|
}
|
2013-11-04 17:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-17 15:26:26 +00:00
|
|
|
|
function clickPlay() {
|
2018-07-24 22:58:29 +00:00
|
|
|
|
if (playstate != 'play')
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_PLAY"});
|
2014-01-17 15:26:26 +00:00
|
|
|
|
else
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_PAUSE"});
|
2014-01-17 15:26:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-10 16:54:57 +00:00
|
|
|
|
function clickStop() {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_STOP"});
|
2018-06-10 16:54:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-18 21:26:00 +00:00
|
|
|
|
function clickPrev() {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_PREV"});
|
2018-06-18 21:26:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clickNext() {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_NEXT"});
|
2014-05-24 16:23:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 19:34:16 +00:00
|
|
|
|
function delQueueSong(mode, start, end) {
|
|
|
|
|
if (mode == 'range')
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_RM_RANGE", "data": {"start": start, "end": end}});
|
2018-07-05 19:34:16 +00:00
|
|
|
|
else if (mode == 'single')
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_RM_TRACK", "data": { "track": start}});
|
2017-04-08 09:25:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-14 21:08:10 +00:00
|
|
|
|
function showDelPlaylist(uri) {
|
|
|
|
|
document.getElementById('deletePlaylist').value = uri;
|
|
|
|
|
modalDeletePlaylist.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delPlaylist() {
|
|
|
|
|
var uri = document.getElementById('deletePlaylist').value;
|
2018-10-14 21:38:34 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYLIST_RM", "data": {"uri": uri}});
|
2018-10-14 21:08:10 +00:00
|
|
|
|
modalDeletePlaylist.hide();
|
2018-05-29 20:12:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-28 18:48:43 +00:00
|
|
|
|
function confirmSettings() {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var formOK = true;
|
|
|
|
|
var inputCrossfade = document.getElementById('inputCrossfade');
|
|
|
|
|
if (!inputCrossfade.getAttribute('disabled')) {
|
2018-07-05 21:56:42 +00:00
|
|
|
|
var value = parseInt(inputCrossfade.value);
|
2018-08-22 12:06:22 +00:00
|
|
|
|
if (!isNaN(value))
|
2018-07-05 21:56:42 +00:00
|
|
|
|
inputCrossfade.value = value;
|
2018-08-22 12:06:22 +00:00
|
|
|
|
else {
|
2018-07-05 21:56:42 +00:00
|
|
|
|
inputCrossfade.classList.add('is-invalid');
|
|
|
|
|
formOK = false;
|
|
|
|
|
}
|
2018-05-28 18:48:43 +00:00
|
|
|
|
}
|
2018-09-30 01:03:33 +00:00
|
|
|
|
var inputJukeboxQueueLength = document.getElementById('inputJukeboxQueueLength');
|
|
|
|
|
var value = parseInt(inputJukeboxQueueLength.value);
|
|
|
|
|
if (!isNaN(value)) {
|
|
|
|
|
if (value > 0) {
|
|
|
|
|
inputJukeboxQueueLength.value = value;
|
|
|
|
|
} else {
|
|
|
|
|
inputJukeboxQueueLength.classList.add('is-invalid');
|
|
|
|
|
formOK = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
inputJukeboxQueueLength.classList.add('is-invalid');
|
|
|
|
|
formOK = false;
|
|
|
|
|
}
|
2018-08-21 22:02:22 +00:00
|
|
|
|
if (settings.mixramp) {
|
|
|
|
|
var inputMixrampdb = document.getElementById('inputMixrampdb');
|
|
|
|
|
if (!inputMixrampdb.getAttribute('disabled')) {
|
|
|
|
|
var value = parseFloat(inputMixrampdb.value);
|
2018-08-22 12:06:22 +00:00
|
|
|
|
if (!isNaN(value))
|
2018-08-21 22:02:22 +00:00
|
|
|
|
inputMixrampdb.value = value;
|
2018-08-22 12:06:22 +00:00
|
|
|
|
else {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
inputMixrampdb.classList.add('is-invalid');
|
|
|
|
|
formOK = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var inputMixrampdelay = document.getElementById('inputMixrampdelay');
|
|
|
|
|
if (!inputMixrampdelay.getAttribute('disabled')) {
|
2018-08-22 12:06:22 +00:00
|
|
|
|
if (inputMixrampdelay.value == 'nan')
|
|
|
|
|
inputMixrampdelay.value = '-1';
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var value = parseFloat(inputMixrampdelay.value);
|
2018-08-22 12:06:22 +00:00
|
|
|
|
if (!isNaN(value))
|
2018-08-21 22:02:22 +00:00
|
|
|
|
inputMixrampdelay.value = value;
|
2018-08-22 12:06:22 +00:00
|
|
|
|
else {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
inputMixrampdelay.classList.add('is-invalid');
|
|
|
|
|
formOK = false;
|
|
|
|
|
}
|
2018-07-05 21:56:42 +00:00
|
|
|
|
}
|
2018-05-31 20:23:57 +00:00
|
|
|
|
}
|
2018-08-21 22:02:22 +00:00
|
|
|
|
|
2018-05-31 20:23:57 +00:00
|
|
|
|
if (formOK == true) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var selectReplaygain = document.getElementById('selectReplaygain');
|
2018-09-30 01:03:33 +00:00
|
|
|
|
var selectJukeboxPlaylist = document.getElementById('selectJukeboxPlaylist');
|
|
|
|
|
var selectJukeboxMode = document.getElementById('selectJukeboxMode');
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_SETTINGS_SET", "data": {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
"consume": (document.getElementById('btnConsume').classList.contains('active') ? 1 : 0),
|
|
|
|
|
"random": (document.getElementById('btnRandom').classList.contains('active') ? 1 : 0),
|
|
|
|
|
"single": (document.getElementById('btnSingle').classList.contains('active') ? 1 : 0),
|
|
|
|
|
"repeat": (document.getElementById('btnRepeat').classList.contains('active') ? 1 : 0),
|
|
|
|
|
"replaygain": selectReplaygain.options[selectReplaygain.selectedIndex].value,
|
|
|
|
|
"crossfade": document.getElementById('inputCrossfade').value,
|
2018-08-21 22:02:22 +00:00
|
|
|
|
"mixrampdb": (settings.mixramp == true ? document.getElementById('inputMixrampdb').value : settings.mixrampdb),
|
|
|
|
|
"mixrampdelay": (settings.mixramp == true ? document.getElementById('inputMixrampdelay').value : settings.mixrampdelay),
|
2018-09-17 22:25:50 +00:00
|
|
|
|
"notificationWeb": (document.getElementById('btnnotifyWeb').classList.contains('active') ? true : false),
|
|
|
|
|
"notificationPage": (document.getElementById('btnnotifyPage').classList.contains('active') ? true : false),
|
2018-09-30 01:03:33 +00:00
|
|
|
|
"jukeboxMode": selectJukeboxMode.options[selectJukeboxMode.selectedIndex].value,
|
|
|
|
|
"jukeboxPlaylist": selectJukeboxPlaylist.options[selectJukeboxPlaylist.selectedIndex].value,
|
|
|
|
|
"jukeboxQueueLength": document.getElementById('inputJukeboxQueueLength').value
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}}, getSettings);
|
2018-07-02 22:02:02 +00:00
|
|
|
|
modalSettings.hide();
|
2018-08-22 12:06:22 +00:00
|
|
|
|
} else
|
2018-06-28 22:51:24 +00:00
|
|
|
|
document.getElementById('settingsFrm').classList.add('was-validated');
|
2018-05-28 18:48:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-10 20:51:53 +00:00
|
|
|
|
function addAllFromBrowseFilesystem() {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_ADD_TRACK", "data": {"uri": app.current.search}});
|
2018-07-05 19:34:16 +00:00
|
|
|
|
showNotification('Added all songs', '', '', 'success');
|
2018-07-02 19:40:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-11 18:59:22 +00:00
|
|
|
|
function addAllFromSearchPlist(plist) {
|
2018-11-27 15:37:17 +00:00
|
|
|
|
var nr = parseInt(document.getElementById('panel-heading-search').innerText);
|
2018-12-03 20:11:00 +00:00
|
|
|
|
if (!isNaN(nr) && nr > 0) {
|
2018-11-27 15:37:17 +00:00
|
|
|
|
if (settings.featAdvsearch)
|
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_SEARCH_ADV", "data": {"plist": plist, "sort": "", "sortdesc": false, "expression": app.current.search, "offset": 0}});
|
|
|
|
|
else
|
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_SEARCH", "data": {"plist": plist, "filter": app.current.filter, "searchstr": app.current.search, "offset": 0}});
|
|
|
|
|
showNotification('Added ' + nr +' songs from search to ' + plist, '', '', 'success');
|
2018-05-31 23:05:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-11 18:59:22 +00:00
|
|
|
|
function addAllFromBrowseDatabasePlist(plist) {
|
2018-07-31 20:46:53 +00:00
|
|
|
|
if (app.current.search.length >= 2) {
|
2018-09-11 18:59:22 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_DATABASE_SEARCH", "data": {"plist": plist, "filter": app.current.view, "searchstr": app.current.search, "offset": 0}});
|
|
|
|
|
showNotification('Added songs from database selection to ' + plist, '', '', 'success');
|
2018-07-31 20:46:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-09 15:36:45 +00:00
|
|
|
|
function scrollTo(pos) {
|
|
|
|
|
document.body.scrollTop = pos; // For Safari
|
|
|
|
|
document.documentElement.scrollTop = pos; // For Chrome, Firefox, IE and Opera
|
2018-05-27 20:21:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
function gotoPage(x) {
|
2018-05-27 20:21:18 +00:00
|
|
|
|
switch (x) {
|
2018-06-26 22:46:29 +00:00
|
|
|
|
case 'next':
|
2018-08-21 22:56:17 +00:00
|
|
|
|
app.current.page += settings.maxElementsPerPage;
|
2018-05-27 20:21:18 +00:00
|
|
|
|
break;
|
2018-06-26 22:46:29 +00:00
|
|
|
|
case 'prev':
|
2018-08-21 22:56:17 +00:00
|
|
|
|
app.current.page -= settings.maxElementsPerPage;
|
2018-08-21 22:02:22 +00:00
|
|
|
|
if (app.current.page < 0)
|
2018-06-26 22:46:29 +00:00
|
|
|
|
app.current.page = 0;
|
2018-05-27 20:21:18 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2018-06-10 19:31:40 +00:00
|
|
|
|
app.current.page = x;
|
2018-05-27 20:21:18 +00:00
|
|
|
|
}
|
2018-07-02 19:40:27 +00:00
|
|
|
|
appGoto(app.current.app, app.current.tab, app.current.view, app.current.page + '/' + app.current.filter + '/' + app.current.search);
|
2018-05-27 20:21:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-02 17:24:52 +00:00
|
|
|
|
function saveQueue() {
|
2018-07-22 19:42:01 +00:00
|
|
|
|
var plName = document.getElementById('saveQueueName').value;
|
2018-09-29 08:38:25 +00:00
|
|
|
|
var valid = plName.replace(/[\w\-]/g, '');
|
2018-07-22 19:42:01 +00:00
|
|
|
|
if (plName != '' && valid == '') {
|
2018-08-27 18:47:00 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_QUEUE_SAVE", "data": {"plist": plName}});
|
2018-07-22 19:16:31 +00:00
|
|
|
|
modalSavequeue.hide();
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-09-29 08:38:25 +00:00
|
|
|
|
alert(valid);
|
2018-07-22 19:16:31 +00:00
|
|
|
|
document.getElementById('saveQueueName').classList.add('is-invalid');
|
|
|
|
|
document.getElementById('saveQueueFrm').classList.add('was-validated');
|
|
|
|
|
}
|
2015-09-02 17:24:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-22 23:07:34 +00:00
|
|
|
|
function showNotification(notificationTitle,notificationText,notificationHtml,notificationType) {
|
2018-09-17 22:25:50 +00:00
|
|
|
|
if (settings.notificationWeb == true) {
|
2018-08-22 12:06:22 +00:00
|
|
|
|
var notification = new Notification(notificationTitle, {icon: 'assets/favicon.ico', body: notificationText});
|
|
|
|
|
setTimeout(function(notification) {
|
|
|
|
|
notification.close();
|
|
|
|
|
}, 3000, notification);
|
2018-05-22 23:07:34 +00:00
|
|
|
|
}
|
2018-09-17 22:25:50 +00:00
|
|
|
|
if (settings.notificationPage == true) {
|
2018-07-02 19:59:56 +00:00
|
|
|
|
var alertBox;
|
|
|
|
|
if (!document.getElementById('alertBox')) {
|
|
|
|
|
alertBox = document.createElement('div');
|
2018-07-09 17:28:28 +00:00
|
|
|
|
alertBox.setAttribute('id', 'alertBox');
|
2018-07-10 23:12:36 +00:00
|
|
|
|
alertBox.addEventListener('click', function() {
|
|
|
|
|
hideNotification();
|
|
|
|
|
}, false);
|
2018-07-02 19:59:56 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
alertBox = document.getElementById('alertBox');
|
|
|
|
|
}
|
2018-07-22 19:00:26 +00:00
|
|
|
|
alertBox.classList.remove('alert-success', 'alert-danger');
|
2018-07-02 19:59:56 +00:00
|
|
|
|
alertBox.classList.add('alert','alert-' + notificationType);
|
2018-07-18 22:29:19 +00:00
|
|
|
|
alertBox.innerHTML = '<div><strong>' + notificationTitle + '</strong><br/>' + notificationHtml + '</div>';
|
2018-07-02 19:59:56 +00:00
|
|
|
|
document.getElementsByTagName('main')[0].append(alertBox);
|
|
|
|
|
document.getElementById('alertBox').classList.add('alertBoxActive');
|
2018-07-05 19:34:16 +00:00
|
|
|
|
if (alertTimeout)
|
|
|
|
|
clearTimeout(alertTimeout);
|
|
|
|
|
alertTimeout = setTimeout(function() {
|
2018-07-10 23:12:36 +00:00
|
|
|
|
hideNotification();
|
2018-07-01 22:49:47 +00:00
|
|
|
|
}, 3000);
|
2018-05-22 23:07:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-10 23:12:36 +00:00
|
|
|
|
function hideNotification() {
|
|
|
|
|
if (document.getElementById('alertBox')) {
|
|
|
|
|
document.getElementById('alertBox').classList.remove('alertBoxActive');
|
|
|
|
|
setTimeout(function() {
|
2018-08-22 12:06:22 +00:00
|
|
|
|
var alertBox = document.getElementById('alertBox');
|
|
|
|
|
if (alertBox)
|
|
|
|
|
alertBox.remove();
|
2018-07-10 23:12:36 +00:00
|
|
|
|
}, 600);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-17 17:34:22 +00:00
|
|
|
|
function notificationsSupported() {
|
2014-05-24 00:57:30 +00:00
|
|
|
|
return "Notification" in window;
|
2014-01-17 17:34:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-19 23:23:08 +00:00
|
|
|
|
function songChange(obj) {
|
2018-07-22 19:00:26 +00:00
|
|
|
|
if (obj.type == 'error' || obj.type == 'result')
|
2018-07-18 21:47:37 +00:00
|
|
|
|
return;
|
2018-10-17 22:04:06 +00:00
|
|
|
|
var curSong = obj.data.Title + obj.data.Artist + obj.data.Album + obj.data.uri + obj.data.currentSongId;
|
2018-08-14 14:10:00 +00:00
|
|
|
|
if (lastSong == curSong)
|
2018-06-11 17:33:11 +00:00
|
|
|
|
return;
|
2018-05-22 23:07:34 +00:00
|
|
|
|
var textNotification = '';
|
|
|
|
|
var htmlNotification = '';
|
|
|
|
|
var pageTitle = 'myMPD: ';
|
2018-05-23 23:42:20 +00:00
|
|
|
|
|
2018-08-21 22:02:22 +00:00
|
|
|
|
domCache.currentCover.style.backgroundImage = 'url("' + obj.data.cover + '")';
|
2018-06-22 00:01:15 +00:00
|
|
|
|
|
2018-10-17 22:04:06 +00:00
|
|
|
|
if (typeof obj.data.Artist != 'undefined' && obj.data.Artist.length > 0 && obj.data.Artist != '-') {
|
|
|
|
|
textNotification += obj.data.Artist;
|
|
|
|
|
htmlNotification += obj.data.Artist;
|
|
|
|
|
pageTitle += obj.data.Artist + ' - ';
|
2018-11-04 23:26:59 +00:00
|
|
|
|
}
|
2018-08-22 12:06:22 +00:00
|
|
|
|
|
2018-10-17 22:04:06 +00:00
|
|
|
|
if (typeof obj.data.Album != 'undefined' && obj.data.Album.length > 0 && obj.data.Album != '-') {
|
|
|
|
|
textNotification += ' - ' + obj.data.Album;
|
|
|
|
|
htmlNotification += '<br/>' + obj.data.Album;
|
2018-05-23 23:42:20 +00:00
|
|
|
|
}
|
2018-08-22 12:06:22 +00:00
|
|
|
|
|
2018-10-17 22:04:06 +00:00
|
|
|
|
if (typeof obj.data.Title != 'undefined' && obj.data.Title.length > 0) {
|
|
|
|
|
pageTitle += obj.data.Title;
|
2018-11-04 23:26:59 +00:00
|
|
|
|
domCache.currentTitle.innerText = obj.data.Title;
|
|
|
|
|
domCache.currentTitle.setAttribute('data-uri', encodeURI(obj.data.uri));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
domCache.currentTitle.innerText = '';
|
|
|
|
|
domCache.currentTitle.setAttribute('data-uri', '');
|
2018-05-22 23:07:34 +00:00
|
|
|
|
}
|
|
|
|
|
document.title = pageTitle;
|
2018-08-22 12:06:22 +00:00
|
|
|
|
|
2018-10-25 20:03:33 +00:00
|
|
|
|
if (settings.featStickers == true) {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
setVoteSongBtns(obj.data.like, obj.data.uri);
|
|
|
|
|
}
|
2018-11-04 23:26:59 +00:00
|
|
|
|
|
|
|
|
|
for (var i = 0; i < settings.colsPlayback.length; i++) {
|
|
|
|
|
var c = document.getElementById('current' + settings.colsPlayback[i]);
|
2018-11-05 19:57:06 +00:00
|
|
|
|
c.getElementsByTagName('h4')[0].innerText = obj.data[settings.colsPlayback[i]];
|
2018-11-04 23:26:59 +00:00
|
|
|
|
c.setAttribute('data-name', encodeURI(obj.data[settings.colsPlayback[i]]));
|
|
|
|
|
}
|
2018-08-21 22:02:22 +00:00
|
|
|
|
|
2018-07-05 19:34:16 +00:00
|
|
|
|
//Update Artist in queue view for http streams
|
2018-08-14 14:10:00 +00:00
|
|
|
|
var playingTr = document.getElementById('queueTrackId' + obj.data.currentSongId);
|
2018-07-05 19:34:16 +00:00
|
|
|
|
if (playingTr)
|
2018-10-17 22:04:06 +00:00
|
|
|
|
playingTr.getElementsByTagName('td')[1].innerText = obj.data.Title;
|
2018-07-05 19:34:16 +00:00
|
|
|
|
|
2018-11-05 21:49:57 +00:00
|
|
|
|
if (playstate == 'play')
|
|
|
|
|
showNotification(obj.data.Title, textNotification, htmlNotification, 'success');
|
2018-08-14 14:10:00 +00:00
|
|
|
|
lastSong = curSong;
|
2018-11-05 19:57:06 +00:00
|
|
|
|
lastSongObj = obj;
|
2014-01-17 17:34:22 +00:00
|
|
|
|
}
|
2015-09-13 08:38:18 +00:00
|
|
|
|
|
2018-06-04 18:31:05 +00:00
|
|
|
|
function doSetFilterLetter(x) {
|
2018-08-21 22:02:22 +00:00
|
|
|
|
var af = document.getElementById(x + 'Letters').getElementsByClassName('active')[0];
|
2018-06-28 22:51:24 +00:00
|
|
|
|
if (af)
|
|
|
|
|
af.classList.remove('active');
|
|
|
|
|
var filter = app.current.filter;
|
|
|
|
|
if (filter == '0')
|
|
|
|
|
filter = '#';
|
|
|
|
|
|
|
|
|
|
document.getElementById(x).innerText = 'Filter' + (filter != '-' ? ': '+filter : '');
|
|
|
|
|
|
|
|
|
|
if (filter != '-') {
|
|
|
|
|
var btns = document.getElementById(x + 'Letters').getElementsByTagName('button');
|
|
|
|
|
var btnsLen = btns.length;
|
2018-07-15 23:56:58 +00:00
|
|
|
|
for (var i = 0; i < btnsLen; i++) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
if (btns[i].innerText == filter) {
|
|
|
|
|
btns[i].classList.add('active');
|
|
|
|
|
break;
|
2018-06-04 18:31:05 +00:00
|
|
|
|
}
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}
|
2018-06-04 18:31:05 +00:00
|
|
|
|
}
|
2016-06-08 21:20:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
function addFilterLetter(x) {
|
|
|
|
|
var filter = '<button class="mr-1 mb-1 btn btn-sm btn-secondary material-icons material-icons-small">delete</button>' +
|
|
|
|
|
'<button class="mr-1 mb-1 btn btn-sm btn-secondary">#</button>';
|
2018-08-22 12:06:22 +00:00
|
|
|
|
for (var i = 65; i <= 90; i++)
|
2018-06-28 22:51:24 +00:00
|
|
|
|
filter += '<button class="mr-1 mb-1 btn-sm btn btn-secondary">' + String.fromCharCode(i) + '</button>';
|
2018-08-22 12:06:22 +00:00
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var letters = document.getElementById(x);
|
|
|
|
|
letters.innerHTML = filter;
|
|
|
|
|
|
|
|
|
|
letters.addEventListener('click', function(event) {
|
|
|
|
|
switch (event.target.innerText) {
|
|
|
|
|
case 'delete':
|
|
|
|
|
filter = '-';
|
|
|
|
|
break;
|
|
|
|
|
case '#':
|
|
|
|
|
filter = '0';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
filter = event.target.innerText;
|
|
|
|
|
}
|
2018-07-02 19:40:27 +00:00
|
|
|
|
appGoto(app.current.app, app.current.tab, app.current.view, '0/' + filter + '/' + app.current.search);
|
2018-06-28 22:51:24 +00:00
|
|
|
|
}, false);
|
2016-06-08 21:20:27 +00:00
|
|
|
|
}
|
2018-05-21 23:36:05 +00:00
|
|
|
|
|
2018-09-11 18:59:22 +00:00
|
|
|
|
function selectTag(btnsEl, desc, setTo) {
|
|
|
|
|
var btns = document.getElementById(btnsEl);
|
|
|
|
|
var aBtn = btns.querySelector('.active')
|
|
|
|
|
if (aBtn)
|
|
|
|
|
aBtn.classList.remove('active');
|
|
|
|
|
aBtn = btns.querySelector('[data-tag=' + setTo + ']');
|
|
|
|
|
if (aBtn) {
|
|
|
|
|
aBtn.classList.add('active');
|
|
|
|
|
document.getElementById(desc).innerText = aBtn.innerText;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-29 18:39:55 +00:00
|
|
|
|
|
2018-10-29 18:17:04 +00:00
|
|
|
|
function addTagList(el, list) {
|
|
|
|
|
var tagList = '';
|
|
|
|
|
if (list == 'searchtags') {
|
|
|
|
|
if (settings.featTags == true)
|
|
|
|
|
tagList += '<button type="button" class="btn btn-secondary btn-sm btn-block" data-tag="any">Any Tag</button>';
|
2018-10-29 18:39:55 +00:00
|
|
|
|
tagList += '<button type="button" class="btn btn-secondary btn-sm btn-block" data-tag="filename">Filename</button>';
|
2018-10-29 18:17:04 +00:00
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < settings[list].length; i++)
|
|
|
|
|
tagList += '<button type="button" class="btn btn-secondary btn-sm btn-block" data-tag="' + settings[list][i] + '">' + settings[list][i] + '</button>';
|
|
|
|
|
document.getElementById(el).innerHTML = tagList;
|
|
|
|
|
}
|
2018-09-11 18:59:22 +00:00
|
|
|
|
|
2018-09-10 20:32:15 +00:00
|
|
|
|
function gotoTagList() {
|
|
|
|
|
appGoto(app.current.app, app.current.tab, app.current.view, '0/-/');
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-05 23:13:22 +00:00
|
|
|
|
function openModal(modal) {
|
|
|
|
|
window[modal].show();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 23:59:44 +00:00
|
|
|
|
function openDropdown(dropdown) {
|
|
|
|
|
window[dropdown].toggle();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-08 22:42:45 +00:00
|
|
|
|
function focusSearch() {
|
|
|
|
|
if (app.current.app == 'Queue')
|
|
|
|
|
document.getElementById('searchqueuestr').focus();
|
|
|
|
|
else if (app.current.app == 'Search')
|
2018-11-27 19:45:35 +00:00
|
|
|
|
domCache.searchstr.focus();
|
2018-11-08 22:42:45 +00:00
|
|
|
|
else
|
|
|
|
|
appGoto('Search');
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-28 22:51:24 +00:00
|
|
|
|
function chVolume(increment) {
|
|
|
|
|
var newValue = parseInt(domCache.volumeBar.value) + increment;
|
|
|
|
|
if (newValue < 0)
|
|
|
|
|
newValue = 0;
|
|
|
|
|
else if (newValue > 100)
|
2018-08-21 22:02:22 +00:00
|
|
|
|
newValue = 100;
|
2018-06-28 22:51:24 +00:00
|
|
|
|
domCache.volumeBar.value = newValue;
|
2018-10-11 19:50:26 +00:00
|
|
|
|
sendAPI({"cmd": "MPD_API_PLAYER_VOLUME_SET", "data": {"volume": newValue}});
|
2018-05-27 21:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function beautifyDuration(x) {
|
2018-06-28 22:51:24 +00:00
|
|
|
|
var days = Math.floor(x / 86400);
|
|
|
|
|
var hours = Math.floor(x / 3600) - days * 24;
|
|
|
|
|
var minutes = Math.floor(x / 60) - hours * 60 - days * 1440;
|
|
|
|
|
var seconds = x - days * 86400 - hours * 3600 - minutes * 60;
|
|
|
|
|
|
|
|
|
|
return (days > 0 ? days + '\u2009d ' : '') +
|
|
|
|
|
(hours > 0 ? hours + '\u2009h ' + (minutes < 10 ? '0' : '') : '') +
|
|
|
|
|
minutes + '\u2009m ' + (seconds < 10 ? '0' : '') + seconds + '\u2009s';
|
2018-06-03 19:35:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function genId(x) {
|
2018-09-12 23:11:58 +00:00
|
|
|
|
return 'id' + x.replace(/[^\w\-]/g, '');
|
2018-06-29 06:52:32 +00:00
|
|
|
|
}
|
2018-07-02 19:59:56 +00:00
|
|
|
|
|
|
|
|
|
//Init app
|
2018-07-05 21:56:42 +00:00
|
|
|
|
appInit();
|