1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-12-25 10:30:26 +00:00

Merge pull request #75 from jcorporation/devel

Merge devel into master for 4.6.0 release
This commit is contained in:
Jürgen Mang 2018-11-15 23:13:44 +01:00 committed by GitHub
commit b3a0d0d3a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 1198 additions and 502 deletions

View File

@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 2.6)
project (mympd C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
set(CPACK_PACKAGE_VERSION_MAJOR "4")
set(CPACK_PACKAGE_VERSION_MINOR "5")
set(CPACK_PACKAGE_VERSION_PATCH "1")
set(CPACK_PACKAGE_VERSION_MINOR "6")
set(CPACK_PACKAGE_VERSION_PATCH "0")
if(CMAKE_BUILD_TYPE MATCHES RELEASE)
set(ASSETS_PATH "/usr/share/${PROJECT_NAME}/htdocs")
@ -52,6 +52,7 @@ install(FILES dist/htdocs/sw.min.js DESTINATION share/${PROJECT_NAME}/htdocs/)
install(FILES dist/htdocs/js/player.min.js DESTINATION share/${PROJECT_NAME}/htdocs/js/)
install(FILES dist/htdocs/js/bootstrap-native-v4.min.js DESTINATION share/${PROJECT_NAME}/htdocs/js/)
install(FILES dist/htdocs/js/mympd.min.js DESTINATION share/${PROJECT_NAME}/htdocs/js/)
install(FILES dist/htdocs/js/keymap.min.js DESTINATION share/${PROJECT_NAME}/htdocs/js/)
install(FILES dist/htdocs/css/bootstrap.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/)
install(FILES dist/htdocs/css/mympd.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/)
install(DIRECTORY htdocs/assets DESTINATION share/${PROJECT_NAME}/htdocs)

View File

@ -4,7 +4,7 @@
pkgname=mympd
_pkgname=myMPD
pkgver=4.5.1
pkgver=4.6.0
pkgrel=1
pkgdesc="myMPD is a standalone and mobile friendly web mpdclient."
arch=('x86_64' 'armv7h' 'aarch64')

View File

@ -67,10 +67,12 @@ post_upgrade() {
[ -f /var/lib/mympd/state/notificationPage ] || echo -n "true" > /var/lib/mympd/state/notificationPage
[ -f /var/lib/mympd/state/notificationWeb ] || echo -n "false" > /var/lib/mympd/state/notificationWeb
[ -f /var/lib/mympd/state/colsBrowseDatabase ] || echo -n '["Track","Title","Duration"]' > /var/lib/mympd/state/colsBrowseDatabase
[ -f /var/lib/mympd/state/colsPlayback ] || echo -n '["Artist","Album","Genre"]' > /var/lib/mympd/state/colsPlayback
[ -f /var/lib/mympd/state/colsBrowseFilesystem ] || echo -n '["Type","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowseFilesystem
[ -f /var/lib/mympd/state/colsBrowsePlaylistsDetail ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowsePlaylistsDetail
[ -f /var/lib/mympd/state/colsQueue ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueue
[ -f /var/lib/mympd/state/colsQueueCurrent ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueueCurrent
[ -f /var/lib/mympd/state/colsSearch ] || echo -n '["Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsSearch
[ -f /var/lib/mympd/state/colsQueueLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsQueueLastPlayed
# fix ownership of /var/lib/mympd
echo "INFO: Fixing ownership of /var/lib/mympd"

View File

@ -4,7 +4,7 @@
# (c) 2018 Juergen Mang <mail@jcgames.de>
Name: myMPD
Version: 4.5.1
Version: 4.6.0
Release: 0
License: GPL-2.0
Group: Productivity/Multimedia/Sound/Players
@ -83,9 +83,11 @@ done
[ -f /var/lib/mympd/state/notificationWeb ] || echo -n "false" > /var/lib/mympd/state/notificationWeb
[ -f /var/lib/mympd/state/colsBrowseDatabase ] || echo -n '["Track","Title","Duration"]' > /var/lib/mympd/state/colsBrowseDatabase
[ -f /var/lib/mympd/state/colsBrowseFilesystem ] || echo -n '["Type","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowseFilesystem
[ -f /var/lib/mympd/state/colsPlayback ] || echo -n '["Artist","Album","Genre"]' > /var/lib/mympd/state/colsPlayback
[ -f /var/lib/mympd/state/colsBrowsePlaylistsDetail ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowsePlaylistsDetail
[ -f /var/lib/mympd/state/colsQueue ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueue
[ -f /var/lib/mympd/state/colsQueueCurrent ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueueCurrent
[ -f /var/lib/mympd/state/colsSearch ] || echo -n '["Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsSearch
[ -f /var/lib/mympd/state/colsQueueLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsQueueLastPlayed
echo "Fixing ownership of /var/lib/mympd"
chown -R mympd.mympd /var/lib/mympd

View File

@ -24,7 +24,7 @@ localplayer = true
streamport = 8000
#Manual streamurl, overwrites streamport
#streamurl = http://jukebox:8000
#streamurl = http://mpdhost:8000
#Enable coverimages
coverimage = true
@ -54,3 +54,6 @@ syscmds = false
#Elements per page for pagination, max: 400
max_elements_per_page = 100
#Number of songs to keep in last played list
last_played_count = 20

View File

@ -1,6 +1,7 @@
[Unit]
Description=myMPD server daemon
Requires=network.target local-fs.target mpd.service
After=mpd.service
[Service]
ExecStart=/usr/bin/mympd /etc/mympd/mympd.conf

4
debian/changelog vendored
View File

@ -1,5 +1,5 @@
mympd (4.5.0-1) stable; urgency=medium
mympd (4.6.0-1) stable; urgency=medium
* Release from master
-- Juergen Mang <mail@jcgames.de> Sun, 04 Nov 2018 19:11:17 +0100
-- Juergen Mang <mail@jcgames.de> Thu, 15 Nov 2018 22:11:49 +0000

4
debian/postinst vendored
View File

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

View File

@ -1 +1 @@
html{position:relative;min-height:100%}body{margin-bottom:60px;padding-top:50px;padding-bottom:50px;background-color:#888}main{padding-top:20px}footer{position:absolute;bottom:0}button{overflow:hidden}#BrowseBreadrumb{overflow:auto;white-space:nowrap}#BrowseBreadcrumb>li>a{cursor:pointer}@media only screen and (max-width:576px){.header-logo{display:none!important}}.clickable{cursor:pointer}[data-col=Pos],[data-col=Type],[data-col=Track],[data-col=Action]{width:30px}small{color:#aaa}.card{min-height:300px}.card-footer-playback{padding:0}.album-cover{background-size:cover;background-image:url("/assets/coverimage-loading.png");border:1px solid black;border-radius:5px;overflow:hidden;width:240px;height:240px;background-color:#eee;float:left;margin-right:20px;margin-bottom:20px}.album-desc{min-width:240px;float:left}.hide{display:none!important}.pull-right{float:right!important}.card-toolbar{margin-bottom:10px}.card-toolbar>div,.card-toolbar>form{margin-bottom:5px}@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(/assets/MaterialIcons-Regular.woff2) format('woff2'),url(/assets/MaterialIcons-Regular.woff) format('woff'),url(/assets/MaterialIcons-Regular.ttf) format('truetype')}.material-icons{font-family:'Material Icons';font-weight:normal;font-style:normal;font-size:18px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;vertical-align:top;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:'liga'}.material-icons-left{font-size:1rem;margin-left:-1em;vertical-align:middle}.material-icons-small{font-size:16px}.material-icons-small-left{font-size:1rem;margin-left:-1em}.color-darkgrey,.color-darkgrey:hover{color:#6c757d!important}#btn-outputs-block>button{margin-bottom:10px}#btn-outputs-block>button:last-child{margin-bottom:0}.card-body{overflow-x:hidden}.progressBarPlay{font-size:22px}#counter{cursor:text}#volumeBar{margin-top:2px;width:160px}.title-icon{float:left;margin-right:5px;font-size:1.8rem}.header-logo{font-size:2rem;float:left;margin-right:5px}.letters>button{width:28px;height:28px}.col-md{max-width:250px;min-width:250px}a.card-img-left{overflow:hidden;display:block;width:250px;height:250px;border-radius:5px;background-size:cover;background-image:url(/assets/coverimage-loading.png);margin-bottom:5px;cursor:pointer}button.active{color:#fff;background-color:#28a745!important;border-color:#28a745!important}button.active-fg-green{color:#28a745!important}button.active-fg-red{color:#bd2130!important}div#alertBox{position:fixed;top:50px;right:10px;width:80%;max-width:400px;z-index:1000;opacity:0;visibility:visible;transition:opacity .5s ease-in}div.alertBoxActive{opacity:1!important;visibility:visible!important;transition:opacity .5s ease-in}.popover-content{padding-top:4px;padding-bottom:4px}.opacity05{opacity:.5}caption{caption-side:top;font-size:120%;font-weight:bold;color:black}.dragover>td{border-top:2px solid #28a745}.dragover-th{border-left:2px solid #28a745}[draggable]{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;user-select:none;-khtml-user-drag:element;-webkit-user-drag:element;cursor:pointer}@keyframes changewidth{0%{margin-left:-20px}to{margin-left:100%}}#updateDBprogress{width:20px}.updateDBprogressAnimate{animation-duration:2s;animation-name:changewidth;animation-iteration-count:infinite}.modal-body{overflow-x:hidden}.modal-body .album-cover{float:none}#BrowseDatabaseAlbumListCaption{margin-left:15px;margin-right:15px;width:100%}#BrowseDatabaseAlbumListCaption h2{display:inline}#BrowseDatabaseAlbumListCaption small{padding-top:.8rem}#menu-dbupdate{padding-left:1rem}
html{position:relative;min-height:100%}body{margin-bottom:60px;padding-top:50px;padding-bottom:50px;background-color:#888}main{padding-top:20px}footer{position:absolute;bottom:0}button{overflow:hidden}#BrowseBreadrumb{overflow:auto;white-space:nowrap}#BrowseBreadcrumb>li>a{cursor:pointer}@media only screen and (max-width:576px){.header-logo{display:none!important}}.clickable{cursor:pointer}[data-col=Pos],[data-col=Type],[data-col=Track],[data-col=Action]{width:30px}small{color:#aaa}.card{min-height:300px}.cardFooterPlayback{padding:0}.album-cover{background-size:cover;background-image:url("/assets/coverimage-loading.png");border:1px solid black;border-radius:5px;overflow:hidden;width:240px;height:240px;background-color:#eee;float:left;margin-right:20px;margin-bottom:20px}.album-desc{min-width:240px;float:left}.hide{display:none!important}.pull-right{float:right!important}.card-toolbar{margin-bottom:10px}.card-toolbar>div,.card-toolbar>form{margin-bottom:5px}@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(/assets/MaterialIcons-Regular.woff2) format('woff2'),url(/assets/MaterialIcons-Regular.woff) format('woff'),url(/assets/MaterialIcons-Regular.ttf) format('truetype')}.material-icons{font-family:'Material Icons';font-weight:normal;font-style:normal;font-size:18px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;vertical-align:top;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:'liga'}.material-icons-left{font-size:1rem;margin-left:-1em;vertical-align:middle}.material-icons-small{font-size:16px}.material-icons-small-left{font-size:1rem;margin-left:-1em}.color-darkgrey,.color-darkgrey:hover{color:#6c757d!important}#btn-outputs-block>button{margin-bottom:10px}#btn-outputs-block>button:last-child{margin-bottom:0}.card-body{overflow-x:hidden}.progressBarPlay{font-size:22px}#counter{cursor:text}#volumeBar{margin-top:2px;width:160px}.title-icon{float:left;margin-right:5px;font-size:1.8rem}.header-logo{font-size:2rem;float:left;margin-right:5px}.letters>button{width:28px;height:28px}.col-md{max-width:250px;min-width:250px}a.card-img-left{overflow:hidden;display:block;width:250px;height:250px;border-radius:5px;background-size:cover;background-image:url(/assets/coverimage-loading.png);margin-bottom:5px;cursor:pointer}button.active{color:#fff;background-color:#28a745!important;border-color:#28a745!important}button.active-fg-green{color:#28a745!important}button.active-fg-red{color:#bd2130!important}div#alertBox{position:fixed;top:50px;right:10px;width:80%;max-width:400px;z-index:1000;opacity:0;visibility:visible;transition:opacity .5s ease-in}div.alertBoxActive{opacity:1!important;visibility:visible!important;transition:opacity .5s ease-in}.popover-content{padding-top:4px;padding-bottom:4px}.opacity05{opacity:.5}caption{caption-side:top;font-size:120%;font-weight:bold;color:black}.dragover>td{border-top:2px solid #28a745}.dragover-th{border-left:2px solid #28a745}[draggable]{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;user-select:none;-khtml-user-drag:element;-webkit-user-drag:element;cursor:pointer}@keyframes changewidth{0%{margin-left:-20px}to{margin-left:100%}}#updateDBprogress{width:20px}.updateDBprogressAnimate{animation-duration:2s;animation-name:changewidth;animation-iteration-count:infinite}.modal-body{overflow-x:hidden}.modal-body .album-cover{float:none}#BrowseDatabaseAlbumListCaption{margin-left:15px;margin-right:15px;width:100%}#BrowseDatabaseAlbumListCaption h2{display:inline}#BrowseDatabaseAlbumListCaption small{padding-top:.8rem}#menu-dbupdate{padding-left:1rem}div.key{border:1px solid #bbb;background-color:#eee;border-radius:2px;width:20px;heigth:20px;text-align:center}

File diff suppressed because one or more lines are too long

View File

@ -826,7 +826,14 @@
menuItems = (function(){
var set = menu[children], newSet = [];
for ( var i=0; i<set[length]; i++ ){
set[i][children][length] && (set[i][children][0].tagName === 'A' && newSet[push](set[i][children][0]));
//set[i][children][length] && (set[i][children][0].tagName === 'A' && newSet[push](set[i][children][0]));
//start patch: push all child elements, not only first
if (set[i][children][length]){
for ( var j=0; j<set[i][children][length]; j++ ){
set[i][children][j].tagName === 'A' && newSet[push](set[i][children][j]);
}
}
//end patch
set[i].tagName === 'A' && newSet[push](set[i]);
}
return newSet;
@ -874,9 +881,19 @@
isMenuItem = activeItem[parentNode] === menu || activeItem[parentNode][parentNode] === menu;
if ( isMenuItem || isSameElement ) { // navigate up | down
/* idx = isSameElement ? 0
: key === 38 ? (idx>1?idx-1:0)
: key === 40 ? (idx<menuItems[length]-1?idx+1:idx) : idx;
*/
//start patch: skip hidden elements
do {
idx = isSameElement ? 0
: key === 38 ? (idx>1?idx-1:0)
: key === 40 ? (idx<menuItems[length]-1?idx+1:idx) : idx;
if ( idx == 0 || idx == menuItems[length]-1)
break;
} while ( !menuItems[idx].offsetHeight )
//end patch
menuItems[idx] && setFocus(menuItems[idx]);
}
if ( (menuItems[length] && isMenuItem // menu has items

4
dist/htdocs/js/keymap.min.js vendored Normal file
View File

@ -0,0 +1,4 @@
var keymap={ArrowLeft:{cmd:"clickPrev",options:[],desc:"Previous Song",key:"keyboard_arrow_left"},ArrowRight:{cmd:"clickNext",options:[],desc:"Next Song",key:"keyboard_arrow_right"}," ":{cmd:"clickPlay",options:[],desc:"Toggle Play / Pause",key:"space_bar"},s:{cmd:"clickStop",options:[],desc:"Stop Playing"},"-":{cmd:"chVolume",options:[-5],desc:"Volume Down"},"+":{cmd:"chVolume",options:[5],desc:"Volume Up"},c:{cmd:"MPD_API_QUEUE_CLEAR",options:[],desc:"Clear Queue"},u:{cmd:"updateDB",options:[],
desc:"Update Database"},r:{cmd:"rescanDB",options:[],desc:"Rescan Database"},l:{cmd:"openLocalPlayer",options:[],desc:"Open Local Player",req:"featLocalplayer"},p:{cmd:"updateSmartPlaylists",options:[],desc:"Update Smart Playlists",req:"featSmartpls"},a:{cmd:"showAddToPlaylist",options:["stream"],desc:"Add Stream"},t:{cmd:"openModal",options:["modalSettings"],desc:"Open Settings"},y:{cmd:"openModal",options:["modalAbout"],desc:"Open About"},i:{cmd:"clickTitle",options:[],desc:"Open Song Details"},
1:{cmd:"appGoto",options:["Playback"],desc:"Goto Playback"},2:{cmd:"appGoto",options:["Queue","Current"],desc:"Goto Queue"},3:{cmd:"appGoto",options:["Queue","LastPlayed"],desc:"Goto Last Played"},4:{cmd:"appGoto",options:["Browse","Database"],desc:"Goto Browse Database",req:"featTags"},5:{cmd:"appGoto",options:["Browse","Playlists"],desc:"Goto Browse Playlists",req:"featPlaylists"},6:{cmd:"appGoto",options:["Browse","Filesystem"],desc:"Goto Browse Filesystem"},7:{cmd:"appGoto",options:["Search"],
desc:"Goto Search"},m:{cmd:"openDropdown",options:["dropdownMainMenu"],desc:"Open Main Menu"},v:{cmd:"openDropdown",options:["dropdownVolumeMenu"],desc:"Open Volume Menu"},S:{cmd:"MPD_API_QUEUE_SHUFFLE",options:[],desc:"Shuffle Queue"},C:{cmd:"MPD_API_QUEUE_CROP",options:[],desc:"Crop Queue"},"?":{cmd:"openModal",options:["modalHelp"],desc:"Open Help"},"/":{cmd:"focusSearch",options:[],desc:"Focus Search"}};

View File

@ -3,114 +3,126 @@ $jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Sym
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var b=0;return $jscomp.iteratorPrototype(function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}})};
$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.makeIterator=function(a){$jscomp.initSymbolIterator();var b=a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)};$jscomp.arrayFromIterator=function(a){for(var b,c=[];!(b=a.next()).done;)c.push(b.value);return c};$jscomp.arrayFromIterable=function(a){return a instanceof Array?a:$jscomp.arrayFromIterator($jscomp.makeIterator(a))};
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Object.is",function(a){return a?a:function(a,c){return a===c?0!==a||1/a===1/c:a!==a&&c!==c}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,c){var d=this;d instanceof String&&(d=String(d));var b=d.length;c=c||0;for(0>c&&(c=Math.max(c+b,0));c<b;c++){var f=d[c];if(f===a||Object.is(f,a))return!0}return!1}},"es7","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,c){var b=this;b instanceof String&&(b=String(b));var e=b.length;c=c||0;for(0>c&&(c=Math.max(c+e,0));c<e;c++){var f=b[c];if(f===a||Object.is(f,a))return!0}return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,b,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,c){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,c||0)}},"es6","es3");
$jscomp.polyfill("String.prototype.repeat",function(a){return a?a:function(a){var b=$jscomp.checkStringArgs(this,null,"repeat");if(0>a||1342177279<a)throw new RangeError("Invalid count value");a|=0;for(var d="";a;)if(a&1&&(d+=b),a>>>=1)b+=b;return d}},"es6","es3");
var socket,lastSong="",lastState,currentSong={},playstate="",settings={},alertTimeout,progressTimer,deferredPrompt,dragEl,playlistEl,app={apps:{Playback:{state:"0/-/",scrollPos:0},Queue:{state:"0/any/",scrollPos:0},Browse:{active:"Database",tabs:{Filesystem:{state:"0/-/",scrollPos:0},Playlists:{active:"All",views:{All:{state:"0/-/",scrollPos:0},Detail:{state:"0/-/",scrollPos:0}}},Database:{active:"AlbumArtist",views:{}}}},Search:{state:"0/any/",scrollPos:0}},current:{app:"Playback",tab:void 0,view:void 0,
page:0,filter:"",search:"",scrollPos:0},last:{app:void 0,tab:void 0,view:void 0,filter:"",search:"",scrollPos:0}},domCache={};domCache.navbarBottomBtns=document.getElementById("navbar-bottom").getElementsByTagName("div");domCache.navbarBottomBtnsLen=domCache.navbarBottomBtns.length;domCache.panelHeadingBrowse=document.getElementById("panel-heading-browse").getElementsByTagName("a");domCache.panelHeadingBrowseLen=domCache.panelHeadingBrowse.length;domCache.counter=document.getElementById("counter");
domCache.volumePrct=document.getElementById("volumePrct");domCache.volumeControl=document.getElementById("volumeControl");domCache.volumeIcon=document.getElementById("volumeIcon");domCache.btnsPlay=document.getElementsByClassName("btnPlay");domCache.btnsPlayLen=domCache.btnsPlay.length;domCache.btnPrev=document.getElementById("btnPrev");domCache.btnNext=document.getElementById("btnNext");domCache.progressBar=document.getElementById("progressBar");domCache.volumeBar=document.getElementById("volumeBar");
domCache.outputs=document.getElementById("outputs");domCache.btnAdd=document.getElementById("nav-add2homescreen");domCache.currentTrack=document.getElementById("currentTrack");domCache.currentArtist=document.getElementById("currentArtist");domCache.currentAlbum=document.getElementById("currentAlbum");domCache.currentCover=document.getElementById("currentCover");domCache.btnVoteUp=document.getElementById("btnVoteUp");domCache.btnVoteDown=document.getElementById("btnVoteDown");
var modalConnectionError=new Modal(document.getElementById("modalConnectionError"),{backdrop:"static",keyboard:!1}),modalSettings=new Modal(document.getElementById("modalSettings")),modalSavequeue=new Modal(document.getElementById("modalSaveQueue")),modalSongDetails=new Modal(document.getElementById("modalSongDetails")),modalAddToPlaylist=new Modal(document.getElementById("modalAddToPlaylist")),modalRenamePlaylist=new Modal(document.getElementById("modalRenamePlaylist")),modalUpdateDB=new Modal(document.getElementById("modalUpdateDB")),
modalSaveSmartPlaylist=new Modal(document.getElementById("modalSaveSmartPlaylist")),modalDeletePlaylist=new Modal(document.getElementById("modalDeletePlaylist"));
function appPrepare(a){if(app.current.app!=app.last.app||app.current.tab!=app.last.tab||app.current.view!=app.last.view){for(var b=0;b<domCache.navbarBottomBtnsLen;b++)domCache.navbarBottomBtns[b].classList.remove("active");document.getElementById("cardPlayback").classList.add("hide");document.getElementById("cardQueue").classList.add("hide");document.getElementById("cardBrowse").classList.add("hide");document.getElementById("cardSearch").classList.add("hide");for(b=0;b<domCache.panelHeadingBrowseLen;b++)domCache.panelHeadingBrowse[b].classList.remove("active");
document.getElementById("cardBrowsePlaylists").classList.add("hide");document.getElementById("cardBrowseDatabase").classList.add("hide");document.getElementById("cardBrowseFilesystem").classList.add("hide");document.getElementById("card"+app.current.app).classList.remove("hide");document.getElementById("nav"+app.current.app).classList.add("active");void 0!=app.current.tab&&(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"));scrollTo(a)}(a=document.getElementById(app.current.app+(void 0==app.current.tab?"":app.current.tab)+(void 0==app.current.view?"":app.current.view)+"List"))&&a.classList.add("opacity05")}
var socket,lastSong="",lastSongObj={},lastState,currentSong={},playstate="",settings={},alertTimeout,progressTimer,deferredPrompt,dragEl,playlistEl,app={apps:{Playback:{state:"0/-/",scrollPos:0},Queue:{active:"Current",tabs:{Current:{state:"0/any/",scrollPos:0},LastPlayed:{state:"0/any/",scrollPos:0}}},Browse:{active:"Database",tabs:{Filesystem:{state:"0/-/",scrollPos:0},Playlists:{active:"All",views:{All:{state:"0/-/",scrollPos:0},Detail:{state:"0/-/",scrollPos:0}}},Database:{active:"AlbumArtist",
views:{}}}},Search:{state:"0/any/",scrollPos:0}},current:{app:"Playback",tab:void 0,view:void 0,page:0,filter:"",search:"",scrollPos:0},last:{app:void 0,tab:void 0,view:void 0,filter:"",search:"",scrollPos:0}},domCache={};domCache.navbarBottomBtns=document.getElementById("navbar-bottom").getElementsByTagName("div");domCache.navbarBottomBtnsLen=domCache.navbarBottomBtns.length;domCache.cardHeaderBrowse=document.getElementById("cardHeaderBrowse").getElementsByTagName("a");
domCache.cardHeaderBrowseLen=domCache.cardHeaderBrowse.length;domCache.cardHeaderQueue=document.getElementById("cardHeaderQueue").getElementsByTagName("a");domCache.cardHeaderQueueLen=domCache.cardHeaderQueue.length;domCache.counter=document.getElementById("counter");domCache.volumePrct=document.getElementById("volumePrct");domCache.volumeControl=document.getElementById("volumeControl");domCache.volumeMenu=document.getElementById("volumeMenu");domCache.btnsPlay=document.getElementsByClassName("btnPlay");
domCache.btnsPlayLen=domCache.btnsPlay.length;domCache.btnPrev=document.getElementById("btnPrev");domCache.btnNext=document.getElementById("btnNext");domCache.progressBar=document.getElementById("progressBar");domCache.volumeBar=document.getElementById("volumeBar");domCache.outputs=document.getElementById("outputs");domCache.btnAdd=document.getElementById("nav-add2homescreen");domCache.currentCover=document.getElementById("currentCover");domCache.currentTitle=document.getElementById("currentTitle");
domCache.btnVoteUp=document.getElementById("btnVoteUp");domCache.btnVoteDown=document.getElementById("btnVoteDown");domCache.badgeQueueItems=document.getElementById("badgeQueueItems");
var modalConnectionError=new Modal(document.getElementById("modalConnectionError"),{backdrop:"static",keyboard:!1}),modalSettings=new Modal(document.getElementById("modalSettings")),modalAbout=new Modal(document.getElementById("modalAbout")),modalSavequeue=new Modal(document.getElementById("modalSaveQueue")),modalSongDetails=new Modal(document.getElementById("modalSongDetails")),modalAddToPlaylist=new Modal(document.getElementById("modalAddToPlaylist")),modalRenamePlaylist=new Modal(document.getElementById("modalRenamePlaylist")),
modalUpdateDB=new Modal(document.getElementById("modalUpdateDB")),modalSaveSmartPlaylist=new Modal(document.getElementById("modalSaveSmartPlaylist")),modalDeletePlaylist=new Modal(document.getElementById("modalDeletePlaylist")),modalHelp=new Modal(document.getElementById("modalHelp")),dropdownMainMenu,dropdownVolumeMenu=new Dropdown(document.getElementById("volumeMenu")),collapseDBupdate=new Collapse(document.getElementById("navDBupdate"));
function appPrepare(a){if(app.current.app!=app.last.app||app.current.tab!=app.last.tab||app.current.view!=app.last.view){for(var b=0;b<domCache.navbarBottomBtnsLen;b++)domCache.navbarBottomBtns[b].classList.remove("active");document.getElementById("cardPlayback").classList.add("hide");document.getElementById("cardQueue").classList.add("hide");document.getElementById("cardBrowse").classList.add("hide");document.getElementById("cardSearch").classList.add("hide");for(b=0;b<domCache.cardHeaderBrowseLen;b++)domCache.cardHeaderBrowse[b].classList.remove("active");
for(b=0;b<domCache.cardHeaderQueueLen;b++)domCache.cardHeaderQueue[b].classList.remove("active");document.getElementById("cardQueueCurrent").classList.add("hide");document.getElementById("cardQueueLastPlayed").classList.add("hide");document.getElementById("cardBrowsePlaylists").classList.add("hide");document.getElementById("cardBrowseDatabase").classList.add("hide");document.getElementById("cardBrowseFilesystem").classList.add("hide");document.getElementById("card"+app.current.app).classList.remove("hide");
document.getElementById("nav"+app.current.app)&&document.getElementById("nav"+app.current.app).classList.add("active");void 0!=app.current.tab&&(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"));scrollTo(a)}(a=document.getElementById(app.current.app+(void 0==app.current.tab?"":app.current.tab)+(void 0==app.current.view?"":app.current.view)+"List"))&&a.classList.add("opacity05")}
function appGoto(a,b,c,d){var e=document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;void 0!=app.apps[app.current.app].scrollPos?app.apps[app.current.app].scrollPos=e:void 0!=app.apps[app.current.app].tabs[app.current.tab].scrollPos?app.apps[app.current.app].tabs[app.current.tab].scrollPos=e:void 0!=app.apps[app.current.app].tabs[app.current.tab].views[app.current.view].scrollPos&&(app.apps[app.current.app].tabs[app.current.tab].views[app.current.view].scrollPos=e);app.apps[a].tabs?
(void 0==b&&(b=app.apps[a].active),app.apps[a].tabs[b].views?(void 0==c&&(c=app.apps[a].tabs[b].active),a="/"+a+"/"+b+"/"+c+"!"+(void 0==d?app.apps[a].tabs[b].views[c].state:d)):a="/"+a+"/"+b+"!"+(void 0==d?app.apps[a].tabs[b].state:d)):a="/"+a+"!"+(void 0==d?app.apps[a].state:d);location.hash=a}
function appRoute(){var a;if(a=decodeURI(location.hash).match(/^#\/(\w+)\/?(\w+)?\/?(\w+)?!((\d+)\/([^\/]+)\/(.*))$/)){app.current.app=a[1];app.current.tab=a[2];app.current.view=a[3];app.apps[app.current.app].state?(app.apps[app.current.app].state=a[4],app.current.scrollPos=app.apps[app.current.app].scrollPos):app.apps[app.current.app].tabs[app.current.tab].state?(app.apps[app.current.app].tabs[app.current.tab].state=a[4],app.apps[app.current.app].active=app.current.tab,app.current.scrollPos=app.apps[app.current.app].tabs[app.current.tab].scrollPos):
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=a[4],app.apps[app.current.app].active=app.current.tab,app.apps[app.current.app].tabs[app.current.tab].active=app.current.view,app.current.scrollPos=app.apps[app.current.app].tabs[app.current.tab].views[app.current.view].scrollPos);app.current.page=parseInt(a[5]);app.current.filter=a[6];app.current.search=a[7];appPrepare(app.current.scrollPos);
if("Playback"==app.current.app)sendAPI({cmd:"MPD_API_PLAYER_CURRENT_SONG"},songChange);else if("Queue"==app.current.app)selectTag("searchqueuetags","searchqueuetagsdesc",app.current.filter),getQueue();else if("Browse"==app.current.app&&"Playlists"==app.current.tab&&"All"==app.current.view)sendAPI({cmd:"MPD_API_PLAYLIST_LIST",data:{offset:app.current.page,filter:app.current.filter}},parsePlaylists),doSetFilterLetter("BrowsePlaylistsFilter");else if("Browse"==app.current.app&&"Playlists"==app.current.tab&&
"Detail"==app.current.view)sendAPI({cmd:"MPD_API_PLAYLIST_CONTENT_LIST",data:{offset:app.current.page,filter:app.current.filter,uri:app.current.search}},parsePlaylists),doSetFilterLetter("BrowsePlaylistsFilter");else if("Browse"==app.current.app&&"Database"==app.current.tab)""!=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")):
(sendAPI({cmd:"MPD_API_DATABASE_TAG_LIST",data:{offset:app.current.page,filter:app.current.filter,tag:app.current.view}},parseListDBtags),doSetFilterLetter("BrowseDatabaseFilter"),selectTag("BrowseDatabaseByTagDropdown","btnBrowseDatabaseByTag",app.current.view));else if("Browse"==app.current.app&&"Filesystem"==app.current.tab){sendAPI({cmd:"MPD_API_DATABASE_FILESYSTEM_LIST",data:{offset:app.current.page,path:app.current.search?app.current.search:"/",filter:app.current.filter}},parseFilesystem);app.current.search?
(document.getElementById("BrowseFilesystemAddAllSongs").removeAttribute("disabled"),document.getElementById("BrowseFilesystemAddAllSongsBtn").removeAttribute("disabled")):(document.getElementById("BrowseFilesystemAddAllSongs").setAttribute("disabled","disabled"),document.getElementById("BrowseFilesystemAddAllSongsBtn").setAttribute("disabled","disabled"));var b='<li class="breadcrumb-item"><a data-uri="">root</a></li>',c=app.current.search.split("/"),d=c.length,e="";for(a=0;a<d;a++){if(d-1==a){b+=
'<li class="breadcrumb-item active">'+c[a]+"</li>";break}e+=c[a];b+='<li class="breadcrumb-item"><a data-uri="'+e+'">'+c[a]+"</a></li>";e+="/"}a=document.getElementById("BrowseBreadcrumb");a.innerHTML=b;b=a.getElementsByTagName("a");c=b.length;for(a=0;a<c;a++)b[a].addEventListener("click",function(){appGoto("Browse","Filesystem",void 0,"0/"+app.current.filter+"/"+this.getAttribute("data-uri"))},!1);doSetFilterLetter("BrowseFilesystemFilter")}else"Search"==app.current.app?(a=document.getElementById("searchstr"),
a.focus(),""==a.value&&""!=app.current.search&&(a.value=app.current.search),app.last.app!=app.current.app&&""!=app.current.search&&(document.getElementById("SearchList").getElementsByTagName("tbody")[0].innerHTML='<tr><td><span class="material-icons">search</span></td><td colspan="5">Searching...</td></tr>'),2<=app.current.search.length?sendAPI({cmd:"MPD_API_DATABASE_SEARCH",data:{plist:"",offset:app.current.page,filter:app.current.filter,searchstr:app.current.search}},parseSearch):(document.getElementById("SearchList").getElementsByTagName("tbody")[0].innerHTML=
"",document.getElementById("searchAddAllSongs").setAttribute("disabled","disabled"),document.getElementById("searchAddAllSongsBtn").setAttribute("disabled","disabled"),document.getElementById("panel-heading-search").innerText="",document.getElementById("SearchList").classList.remove("opacity05"),setPagination(0)),selectTag("searchtags","searchtagsdesc",app.current.filter)):appGoto("Playback");app.last.app=app.current.app;app.last.tab=app.current.tab;app.last.view=app.current.view}else appGoto("Playback")}
if("Playback"==app.current.app)sendAPI({cmd:"MPD_API_PLAYER_CURRENT_SONG"},songChange);else if("Queue"==app.current.app&&"Current"==app.current.tab)selectTag("searchqueuetags","searchqueuetagsdesc",app.current.filter),getQueue();else if("Queue"==app.current.app&&"LastPlayed"==app.current.tab)sendAPI({cmd:"MPD_API_QUEUE_LAST_PLAYED",data:{offset:app.current.page}},parseLastPlayed);else if("Browse"==app.current.app&&"Playlists"==app.current.tab&&"All"==app.current.view)sendAPI({cmd:"MPD_API_PLAYLIST_LIST",
data:{offset:app.current.page,filter:app.current.filter}},parsePlaylists),doSetFilterLetter("BrowsePlaylistsFilter");else if("Browse"==app.current.app&&"Playlists"==app.current.tab&&"Detail"==app.current.view)sendAPI({cmd:"MPD_API_PLAYLIST_CONTENT_LIST",data:{offset:app.current.page,filter:app.current.filter,uri:app.current.search}},parsePlaylists),doSetFilterLetter("BrowsePlaylistsFilter");else if("Browse"==app.current.app&&"Database"==app.current.tab)""!=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")):(sendAPI({cmd:"MPD_API_DATABASE_TAG_LIST",data:{offset:app.current.page,filter:app.current.filter,tag:app.current.view}},parseListDBtags),doSetFilterLetter("BrowseDatabaseFilter"),selectTag("BrowseDatabaseByTagDropdown","btnBrowseDatabaseByTag",app.current.view));else if("Browse"==app.current.app&&"Filesystem"==app.current.tab){sendAPI({cmd:"MPD_API_DATABASE_FILESYSTEM_LIST",
data:{offset:app.current.page,path:app.current.search?app.current.search:"/",filter:app.current.filter}},parseFilesystem);app.current.search?(document.getElementById("BrowseFilesystemAddAllSongs").removeAttribute("disabled"),document.getElementById("BrowseFilesystemAddAllSongsBtn").removeAttribute("disabled")):(document.getElementById("BrowseFilesystemAddAllSongs").setAttribute("disabled","disabled"),document.getElementById("BrowseFilesystemAddAllSongsBtn").setAttribute("disabled","disabled"));var b=
'<li class="breadcrumb-item"><a data-uri="">root</a></li>',c=app.current.search.split("/"),d=c.length,e="";for(a=0;a<d;a++){if(d-1==a){b+='<li class="breadcrumb-item active">'+c[a]+"</li>";break}e+=c[a];b+='<li class="breadcrumb-item"><a data-uri="'+e+'">'+c[a]+"</a></li>";e+="/"}a=document.getElementById("BrowseBreadcrumb");a.innerHTML=b;b=a.getElementsByTagName("a");c=b.length;for(a=0;a<c;a++)b[a].addEventListener("click",function(){appGoto("Browse","Filesystem",void 0,"0/"+app.current.filter+"/"+
this.getAttribute("data-uri"))},!1);doSetFilterLetter("BrowseFilesystemFilter")}else"Search"==app.current.app?(a=document.getElementById("searchstr"),a.focus(),""==a.value&&""!=app.current.search&&(a.value=app.current.search),app.last.app!=app.current.app&&""!=app.current.search&&(a=settings["cols"+app.current.app].length,a--,document.getElementById("SearchList").getElementsByTagName("tbody")[0].innerHTML='<tr><td><span class="material-icons">search</span></td><td colspan="'+a+'">Searching...</td></tr>'),
2<=app.current.search.length?sendAPI({cmd:"MPD_API_DATABASE_SEARCH",data:{plist:"",offset:app.current.page,filter:app.current.filter,searchstr:app.current.search}},parseSearch):(document.getElementById("SearchList").getElementsByTagName("tbody")[0].innerHTML="",document.getElementById("searchAddAllSongs").setAttribute("disabled","disabled"),document.getElementById("searchAddAllSongsBtn").setAttribute("disabled","disabled"),document.getElementById("panel-heading-search").innerText="",document.getElementById("SearchList").classList.remove("opacity05"),
setPagination(0)),selectTag("searchtags","searchtagsdesc",app.current.filter)):appGoto("Playback");app.last.app=app.current.app;app.last.tab=app.current.tab;app.last.view=app.current.view}else appGoto("Playback")}
function appInit(){getSettings();sendAPI({cmd:"MPD_API_PLAYER_STATE"},parseState);webSocketConnect();domCache.volumeBar.value=0;document.getElementById("btnChVolumeDown").addEventListener("click",function(a){a.stopPropagation()},!1);document.getElementById("btnChVolumeUp").addEventListener("click",function(a){a.stopPropagation()},!1);domCache.volumeBar.addEventListener("click",function(a){a.stopPropagation()},!1);domCache.volumeBar.addEventListener("change",function(a){sendAPI({cmd:"MPD_API_PLAYER_VOLUME_SET",
data:{volume:domCache.volumeBar.value}})},!1);domCache.progressBar.value=0;domCache.progressBar.addEventListener("change",function(a){currentSong&&0<=currentSong.currentSongId&&sendAPI({cmd:"MPD_API_PLAYER_SEEK",data:{songid:currentSong.currentSongId,seek:Math.ceil(domCache.progressBar.value/100*currentSong.totalTime)}})},!1);document.getElementById("navDBupdate").addEventListener("click",function(a){a.stopPropagation();a.preventDefault();a=this.getElementsByTagName("span")[0];a.innerText="keyboard_arrow_right"==
a.innerText?"keyboard_arrow_down":"keyboard_arrow_right"},!1);document.getElementById("volumeIcon").parentNode.addEventListener("show.bs.dropdown",function(){sendAPI({cmd:"MPD_API_PLAYER_OUTPUT_LIST"},parseOutputs)});document.getElementById("modalAbout").addEventListener("shown.bs.modal",function(){sendAPI({cmd:"MPD_API_DATABASE_STATS"},parseStats)});document.getElementById("modalUpdateDB").addEventListener("hidden.bs.modal",function(){document.getElementById("updateDBprogress").classList.remove("updateDBprogressAnimate")});
document.getElementById("modalSaveQueue").addEventListener("shown.bs.modal",function(){var a=document.getElementById("saveQueueName");a.focus();a.value="";a.classList.remove("is-invalid");document.getElementById("saveQueueFrm").classList.remove("was-validated")});document.getElementById("modalSettings").addEventListener("shown.bs.modal",function(){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")});document.getElementById("selectJukeboxMode").addEventListener("change",function(){var a=this.options[this.selectedIndex].value;0==a||2==a?(document.getElementById("inputJukeboxQueueLength").setAttribute("disabled","disabled"),document.getElementById("selectJukeboxPlaylist").setAttribute("disabled","disabled")):1==a&&(document.getElementById("inputJukeboxQueueLength").removeAttribute("disabled"),
document.getElementById("selectJukeboxPlaylist").removeAttribute("disabled"))});document.getElementById("addToPlaylistPlaylist").addEventListener("change",function(a){"New Playlist"==this.options[this.selectedIndex].text?(document.getElementById("addToPlaylistNewPlaylistDiv").classList.remove("hide"),document.getElementById("addToPlaylistNewPlaylist").focus()):document.getElementById("addToPlaylistNewPlaylistDiv").classList.add("hide")},!1);addFilterLetter("BrowseFilesystemFilterLetters");addFilterLetter("BrowseDatabaseFilterLetters");
addFilterLetter("BrowsePlaylistsFilterLetters");document.getElementById("syscmds").addEventListener("click",function(a){a.preventDefault();"A"==a.target.nodeName&&(a=JSON.parse(a.target.getAttribute("data-href")),"function"===typeof window[a.cmd]&&window[a.cmd].apply(null,$jscomp.arrayFromIterable(a.options)))},!1);for(var a=document.querySelectorAll("[data-href]"),b=a.length,c=0;c<b;c++)a[c].classList.add("clickable"),a[c].addEventListener("click",function(a){a.preventDefault();a=JSON.parse(this.getAttribute("data-href"));
if("function"===typeof window[a.cmd])switch(a.cmd){case "sendAPI":sendAPI.apply(null,$jscomp.arrayFromIterable(a.options));break;default:window[a.cmd].apply(null,$jscomp.arrayFromIterable(a.options))}},!1);a=document.getElementsByClassName("pages");b=a.length;for(c=0;c<b;c++)a[c].addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&gotoPage(a.target.getAttribute("data-page"))},!1);document.getElementById("outputs").addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&a.stopPropagation();
sendAPI({cmd:"MPD_API_PLAYER_TOGGLE_OUTPUT",data:{output:a.target.getAttribute("data-output-id"),state:a.target.classList.contains("active")?0:1}});toggleBtn(a.target.id)},!1);document.getElementById("QueueList").addEventListener("click",function(a){"TD"==a.target.nodeName?sendAPI({cmd:"MPD_API_PLAYER_PLAY_TRACK",data:{track:a.target.parentNode.getAttribute("data-trackid")}}):"A"==a.target.nodeName&&showMenu(a.target,a)},!1);document.getElementById("BrowseFilesystemList").addEventListener("click",
a.innerText?"keyboard_arrow_down":"keyboard_arrow_right"},!1);document.getElementById("volumeMenu").parentNode.addEventListener("show.bs.dropdown",function(){sendAPI({cmd:"MPD_API_PLAYER_OUTPUT_LIST"},parseOutputs)});document.getElementById("modalAbout").addEventListener("shown.bs.modal",function(){sendAPI({cmd:"MPD_API_DATABASE_STATS"},parseStats)});document.getElementById("modalAddToPlaylist").addEventListener("shown.bs.modal",function(){document.getElementById("addStreamFrm").classList.contains("hide")?
document.getElementById("addToPlaylistPlaylist").focus():document.getElementById("streamUrl").focus()});document.getElementById("modalHelp").addEventListener("show.bs.modal",function(){var a="",b;for(b in keymap)if(void 0==keymap[b].req||1==settings[keymap[b].req])a+='<tr><td><div class="key'+(keymap[b].key&&1<keymap[b].key.length?" material-icons material-icons-small":"")+'">'+(void 0!=keymap[b].key?keymap[b].key:b)+"</div></td><td>"+keymap[b].desc+"</td></tr>";document.getElementById("tbodyShortcuts").innerHTML=
a});document.getElementById("modalUpdateDB").addEventListener("hidden.bs.modal",function(){document.getElementById("updateDBprogress").classList.remove("updateDBprogressAnimate")});document.getElementById("modalSaveQueue").addEventListener("shown.bs.modal",function(){var a=document.getElementById("saveQueueName");a.focus();a.value="";a.classList.remove("is-invalid");document.getElementById("saveQueueFrm").classList.remove("was-validated")});document.getElementById("modalSettings").addEventListener("shown.bs.modal",
function(){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")});document.getElementById("selectJukeboxMode").addEventListener("change",function(){var a=this.options[this.selectedIndex].value;0==a||2==a?(document.getElementById("inputJukeboxQueueLength").setAttribute("disabled",
"disabled"),document.getElementById("selectJukeboxPlaylist").setAttribute("disabled","disabled")):1==a&&(document.getElementById("inputJukeboxQueueLength").removeAttribute("disabled"),document.getElementById("selectJukeboxPlaylist").removeAttribute("disabled"))});document.getElementById("addToPlaylistPlaylist").addEventListener("change",function(a){"New Playlist"==this.options[this.selectedIndex].text?(document.getElementById("addToPlaylistNewPlaylistDiv").classList.remove("hide"),document.getElementById("addToPlaylistNewPlaylist").focus()):
document.getElementById("addToPlaylistNewPlaylistDiv").classList.add("hide")},!1);addFilterLetter("BrowseFilesystemFilterLetters");addFilterLetter("BrowseDatabaseFilterLetters");addFilterLetter("BrowsePlaylistsFilterLetters");document.getElementById("syscmds").addEventListener("click",function(a){"A"==a.target.nodeName&&parseCmd(a,a.target.getAttribute("data-href"))},!1);for(var a=document.querySelectorAll("[data-href]"),b=a.length,c=0;c<b;c++)a[c].classList.add("clickable"),a[c].addEventListener("click",
function(a){parseCmd(a,this.getAttribute("data-href"))},!1);a=document.getElementsByClassName("pages");b=a.length;for(c=0;c<b;c++)a[c].addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&gotoPage(a.target.getAttribute("data-page"))},!1);document.getElementById("cardPlaybackTags").addEventListener("click",function(a){"H4"==a.target.nodeName&&gotoBrowse(a.target)},!1);document.getElementById("modalSongDetails").getElementsByTagName("tbody")[0].addEventListener("click",function(a){"A"==
a.target.nodeName?void 0!=a.target.parentNode.getAttribute("data-tag")&&(modalSongDetails.hide(),a.preventDefault(),gotoBrowse(a.target)):"BUTTON"==a.target.nodeName&&a.target.getAttribute("data-href")&&parseCmd(a,a.target.getAttribute("data-href"))},!1);document.getElementById("outputs").addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&a.stopPropagation();sendAPI({cmd:"MPD_API_PLAYER_TOGGLE_OUTPUT",data:{output:a.target.getAttribute("data-output-id"),state:a.target.classList.contains("active")?
0:1}});toggleBtn(a.target.id)},!1);document.getElementById("QueueCurrentList").addEventListener("click",function(a){"TD"==a.target.nodeName?sendAPI({cmd:"MPD_API_PLAYER_PLAY_TRACK",data:{track:a.target.parentNode.getAttribute("data-trackid")}}):"A"==a.target.nodeName&&showMenu(a.target,a)},!1);document.getElementById("QueueLastPlayedList").addEventListener("click",function(a){"A"==a.target.nodeName&&showMenu(a.target,a)},!1);document.getElementById("BrowseFilesystemList").addEventListener("click",
function(a){if("TD"==a.target.nodeName)switch(a.target.parentNode.getAttribute("data-type")){case "dir":appGoto("Browse","Filesystem",void 0,"0/"+app.current.filter+"/"+decodeURI(a.target.parentNode.getAttribute("data-uri")));break;case "song":appendQueue("song",decodeURI(a.target.parentNode.getAttribute("data-uri")),a.target.parentNode.getAttribute("data-name"));break;case "plist":appendQueue("plist",decodeURI(a.target.parentNode.getAttribute("data-uri")),a.target.parentNode.getAttribute("data-name"))}else"A"==
a.target.nodeName&&showMenu(a.target,a)},!1);document.getElementById("BrowsePlaylistsAllList").addEventListener("click",function(a){"TD"==a.target.nodeName?appendQueue("plist",decodeURI(a.target.parentNode.getAttribute("data-uri")),a.target.parentNode.getAttribute("data-name")):"A"==a.target.nodeName&&showMenu(a.target,a)},!1);document.getElementById("BrowsePlaylistsDetailList").addEventListener("click",function(a){"TD"==a.target.nodeName?appendQueue("plist",decodeURI(a.target.parentNode.getAttribute("data-uri")),
a.target.parentNode.getAttribute("data-name")):"A"==a.target.nodeName&&showMenu(a.target,a)},!1);document.getElementById("BrowseDatabaseTagList").addEventListener("click",function(a){"TD"==a.target.nodeName&&appGoto("Browse","Database",app.current.view,"0/-/"+a.target.parentNode.getAttribute("data-uri"))},!1);document.getElementById("SearchList").addEventListener("click",function(a){"TD"==a.target.nodeName?appendQueue("song",decodeURI(a.target.parentNode.getAttribute("data-uri")),a.target.parentNode.getAttribute("data-name")):
"A"==a.target.nodeName&&showMenu(a.target,a)},!1);document.getElementById("BrowseFilesystemAddAllSongsDropdown").addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&("Add all to queue"==a.target.innerText?addAllFromBrowse():"Add all to playlist"==a.target.innerText&&showAddToPlaylist(app.current.search))},!1);document.getElementById("searchAddAllSongsDropdown").addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&("Add all to queue"==a.target.innerText?addAllFromSearchPlist("queue"):
"Add all to playlist"==a.target.innerText?showAddToPlaylist("SEARCH"):"Save as smart playlist"==a.target.innerText&&saveSearchAsSmartPlaylist())},!1);document.getElementById("BrowseDatabaseAddAllSongsDropdown").addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&("Add all to queue"==a.target.innerText?addAllFromBrowseDatabasePlist("queue"):"Add all to playlist"==a.target.innerText&&showAddToPlaylist("DATABASE"))},!1);document.getElementById("searchtags").addEventListener("click",function(a){"BUTTON"==
a.target.nodeName&&appGoto(app.current.app,app.current.tab,app.current.view,"0/"+a.target.getAttribute("data-tag")+"/"+app.current.search)},!1);document.getElementById("searchqueuestr").addEventListener("keyup",function(a){appGoto(app.current.app,app.current.tab,app.current.view,"0/"+app.current.filter+"/"+this.value)},!1);document.getElementById("searchqueuetags").addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&appGoto(app.current.app,app.current.tab,app.current.view,app.current.page+
"/"+a.target.getAttribute("data-tag")+"/"+app.current.search)},!1);document.getElementById("QueueColsDropdown").addEventListener("click",function(a){"INPUT"==a.target.nodeName&&a.stopPropagation()},!1);document.getElementById("BrowseFilesystemColsDropdown").addEventListener("click",function(a){"INPUT"==a.target.nodeName&&a.stopPropagation()},!1);document.getElementById("SearchColsDropdown").addEventListener("click",function(a){"INPUT"==a.target.nodeName&&a.stopPropagation()},!1);document.getElementById("BrowsePlaylistsDetailColsDropdown").addEventListener("click",
function(a){"INPUT"==a.target.nodeName&&a.stopPropagation()},!1);document.getElementById("BrowseDatabaseColsDropdown").addEventListener("click",function(a){"INPUT"==a.target.nodeName&&a.stopPropagation()},!1);document.getElementById("search").addEventListener("submit",function(){return!1},!1);document.getElementById("searchqueue").addEventListener("submit",function(){return!1},!1);document.getElementById("searchstr").addEventListener("keyup",function(a){appGoto("Search",void 0,void 0,"0/"+app.current.filter+
"/"+this.value)},!1);document.getElementById("BrowseDatabaseByTagDropdown").addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&appGoto(app.current.app,app.current.tab,a.target.getAttribute("data-tag"),"0/"+app.current.filter+"/"+app.current.search)},!1);document.getElementsByTagName("body")[0].addEventListener("click",function(a){hideMenu()},!1);dragAndDropTable("QueueList");dragAndDropTable("BrowsePlaylistsDetailList");dragAndDropTableHeader("Queue");dragAndDropTableHeader("Search");
dragAndDropTableHeader("BrowseFilesystem");dragAndDropTableHeader("BrowsePlaylistsDetail");window.addEventListener("hashchange",appRoute,!1);window.addEventListener("focus",function(){sendAPI({cmd:"MPD_API_PLAYER_STATE"},parseState)},!1);document.addEventListener("keydown",function(a){if("INPUT"!=a.target.tagName&&"SELECT"!=a.target.tagName){if(a.shiftKey)switch(a.which){case 83:sendAPI({cmd:"MPD_API_QUEUE_SHUFFLE"});break;case 67:sendAPI({cmd:"MPD_API_QUEUE_CROP"});break;default:return}else switch(a.which){case 37:clickPrev();
break;case 39:clickNext();break;case 32:clickPlay();break;case 83:clickStop();break;case 173:chVolume(-5);break;case 171:chVolume(5);break;case 67:sendAPI({cmd:"MPD_API_QUEUE_CLEAR"});break;default:return}a.preventDefault()}},!1);"serviceWorker"in navigator&&"https"==document.URL.substring(0,5)&&window.addEventListener("load",function(){navigator.serviceWorker.register("/sw.min.js",{scope:"/"}).then(function(a){console.log("ServiceWorker registration successful with scope: ",a.scope);a.update()},
function(a){console.log("ServiceWorker registration failed: ",a)})});window.addEventListener("beforeinstallprompt",function(a){a.preventDefault();deferredPrompt=a});window.addEventListener("beforeinstallprompt",function(a){a.preventDefault();deferredPrompt=a;domCache.btnAdd.classList.remove("hide")});domCache.btnAdd.addEventListener("click",function(a){domCache.btnAdd.classList.add("hide");deferredPrompt.prompt();deferredPrompt.userChoice.then(function(a){"accepted"===a.outcome?console.log("User accepted the A2HS prompt"):
console.log("User dismissed the A2HS prompt");deferredPrompt=null})});window.addEventListener("appinstalled",function(a){console.log("myMPD installed as app")})}
a.target.nodeName&&appGoto(app.current.app,app.current.tab,app.current.view,"0/"+a.target.getAttribute("data-tag")+"/"+app.current.search)},!1);document.getElementById("searchqueuestr").addEventListener("keyup",function(a){"Escape"==a.key?this.blur():appGoto(app.current.app,app.current.tab,app.current.view,"0/"+app.current.filter+"/"+this.value)},!1);document.getElementById("searchqueuetags").addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&appGoto(app.current.app,app.current.tab,
app.current.view,app.current.page+"/"+a.target.getAttribute("data-tag")+"/"+app.current.search)},!1);a="QueueCurrentColsDropdown BrowseFilesystemColsDropdown SearchColsDropdown BrowsePlaylistsDetailColsDropdown BrowseDatabaseColsDropdown PlaybackColsDropdown QueueLastPlayedColsDropdown".split(" ");for(c=0;c<a.length;c++)document.getElementById(a[c]).addEventListener("click",function(a){"INPUT"==a.target.nodeName&&a.stopPropagation()},!1);document.getElementById("search").addEventListener("submit",
function(){return!1},!1);document.getElementById("searchqueue").addEventListener("submit",function(){return!1},!1);document.getElementById("searchstr").addEventListener("keyup",function(a){"Escape"==a.key?this.blur():appGoto("Search",void 0,void 0,"0/"+app.current.filter+"/"+this.value)},!1);document.getElementById("BrowseDatabaseByTagDropdown").addEventListener("click",function(a){"BUTTON"==a.target.nodeName&&appGoto(app.current.app,app.current.tab,a.target.getAttribute("data-tag"),"0/"+app.current.filter+
"/"+app.current.search)},!1);document.getElementsByTagName("body")[0].addEventListener("click",function(a){hideMenu()},!1);dragAndDropTable("QueueCurrentList");dragAndDropTable("BrowsePlaylistsDetailList");dragAndDropTableHeader("QueueCurrent");dragAndDropTableHeader("QueueLastPlayed");dragAndDropTableHeader("Search");dragAndDropTableHeader("BrowseFilesystem");dragAndDropTableHeader("BrowsePlaylistsDetail");window.addEventListener("hashchange",appRoute,!1);window.addEventListener("focus",function(){sendAPI({cmd:"MPD_API_PLAYER_STATE"},
parseState)},!1);document.addEventListener("keydown",function(a){if("INPUT"!=a.target.tagName&&"SELECT"!=a.target.tagName&&!a.ctrlKey&&!a.altKey){var b=keymap[a.key];b&&"function"===typeof window[b.cmd]&&(void 0==keymap[a.key].req||1==settings[keymap[a.key].req])&&parseCmd(a,b)}},!1);"serviceWorker"in navigator&&"https"==document.URL.substring(0,5)&&window.addEventListener("load",function(){navigator.serviceWorker.register("/sw.min.js",{scope:"/"}).then(function(a){console.log("ServiceWorker registration successful with scope: ",
a.scope);a.update()},function(a){console.log("ServiceWorker registration failed: ",a)})});window.addEventListener("beforeinstallprompt",function(a){a.preventDefault();deferredPrompt=a});window.addEventListener("beforeinstallprompt",function(a){a.preventDefault();deferredPrompt=a;domCache.btnAdd.classList.remove("hide")});domCache.btnAdd.addEventListener("click",function(a){domCache.btnAdd.classList.add("hide");deferredPrompt.prompt();deferredPrompt.userChoice.then(function(a){"accepted"===a.outcome?
console.log("User accepted the A2HS prompt"):console.log("User dismissed the A2HS prompt");deferredPrompt=null})});window.addEventListener("appinstalled",function(a){console.log("myMPD installed as app")})}function parseCmd(a,b){a.preventDefault();a=b;"string"==typeof b&&(a=JSON.parse(b));if("function"===typeof window[a.cmd])switch(a.cmd){case "sendAPI":sendAPI.apply(null,$jscomp.arrayFromIterable(a.options));break;default:window[a.cmd].apply(null,$jscomp.arrayFromIterable(a.options))}}
function dragAndDropTable(a){var b=document.getElementById(a).getElementsByTagName("tbody")[0];b.addEventListener("dragstart",function(a){"TR"==a.target.nodeName&&(a.target.classList.add("opacity05"),a.dataTransfer.setDragImage(a.target,0,0),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("Text",a.target.getAttribute("id")),dragEl=a.target.cloneNode(!0))},!1);b.addEventListener("dragleave",function(a){a.preventDefault();if("TR"==dragEl.nodeName){var b=a.target;"TD"==a.target.nodeName&&
(b=a.target.parentNode);"TR"==b.nodeName&&b.classList.remove("dragover")}},!1);b.addEventListener("dragover",function(a){a.preventDefault();if("TR"==dragEl.nodeName){for(var c=b.getElementsByClassName("dragover"),e=c.length,f=0;f<e;f++)c[f].classList.remove("dragover");c=a.target;"TD"==a.target.nodeName&&(c=a.target.parentNode);"TR"==c.nodeName&&c.classList.add("dragover");a.dataTransfer.dropEffect="move"}},!1);b.addEventListener("dragend",function(a){a.preventDefault();if("TR"==dragEl.nodeName){for(var c=
b.getElementsByClassName("dragover"),e=c.length,f=0;f<e;f++)c[f].classList.remove("dragover");document.getElementById(a.dataTransfer.getData("Text"))&&document.getElementById(a.dataTransfer.getData("Text")).classList.remove("opacity05")}},!1);b.addEventListener("drop",function(c){c.stopPropagation();c.preventDefault();if("TR"==dragEl.nodeName){var d=c.target;"TD"==c.target.nodeName&&(d=c.target.parentNode);var e=document.getElementById(c.dataTransfer.getData("Text")).getAttribute("data-songpos"),
f=d.getAttribute("data-songpos");document.getElementById(c.dataTransfer.getData("Text")).remove();dragEl.classList.remove("opacity05");b.insertBefore(dragEl,d);c=b.getElementsByClassName("dragover");d=c.length;for(var g=0;g<d;g++)c[g].classList.remove("dragover");document.getElementById(a).classList.add("opacity05");"Queue"==app.current.app?sendAPI({cmd:"MPD_API_QUEUE_MOVE_TRACK",data:{from:e,to:f}}):"Browse"==app.current.app&&"Playlists"==app.current.tab&&"Detail"==app.current.view&&playlistMoveTrack(e,
f)}},!1)}
function dragAndDropTableHeader(a){if(document.getElementById(a+"List"))var b=document.getElementById(a+"List").getElementsByTagName("tr")[0];else b=a.getElementsByTagName("tr")[0],a="BrowseDatabase";b.addEventListener("dragstart",function(a){"TH"==a.target.nodeName&&(a.target.classList.add("opacity05"),a.dataTransfer.setDragImage(a.target,0,0),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("Text",a.target.getAttribute("data-col")),dragEl=a.target.cloneNode(!0))},!1);b.addEventListener("dragleave",function(a){a.preventDefault();
"TH"==dragEl.nodeName&&"TH"==a.target.nodeName&&a.target.classList.remove("dragover-th")},!1);b.addEventListener("dragover",function(a){a.preventDefault();if("TH"==dragEl.nodeName){for(var c=b.getElementsByClassName("dragover-th"),e=c.length,f=0;f<e;f++)c[f].classList.remove("dragover-th");"TH"==a.target.nodeName&&a.target.classList.add("dragover-th");a.dataTransfer.dropEffect="move"}},!1);b.addEventListener("dragend",function(a){a.preventDefault();if("TH"==dragEl.nodeName){for(var c=b.getElementsByClassName("dragover-th"),
e=c.length,f=0;f<e;f++)c[f].classList.remove("dragover-th");this.querySelector("[data-col="+a.dataTransfer.getData("Text")+"]")&&this.querySelector("[data-col="+a.dataTransfer.getData("Text")+"]").classList.remove("opacity05")}},!1);b.addEventListener("drop",function(c){c.stopPropagation();c.preventDefault();if("TH"==dragEl.nodeName){this.querySelector("[data-col="+c.dataTransfer.getData("Text")+"]").remove();dragEl.classList.remove("opacity05");b.insertBefore(dragEl,c.target);c=b.getElementsByClassName("dragover-th");
for(var d=c.length,e=0;e<d;e++)c[e].classList.remove("dragover-th");document.getElementById(a+"List")?(document.getElementById(a+"List").classList.add("opacity05"),saveCols(a)):saveCols(a,this.parentNode.parentNode)}},!1)}function playlistMoveTrack(a,b){sendAPI({cmd:"MPD_API_PLAYLIST_MOVE_TRACK",data:{plist:app.current.search,from:a,to:b}})}
f=d.getAttribute("data-songpos");document.getElementById(c.dataTransfer.getData("Text")).remove();dragEl.classList.remove("opacity05");b.insertBefore(dragEl,d);c=b.getElementsByClassName("dragover");d=c.length;for(var g=0;g<d;g++)c[g].classList.remove("dragover");document.getElementById(a).classList.add("opacity05");"Queue"==app.current.app&&"Current"==app.current.tab?sendAPI({cmd:"MPD_API_QUEUE_MOVE_TRACK",data:{from:e,to:f}}):"Browse"==app.current.app&&"Playlists"==app.current.tab&&"Detail"==app.current.view&&
playlistMoveTrack(e,f)}},!1)}
function dragAndDropTableHeader(a){if(document.getElementById(a+"List"))var b=document.getElementById(a+"List").getElementsByTagName("tr")[0];else b=a.getElementsByTagName("tr")[0],a="BrowseDatabase";b.addEventListener("dragstart",function(a){"TH"==a.target.nodeName&&(a.target.classList.add("opacity05"),a.dataTransfer.setDragImage(a.target,0,0),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("Text",a.target.getAttribute("data-col")),dragEl=a.target.cloneNode(!0))},!1);b.addEventListener("dragleave",
function(a){a.preventDefault();"TH"==dragEl.nodeName&&"TH"==a.target.nodeName&&a.target.classList.remove("dragover-th")},!1);b.addEventListener("dragover",function(a){a.preventDefault();if("TH"==dragEl.nodeName){for(var c=b.getElementsByClassName("dragover-th"),e=c.length,f=0;f<e;f++)c[f].classList.remove("dragover-th");"TH"==a.target.nodeName&&a.target.classList.add("dragover-th");a.dataTransfer.dropEffect="move"}},!1);b.addEventListener("dragend",function(a){a.preventDefault();if("TH"==dragEl.nodeName){for(var c=
b.getElementsByClassName("dragover-th"),e=c.length,f=0;f<e;f++)c[f].classList.remove("dragover-th");this.querySelector("[data-col="+a.dataTransfer.getData("Text")+"]")&&this.querySelector("[data-col="+a.dataTransfer.getData("Text")+"]").classList.remove("opacity05")}},!1);b.addEventListener("drop",function(c){c.stopPropagation();c.preventDefault();if("TH"==dragEl.nodeName){this.querySelector("[data-col="+c.dataTransfer.getData("Text")+"]").remove();dragEl.classList.remove("opacity05");b.insertBefore(dragEl,
c.target);c=b.getElementsByClassName("dragover-th");for(var d=c.length,e=0;e<d;e++)c[e].classList.remove("dragover-th");document.getElementById(a+"List")?(document.getElementById(a+"List").classList.add("opacity05"),saveCols(a)):saveCols(a,this.parentNode.parentNode)}},!1)}function playlistMoveTrack(a,b){sendAPI({cmd:"MPD_API_PLAYLIST_MOVE_TRACK",data:{plist:app.current.search,from:a,to:b}})}
function webSocketConnect(){var a=getWsUrl();socket=new WebSocket(a);try{socket.onopen=function(){console.log("connected");showNotification("Connected to myMPD: "+a,"","","success");modalConnectionError.hide();appRoute();sendAPI({cmd:"MPD_API_PLAYER_STATE"},parseState)},socket.onmessage=function(b){if(b.data!==lastState&&0!=b.data.length){try{var c=JSON.parse(b.data)}catch(d){console.log("Invalid JSON data received: "+b.data)}switch(c.type){case "update_state":parseState(c);break;case "disconnected":showNotification("Lost connection to myMPD: "+
a,"","","danger");break;case "update_queue":"Queue"===app.current.app&&getQueue();sendAPI({cmd:"MPD_API_PLAYER_STATE"},parseState);break;case "update_options":getSettings();break;case "update_outputs":sendAPI({cmd:"MPD_API_PLAYER_OUTPUT_LIST"},parseOutputs);break;case "update_started":updateDBstarted(!1);break;case "update_database":case "update_finished":updateDBfinished(c.type);break;case "update_volume":parseVolume(c);break;case "update_stored_playlist":"Browse"==app.current.app&&"Playlists"==
app.current.tab&&"All"==app.current.view?sendAPI({cmd:"MPD_API_PLAYLIST_LIST",data:{offset:app.current.page,filter:app.current.filter}},parsePlaylists):"Browse"==app.current.app&&"Playlists"==app.current.tab&&"Detail"==app.current.view&&sendAPI({cmd:"MPD_API_PLAYLIST_CONTENT_LIST",data:{offset:app.current.page,filter:app.current.filter,uri:app.current.search}},parsePlaylists);break;case "error":showNotification(c.data,"","","danger")}}},socket.onclose=function(){console.log("disconnected");modalConnectionError.show();
setTimeout(function(){console.log("reconnect");webSocketConnect()},3E3)}}catch(b){alert("Error: "+b)}}function getWsUrl(){var a=window.location.hostname,b=window.location.protocol,c=window.location.port;a=("https:"==b?"wss://":"ws://")+a+(""!=c?":"+c:"")+"/ws";return document.getElementById("wsUrl").innerText=a}
function parseStats(a){document.getElementById("mpdstats_artists").innerText=a.data.artists;document.getElementById("mpdstats_albums").innerText=a.data.albums;document.getElementById("mpdstats_songs").innerText=a.data.songs;document.getElementById("mpdstats_dbPlaytime").innerText=beautifyDuration(a.data.dbPlaytime);document.getElementById("mpdstats_playtime").innerText=beautifyDuration(a.data.playtime);document.getElementById("mpdstats_uptime").innerText=beautifyDuration(a.data.uptime);var b=new Date(1E3*
a.data.dbUpdated);document.getElementById("mpdstats_dbUpdated").innerText=b.toUTCString();document.getElementById("mympdVersion").innerText=a.data.mympdVersion;document.getElementById("mpdVersion").innerText=a.data.mpdVersion}function toggleBtn(a,b){if(a=document.getElementById(a))void 0==b&&(b=a.classList.contains("active")?0:1),1==b||1==b?a.classList.add("active"):a.classList.remove("active")}
function filterCols(a){var b=settings.tags.slice();0==settings.featTags&&b.push("Title");b.push("Duration");"colsQueue"!=a&&"colsBrowsePlaylistsDetail"!=a||b.push("Pos");"colsBrowseFilesystem"==a&&b.push("Type");for(var c=[],d=0;d<settings[a].length;d++)b.includes(settings[a][d])&&c.push(settings[a][d]);settings[a]=c}
function filterCols(a){var b=settings.tags.slice();0==settings.featTags&&b.push("Title");b.push("Duration");"colsQueueCurrent"==a||"colsBrowsePlaylistsDetail"==a||"colsQueueLastPlayed"==a?b.push("Pos"):"colsBrowseFilesystem"==a&&b.push("Type");"colsQueueLastPlayed"==a&&b.push("LastPlayed");for(var c=[],d=0;d<settings[a].length;d++)b.includes(settings[a][d])&&c.push(settings[a][d]);settings[a]=c}
function parseSettings(a){settings=a.data;toggleBtn("btnRandom",settings.random);toggleBtn("btnConsume",settings.consume);toggleBtn("btnSingle",settings.single);toggleBtn("btnRepeat",settings.repeat);void 0!=settings.crossfade?(document.getElementById("inputCrossfade").removeAttribute("disabled"),document.getElementById("inputCrossfade").value=settings.crossfade):document.getElementById("inputCrossfade").setAttribute("disabled","disabled");void 0!=settings.mixrampdb?(document.getElementById("inputMixrampdb").removeAttribute("disabled"),
document.getElementById("inputMixrampdb").value=settings.mixrampdb):document.getElementById("inputMixrampdb").setAttribute("disabled","disabled");void 0!=settings.mixrampdelay?(document.getElementById("inputMixrampdelay").removeAttribute("disabled"),document.getElementById("inputMixrampdelay").value=settings.mixrampdelay):document.getElementById("inputMixrampdelay").setAttribute("disabled","disabled");document.getElementById("selectReplaygain").value=settings.replaygain;a=document.getElementById("btnnotifyWeb");
notificationsSupported()?settings.notificationWeb?(toggleBtn("btnnotifyWeb",settings.notificationWeb),Notification.requestPermission(function(a){"permission"in Notification||(Notification.permission=a);"granted"===a?toggleBtn("btnnotifyWeb",1):(toggleBtn("btnnotifyWeb",0),settings.notificationWeb=!0)})):toggleBtn("btnnotifyWeb",0):(a.setAttribute("disabled","disabled"),toggleBtn("btnnotifyWeb",0));toggleBtn("btnnotifyPage",settings.notificationPage);for(var b="featStickers featSmartpls featPlaylists featTags featLocalplayer featSyscmds featCoverimage".split(" "),
c=0;c<b.length;c++){var d=document.getElementsByClassName(b[c]),e=d.length,f=1==settings[b[c]]?"":"none";for(a=0;a<e;a++)d[a].style.display=f}0==settings.featTags&&(app.apps.Browse.active="Filesystem",app.apps.Search.state="0/filename/",app.apps.Queue.state="0/filename/",settings.colsQueue=["Pos","Title","Duration"],settings.colsSearch=["Title","Duration"],settings.colsBrowseFilesystem=["Type","Title","Duration"],settings.colsBrowseDatabase=["Track","Title","Duration"]);1==settings.mixramp?document.getElementsByClassName("mixramp")[0].style.display=
"":document.getElementsByClassName("mixramp")[0].style.display="none";!settings.tags.includes("AlbumArtist")&&settings.featTags&&(settings.tags.includes("Artist")?app.apps.Browse.tabs.Database.active="Artist":app.apps.Browse.tabs.Database.active=settings.tags[0]);document.getElementById("selectJukeboxMode").value=settings.jukeboxMode;document.getElementById("inputJukeboxQueueLength").value=settings.jukeboxQueueLength;0==settings.jukeboxMode||2==settings.jukeboxMode?(document.getElementById("inputJukeboxQueueLength").setAttribute("disabled",
"disabled"),document.getElementById("selectJukeboxPlaylist").setAttribute("disabled","disabled")):1==settings.jukeboxMode&&(document.getElementById("inputJukeboxQueueLength").removeAttribute("disabled"),document.getElementById("selectJukeboxPlaylist").removeAttribute("disabled"));settings.featPlaylists?(playlistEl="selectJukeboxPlaylist",sendAPI({cmd:"MPD_API_PLAYLIST_LIST",data:{offset:0,filter:"-"}},getAllPlaylists)):document.getElementById("selectJukeboxPlaylist").innerHTML="<option>Database</option>";
settings.tags.sort();settings.searchtags.sort();settings.browsetags.sort();filterCols("colsSearch");filterCols("colsQueue");filterCols("colsBrowsePlaylistsDetail");filterCols("colsBrowseFilesystem");filterCols("colsBrowseDatabase");settings.featLocalplayer&&(""==settings.streamurl?(settings.mpdstream="http://",settings.mpdstream="127.0.0.1"==settings.mpdhost||"localhost"==settings.mpdhost?settings.mpdstream+window.location.hostname:settings.mpdstream+settings.mpdhost,settings.mpdstream+=":"+settings.streamport+
"/"):settings.mpdstream=settings.streamurl);addTagList("BrowseDatabaseByTagDropdown","browsetags");addTagList("searchqueuetags","searchtags");addTagList("searchtags","searchtags");for(a=0;a<settings.tags.length;a++)app.apps.Browse.tabs.Database.views[settings.tags[a]]={state:"0/-/",scrollPos:0};if(settings.featSyscmds){b="";c=settings.syscmds.length;if(0<c)for(b='<div class="dropdown-divider"></div>',a=0;a<c;a++)b+='<a class="dropdown-item text-light bg-dark" href="#" data-href=\'{"cmd": "execSyscmd", "options": ["'+
settings.syscmds[a]+"\"]}'>"+settings.syscmds[a]+"</a>";document.getElementById("syscmds").innerHTML=b}else document.getElementById("syscmds").innerHTML="";setCols("Queue");setCols("Search");setCols("BrowseFilesystem");setCols("BrowsePlaylistsDetail");setCols("BrowseDatabase",".tblAlbumTitles");"Queue"==app.current.app?getQueue():"Search"==app.current.app?appRoute():"Browse"==app.current.app&&"Filesystem"==app.current.tab?appRoute():"Browse"==app.current.app&&"Playlists"==app.current.tab&&"Detail"==
app.current.view?appRoute():"Browse"==app.current.app&&"Database"==app.current.tab&&""!=app.current.search&&appRoute()}
function setCols(a,b){var c="",d=settings.tags.slice();0==settings.featTags&&d.push("Title");d.push("Duration");"Queue"!=a&&"BrowsePlaylistsDetail"!=a||d.push("Pos");"BrowseFilesystem"==a&&d.push("Type");d.sort();for(var e=0;e<d.length;e++)c+='<div class="form-check"><input class="form-check-input" type="checkbox" value="1" name="'+d[e]+'"',settings["cols"+a].includes(d[e])&&(c+="checked"),c+='><label class="form-check-label text-light" for="'+d[e]+'">&nbsp;&nbsp;'+d[e]+"</label></div>";document.getElementById(a+
"ColsDropdown").firstChild.innerHTML=c;c="";for(e=0;e<settings["cols"+a].length;e++){d=settings["cols"+a][e];c+='<th draggable="true" data-col="'+d+'">';if("Track"==d||"Pos"==d)d="#";c+=d+"</th>"}c+="<th></th>";if(void 0==b)document.getElementById(a+"List").getElementsByTagName("tr")[0].innerHTML=c;else for(a=document.querySelectorAll(b),e=0;e<a.length;e++)a[e].getElementsByTagName("tr")[0].innerHTML=c}function getSettings(){sendAPI({cmd:"MPD_API_SETTINGS_GET"},parseSettings)}
c=0;c<b.length;c++){var d=document.getElementsByClassName(b[c]),e=d.length,f=1==settings[b[c]]?"":"none";for(a=0;a<e;a++)d[a].style.display=f}if(0==settings.featTags)app.apps.Browse.active="Filesystem",app.apps.Search.state="0/filename/",app.apps.Queue.state="0/filename/",settings.colsQueueCurrent=["Pos","Title","Duration"],settings.colsQueueLastPlayed=["Pos","Title","LastPlayed"],settings.colsSearch=["Title","Duration"],settings.colsBrowseFilesystem=["Type","Title","Duration"],settings.colsBrowseDatabase=
["Track","Title","Duration"],settings.colsPlayback=[];else{b="";for(a=0;a<settings.colsPlayback.length;a++)b+='<div id="current'+settings.colsPlayback[a]+'" data-tag="'+settings.colsPlayback[a]+'" data-name="'+encodeURI(lastSongObj.data?lastSongObj.data[settings.colsPlayback[a]]:"")+'"><small>'+settings.colsPlayback[a]+"</small><h4",settings.browsetags.includes(settings.colsPlayback[a])&&(b+=' class="clickable"'),b+=">"+(lastSongObj.data?lastSongObj.data[settings.colsPlayback[a]]:"")+"</h4></div>";
document.getElementById("cardPlaybackTags").innerHTML=b}1==settings.mixramp?document.getElementsByClassName("mixramp")[0].style.display="":document.getElementsByClassName("mixramp")[0].style.display="none";!settings.tags.includes("AlbumArtist")&&settings.featTags&&(settings.tags.includes("Artist")?app.apps.Browse.tabs.Database.active="Artist":app.apps.Browse.tabs.Database.active=settings.tags[0]);document.getElementById("selectJukeboxMode").value=settings.jukeboxMode;document.getElementById("inputJukeboxQueueLength").value=
settings.jukeboxQueueLength;0==settings.jukeboxMode||2==settings.jukeboxMode?(document.getElementById("inputJukeboxQueueLength").setAttribute("disabled","disabled"),document.getElementById("selectJukeboxPlaylist").setAttribute("disabled","disabled")):1==settings.jukeboxMode&&(document.getElementById("inputJukeboxQueueLength").removeAttribute("disabled"),document.getElementById("selectJukeboxPlaylist").removeAttribute("disabled"));settings.featPlaylists?(playlistEl="selectJukeboxPlaylist",sendAPI({cmd:"MPD_API_PLAYLIST_LIST",
data:{offset:0,filter:"-"}},getAllPlaylists)):document.getElementById("selectJukeboxPlaylist").innerHTML="<option>Database</option>";settings.tags.sort();settings.searchtags.sort();settings.browsetags.sort();filterCols("colsSearch");filterCols("colsQueueCurrent");filterCols("colsQueueLastPlayed");filterCols("colsBrowsePlaylistsDetail");filterCols("colsBrowseFilesystem");filterCols("colsBrowseDatabase");filterCols("colsPlayback");settings.featLocalplayer&&(""==settings.streamurl?(settings.mpdstream=
"http://",settings.mpdstream="127.0.0.1"==settings.mpdhost||"localhost"==settings.mpdhost?settings.mpdstream+window.location.hostname:settings.mpdstream+settings.mpdhost,settings.mpdstream+=":"+settings.streamport+"/"):settings.mpdstream=settings.streamurl);addTagList("BrowseDatabaseByTagDropdown","browsetags");addTagList("searchqueuetags","searchtags");addTagList("searchtags","searchtags");for(a=0;a<settings.tags.length;a++)app.apps.Browse.tabs.Database.views[settings.tags[a]]={state:"0/-/",scrollPos:0};
if(settings.featSyscmds){document.getElementById("mainMenuDropdown");b="";c=settings.syscmds.length;if(0<c)for(b='<div class="dropdown-divider"></div>',a=0;a<c;a++)b+='<a class="dropdown-item text-light bg-dark" href="#" data-href=\'{"cmd": "execSyscmd", "options": ["'+settings.syscmds[a]+"\"]}'>"+settings.syscmds[a]+"</a>";document.getElementById("syscmds").innerHTML=b}else document.getElementById("syscmds").innerHTML="";dropdownMainMenu=new Dropdown(document.getElementById("mainMenu"));setCols("QueueCurrent");
setCols("Search");setCols("QueueLastPlayed");setCols("BrowseFilesystem");setCols("BrowsePlaylistsDetail");setCols("BrowseDatabase",".tblAlbumTitles");setCols("Playback");"Queue"==app.current.app&&"Current"==app.current.tab?getQueue():"Queue"==app.current.app&&"LastPlayed"==app.current.tab?appRoute():"Search"==app.current.app?appRoute():"Browse"==app.current.app&&"Filesystem"==app.current.tab?appRoute():"Browse"==app.current.app&&"Playlists"==app.current.tab&&"Detail"==app.current.view?appRoute():
"Browse"==app.current.app&&"Database"==app.current.tab&&""!=app.current.search&&appRoute()}
function setCols(a,b){var c="",d=settings.tags.slice();0==settings.featTags&&d.push("Title");d.push("Duration");"QueueCurrent"!=a&&"BrowsePlaylistsDetail"!=a&&"QueueLastPlayed"!=a||d.push("Pos");"BrowseFilesystem"==a&&d.push("Type");"QueueLastPlayed"==a&&d.push("LastPlayed");d.sort();for(var e=0;e<d.length;e++)if("Playback"!=a||"Title"!=d[e])c+='<div class="form-check"><input class="form-check-input" type="checkbox" value="1" name="'+d[e]+'"',settings["cols"+a].includes(d[e])&&(c+="checked"),c+='><label class="form-check-label text-light" for="'+
d[e]+'">&nbsp;&nbsp;'+d[e]+"</label></div>";document.getElementById(a+"ColsDropdown").firstChild.innerHTML=c;if("Playback"!=a){c="";for(e=0;e<settings["cols"+a].length;e++){d=settings["cols"+a][e];c+='<th draggable="true" data-col="'+d+'">';if("Track"==d||"Pos"==d)d="#";c+=d+"</th>"}c+="<th></th>";if(void 0==b)document.getElementById(a+"List").getElementsByTagName("tr")[0].innerHTML=c;else for(a=document.querySelectorAll(b),e=0;e<a.length;e++)a[e].getElementsByTagName("tr")[0].innerHTML=c}}
function getSettings(){sendAPI({cmd:"MPD_API_SETTINGS_GET"},parseSettings)}
function saveCols(a,b){var c=document.getElementById(a+"ColsDropdown").firstChild.getElementsByTagName("input");var d=void 0==b?document.getElementById(a+"List").getElementsByTagName("tr")[0]:"string"==typeof b?document.querySelector(b).getElementsByTagName("tr")[0]:b.getElementsByTagName("tr")[0];for(b=0;b<c.length;b++){var e=d.querySelector("[data-col="+c[b].name+"]");0==c[b].checked?e&&e.remove():e||(e=document.createElement("th"),e.innerText=c[b].name,e.setAttribute("data-col",c[b].name),d.appendChild(e))}a=
{cmd:"MPD_API_COLS_SAVE",data:{table:"cols"+a,cols:[]}};c=d.getElementsByTagName("th");for(b=0;b<c.length;b++)(d=c[b].getAttribute("data-col"))&&a.data.cols.push(d);sendAPI(a,getSettings)}
function saveColsPlayback(a){for(var b=document.getElementById(a+"ColsDropdown").firstChild.getElementsByTagName("input"),c=document.getElementById("cardPlaybackTags"),d=0;d<b.length;d++){var e=document.getElementById("current"+b[d].name);0==b[d].checked?e&&e.remove():e||(e=document.createElement("div"),e.innerHTML="<small>"+b[d].name+"</small><h4></h4>",e.setAttribute("id","current"+b[d].name),e.setAttribute("data-tag",b[d].name),c.appendChild(e))}a={cmd:"MPD_API_COLS_SAVE",data:{table:"cols"+a,
cols:[]}};c=c.getElementsByTagName("div");for(d=0;d<c.length;d++)(b=c[d].getAttribute("data-tag"))&&a.data.cols.push(b);sendAPI(a,getSettings)}
function parseOutputs(a){for(var b="",c=a.data.outputs.length,d=0;d<c;d++)b+='<button id="btnOutput'+a.data.outputs[d].id+'" data-output-id="'+a.data.outputs[d].id+'" class="btn btn-secondary btn-block',1==a.data.outputs[d].state&&(b+=" active"),b+='"><span class="material-icons float-left">volume_up</span> '+a.data.outputs[d].name+"</button>";domCache.outputs.innerHTML=b}
function setCounter(a,b,c){currentSong.totalTime=b;currentSong.elapsedTime=c;currentSong.currentSongId=a;var d=Math.floor(b/60),e=b-60*d,f=Math.floor(c/60),g=c-60*f;domCache.progressBar.value=Math.floor(100*c/b);b=f+":"+(10>g?"0":"")+g+" / "+d+":"+(10>e?"0":"")+e;domCache.counter.innerText=b;if(lastState&&lastState.data.currentSongId!=a&&(c=document.getElementById("queueTrackId"+lastState.data.currentSongId))){if(d=c.querySelector("[data-col=Duration]"))d.innerText=c.getAttribute("data-duration");
if(d=c.querySelector("[data-col=Pos]"))d.classList.remove("material-icons"),d.innerText=c.getAttribute("data-songpos");c.classList.remove("font-weight-bold")}if(c=document.getElementById("queueTrackId"+a)){if(d=c.querySelector("[data-col=Duration]"))d.innerText=b;(d=c.querySelector("[data-col=Pos]"))&&!d.classList.contains("material-icons")&&(d.classList.add("material-icons"),d.innerText="play_arrow");c.classList.add("font-weight-bold")}progressTimer&&clearTimeout(progressTimer);"play"==playstate&&
(progressTimer=setTimeout(function(){currentSong.elapsedTime++;setCounter(currentSong.currentSongId,currentSong.totalTime,currentSong.elapsedTime)},1E3))}
function parseState(a){if(JSON.stringify(a)!==JSON.stringify(lastState)){if(1==a.data.state){for(var b=0;b<domCache.btnsPlayLen;b++)domCache.btnsPlay[b].innerText="play_arrow";playstate="stop"}else if(2==a.data.state){for(b=0;b<domCache.btnsPlayLen;b++)domCache.btnsPlay[b].innerText="pause";playstate="play"}else{for(b=0;b<domCache.btnsPlayLen;b++)domCache.btnsPlay[b].innerText="play_arrow";playstate="pause"}-1==a.data.nextSongPos&&0==settings.jukeboxMode?domCache.btnNext.setAttribute("disabled","disabled"):
domCache.btnNext.removeAttribute("disabled");0>=a.data.songPos?domCache.btnPrev.setAttribute("disabled","disabled"):domCache.btnPrev.removeAttribute("disabled");if(0==a.data.queueLength)for(b=0;b<domCache.btnsPlayLen;b++)domCache.btnsPlay[b].setAttribute("disabled","disabled");else for(b=0;b<domCache.btnsPlayLen;b++)domCache.btnsPlay[b].removeAttribute("disabled");parseVolume(a);setCounter(a.data.currentSongId,a.data.totalTime,a.data.elapsedTime);lastState&&lastState.data.currentSongId!=a.data.currentSongId&&
sendAPI({cmd:"MPD_API_PLAYER_CURRENT_SONG"},songChange);"-1"==a.data.songPos&&(domCache.currentTrack.innerText="Not playing",domCache.currentAlbum.innerText="",domCache.currentArtist.innerText="",domCache.currentCover.style.backgroundImage="");lastState=a}}
function parseVolume(a){-1==a.data.volume?(domCache.volumePrct.innerText="Volumecontrol disabled",domCache.volumeControl.classList.add("hide")):(domCache.volumeControl.classList.remove("hide"),domCache.volumePrct.innerText=a.data.volume+" %",domCache.volumeIcon.innerText=0==a.data.volume?"volume_off":50>a.data.volume?"volume_down":"volume_up");domCache.volumeBar.value=a.data.volume}
domCache.btnNext.removeAttribute("disabled");0>=a.data.songPos?domCache.btnPrev.setAttribute("disabled","disabled"):domCache.btnPrev.removeAttribute("disabled");if(0==a.data.queueLength)for(b=0;b<domCache.btnsPlayLen;b++)domCache.btnsPlay[b].setAttribute("disabled","disabled");else for(b=0;b<domCache.btnsPlayLen;b++)domCache.btnsPlay[b].removeAttribute("disabled");domCache.badgeQueueItems.innerText=a.data.queueLength;parseVolume(a);setCounter(a.data.currentSongId,a.data.totalTime,a.data.elapsedTime);
lastState&&lastState.data.currentSongId!=a.data.currentSongId&&sendAPI({cmd:"MPD_API_PLAYER_CURRENT_SONG"},songChange);if("-1"==a.data.songPos){domCache.currentTitle.innerText="Not playing";domCache.currentCover.style.backgroundImage="";var c=document.getElementById("cardPlaybackTags").getElementsByTagName("h4");for(b=0;b<c.length;b++)c[b].innerText=""}"LastPlayed"==app.current.app&&sendAPI({cmd:"MPD_API_QUEUE_LAST_PLAYED",data:{offset:app.current.page}},parseLastPlayed);lastState=a}}
function parseVolume(a){-1==a.data.volume?(domCache.volumePrct.innerText="Volumecontrol disabled",domCache.volumeControl.classList.add("hide")):(domCache.volumeControl.classList.remove("hide"),domCache.volumePrct.innerText=a.data.volume+" %",domCache.volumeMenu.innerText=0==a.data.volume?"volume_off":50>a.data.volume?"volume_down":"volume_up");domCache.volumeBar.value=a.data.volume}
function getQueue(){2<=app.current.search.length?sendAPI({cmd:"MPD_API_QUEUE_SEARCH",data:{filter:app.current.filter,offset:app.current.page,searchstr:app.current.search}},parseQueue):sendAPI({cmd:"MPD_API_QUEUE_LIST",data:{offset:app.current.page}},parseQueue)}
function parseQueue(a){if("Queue"===app.current.app){0<a.totalTime&&a.totalEntities<=settings.maxElementsPerPage?document.getElementById("panel-heading-queue").innerText=a.totalEntities+" "+(1<a.totalEntities?"Songs":"Song")+" \u2013 "+beautifyDuration(a.totalTime):0<a.totalEntities?document.getElementById("panel-heading-queue").innerText=a.totalEntities+" "+(1<a.totalEntities?"Songs":"Song"):document.getElementById("panel-heading-queue").innerText="";var b=a.data.length,c=document.getElementById(app.current.app+
"List");c.setAttribute("data-version",a.queueVersion);c=c.getElementsByTagName("tbody")[0];for(var d=c.getElementsByTagName("tr"),e=0;e<b;e++){var f=Math.floor(a.data[e].Duration/60),g=a.data[e].Duration-60*f;a.data[e].Duration=f+":"+(10>g?"0":"")+g;f=document.createElement("tr");f.setAttribute("draggable","true");f.setAttribute("data-trackid",a.data[e].id);f.setAttribute("id","queueTrackId"+a.data[e].id);f.setAttribute("data-songpos",a.data[e].Pos+1);f.setAttribute("data-duration",a.data[e].Duration);
f.setAttribute("data-uri",a.data[e].uri);g="";for(var h=0;h<settings.colsQueue.length;h++)g+='<td data-col="'+settings.colsQueue[h]+'">'+a.data[e][settings.colsQueue[h]]+"</td>";g+='<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';f.innerHTML=g;e<d.length?d[e].replaceWith(f):c.append(f)}for(e=d.length-1;e>=b;e--)d[e].remove();"queuesearch"==a.type&&0==b?c.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td colspan="5">No results, please refine your search!</td></tr>':
"queue"==a.type&&0==b&&(c.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td colspan="5">Empty queue</td></tr>');setPagination(a.totalEntities);document.getElementById("QueueList").classList.remove("opacity05")}}
function parseSearch(a){"Search"===app.current.app&&(document.getElementById("panel-heading-search").innerHTML=a.totalEntities+" Songs found",0<a.totalEntities?(document.getElementById("searchAddAllSongs").removeAttribute("disabled"),document.getElementById("searchAddAllSongsBtn").removeAttribute("disabled")):(document.getElementById("searchAddAllSongs").setAttribute("disabled","disabled"),document.getElementById("searchAddAllSongsBtn").setAttribute("disabled","disabled")),parseFilesystem(a))}
function parseFilesystem(a){if("Browse"===app.current.app||"Filesystem"===app.current.tab||"Search"===app.current.app){for(var b=app.current.app+("Filesystem"==app.current.tab?app.current.tab:""),c=a.data.length,d=document.getElementById(app.current.app+(void 0==app.current.tab?"":app.current.tab)+"List").getElementsByTagName("tbody")[0],e=d.getElementsByTagName("tr"),f=0;f<c;f++){var g=encodeURI(a.data[f].uri),h=document.createElement("tr");h.setAttribute("data-type",a.data[f].Type);h.setAttribute("data-uri",
g);"song"==a.data[f].Type?h.setAttribute("data-name",a.data[f].Title):h.setAttribute("data-name",a.data[f].name);switch(a.data[f].Type){case "dir":case "smartpls":case "plist":g="";for(var k=0;k<settings["cols"+b].length;k++)g+='<td data-col="'+settings["cols"+b][k]+'">',"Type"==settings["cols"+b][k]?g="dir"==a.data[f].Type?g+'<span class="material-icons">folder_open</span>':g+'<span class="material-icons">list</span>':"Title"==settings["cols"+b][k]&&(g+=a.data[f].name),g+="</td>";g+='<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
h.innerHTML=g;break;case "song":g=Math.floor(a.data[f].Duration/60);k=a.data[f].Duration-60*g;a.data[f].Duration=g+":"+(10>k?"0":"")+k;g="";for(k=0;k<settings["cols"+b].length;k++)g+='<td data-col="'+settings["cols"+b][k]+'">',g="Type"==settings["cols"+b][k]?g+'<span class="material-icons">music_note</span>':g+a.data[f][settings["cols"+b][k]],g+="</td>";g+='<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';h.innerHTML=g}f<e.length?e[f].replaceWith(h):d.append(h)}for(f=
e.length-1;f>=c;f--)e[f].remove();setPagination(a.totalEntities);0==c&&(d.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td colspan="5">No results</td></tr>');document.getElementById(app.current.app+(void 0==app.current.tab?"":app.current.tab)+"List").classList.remove("opacity05")}}
function parsePlaylists(a){if("Browse"===app.current.app||"Playlists"===app.current.tab){"All"==app.current.view?(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"),document.getElementById("BrowsePlaylistsDetailColsBtn").parentNode.classList.add("hide")):
(-1<a.uri.indexOf(".")||1==a.smartpls?(document.getElementById("BrowsePlaylistsDetailList").setAttribute("data-ro","true"),document.getElementById("btnPlaylistClear").parentNode.classList.add("hide")):(document.getElementById("BrowsePlaylistsDetailList").setAttribute("data-ro","false"),document.getElementById("btnPlaylistClear").parentNode.classList.remove("hide")),document.getElementById("BrowsePlaylistsDetailList").setAttribute("data-uri",a.uri),1==a.smartpls?document.getElementById("BrowsePlaylistsDetailList").getElementsByTagName("caption")[0].innerHTML=
"Smart playlist: "+a.uri+'<small class="pull-right">'+a.totalEntities+" Songs </small>":document.getElementById("BrowsePlaylistsDetailList").getElementsByTagName("caption")[0].innerHTML="Playlist: "+a.uri+'<small class="pull-right">'+a.totalEntities+" Songs </small>",document.getElementById("BrowsePlaylistsDetailList").classList.remove("hide"),document.getElementById("BrowsePlaylistsAllList").classList.add("hide"),document.getElementById("btnBrowsePlaylistsAll").parentNode.classList.remove("hide"),
settings.featTags&&document.getElementById("BrowsePlaylistsDetailColsBtn").parentNode.classList.remove("hide"));var b=a.data.length,c=document.getElementById(app.current.app+app.current.tab+app.current.view+"List").getElementsByTagName("tbody")[0],d=c.getElementsByTagName("tr");if("All"==app.current.view)for(var e=0;e<b;e++){var f=encodeURI(a.data[e].uri);if(!d[e]||d[e].getAttribute("data-uri")!=f){var g=new Date(1E3*a.data[e].last_modified),h=document.createElement("tr");h.setAttribute("data-uri",
f);h.setAttribute("data-type",a.data[e].Type);h.setAttribute("data-name",a.data[e].name);h.innerHTML='<td data-col="Type"><span class="material-icons">list</span></td><td>'+a.data[e].name+"</td><td>"+g.toUTCString()+'</td><td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';e<d.length?d[e].replaceWith(h):c.append(h)}}else if("Detail"==app.current.view)for(e=0;e<b;e++){f=encodeURI(a.data[e].uri);h=document.createElement("tr");0==a.smartpls&&h.setAttribute("draggable",
"true");h.setAttribute("id","playlistTrackId"+a.data[e].Pos);h.setAttribute("data-type",a.data[e].Type);h.setAttribute("data-uri",f);h.setAttribute("data-name",a.data[e].Title);h.setAttribute("data-songpos",a.data[e].Pos);f=Math.floor(a.data[e].Duration/60);g=a.data[e].Duration-60*f;a.data[e].Duration=f+":"+(10>g?"0":"")+g;f="";for(g=0;g<settings.colsBrowsePlaylistsDetail.length;g++)f+='<td data-col="'+settings.colsBrowsePlaylistsDetail[g]+'">'+a.data[e][settings.colsBrowsePlaylistsDetail[g]]+"</td>";
f+='<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';h.innerHTML=f;e<d.length?d[e].replaceWith(h):c.append(h)}for(e=d.length-1;e>=b;e--)d[e].remove();setPagination(a.totalEntities);0==b&&(c.innerHTML="All"==app.current.view?'<tr><td><span class="material-icons">error_outline</span></td><td colspan="5">No playlists found.</td></tr>':'<tr><td><span class="material-icons">error_outline</span></td><td colspan="5">Empty playlist.</td></tr>');document.getElementById(app.current.app+
app.current.tab+app.current.view+"List").classList.remove("opacity05")}}
function parseQueue(a){0<a.totalTime&&a.totalEntities<=settings.maxElementsPerPage?document.getElementById("cardFooterQueue").innerText=a.totalEntities+" "+(1<a.totalEntities?"Songs":"Song")+" \u2013 "+beautifyDuration(a.totalTime):0<a.totalEntities?document.getElementById("cardFooterQueue").innerText=a.totalEntities+" "+(1<a.totalEntities?"Songs":"Song"):document.getElementById("cardFooterQueue").innerText="";var b=a.data.length,c=document.getElementById("QueueCurrentList");c.setAttribute("data-version",
a.queueVersion);c=c.getElementsByTagName("tbody")[0];for(var d=c.getElementsByTagName("tr"),e=0;e<b;e++){var f=Math.floor(a.data[e].Duration/60),g=a.data[e].Duration-60*f;a.data[e].Duration=f+":"+(10>g?"0":"")+g;a.data[e].Pos++;f=document.createElement("tr");f.setAttribute("draggable","true");f.setAttribute("data-trackid",a.data[e].id);f.setAttribute("id","queueTrackId"+a.data[e].id);f.setAttribute("data-songpos",a.data[e].Pos);f.setAttribute("data-duration",a.data[e].Duration);f.setAttribute("data-uri",
a.data[e].uri);g="";for(var h=0;h<settings.colsQueueCurrent.length;h++)g+='<td data-col="'+settings.colsQueueCurrent[h]+'">'+a.data[e][settings.colsQueueCurrent[h]]+"</td>";g+='<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';f.innerHTML=g;e<d.length?d[e].replaceWith(f):c.append(f)}for(e=d.length-1;e>=b;e--)d[e].remove();d=settings.colsQueueCurrent.length;d--;"queuesearch"==a.type&&0==b?c.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td colspan="'+
d+'">No results, please refine your search!</td></tr>':"queue"==a.type&&0==b&&(c.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td colspan="'+d+'">Empty queue</td></tr>');setPagination(a.totalEntities);document.getElementById("QueueCurrentList").classList.remove("opacity05")}
function parseLastPlayed(a){document.getElementById("cardFooterQueue").innerText=a.totalEntities+" Songs";var b=a.data.length,c=document.getElementById("QueueLastPlayedList");c.setAttribute("data-version",a.queueVersion);c=c.getElementsByTagName("tbody")[0];for(var d=c.getElementsByTagName("tr"),e=0;e<b;e++){var f=Math.floor(a.data[e].Duration/60),g=a.data[e].Duration-60*f;a.data[e].Duration=f+":"+(10>g?"0":"")+g;a.data[e].LastPlayed=(new Date(1E3*a.data[e].LastPlayed)).toUTCString();f=document.createElement("tr");
f.setAttribute("data-songpos",a.data[e].Pos+1);f.setAttribute("data-uri",a.data[e].uri);f.setAttribute("data-name",a.data[e].Title);f.setAttribute("data-type","song");g="";for(var h=0;h<settings.colsQueueLastPlayed.length;h++)g+='<td data-col="'+settings.colsQueueLastPlayed[h]+'">'+a.data[e][settings.colsQueueLastPlayed[h]]+"</td>";g+='<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';f.innerHTML=g;e<d.length?d[e].replaceWith(f):c.append(f)}for(e=d.length-
1;e>=b;e--)d[e].remove();d=settings.colsQueueLastPlayed.length;d--;0==b&&(c.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td colspan="'+d+'">Empty list</td></tr>');setPagination(a.totalEntities);document.getElementById("QueueLastPlayedList").classList.remove("opacity05")}
function parseSearch(a){document.getElementById("panel-heading-search").innerHTML=a.totalEntities+" Songs found";document.getElementById("cardFooterSearch").innerHTML=a.totalEntities+" Songs found";0<a.totalEntities?(document.getElementById("searchAddAllSongs").removeAttribute("disabled"),document.getElementById("searchAddAllSongsBtn").removeAttribute("disabled")):(document.getElementById("searchAddAllSongs").setAttribute("disabled","disabled"),document.getElementById("searchAddAllSongsBtn").setAttribute("disabled",
"disabled"));parseFilesystem(a)}
function parseFilesystem(a){var b=app.current.app+("Filesystem"==app.current.tab?app.current.tab:""),c=settings["cols"+b].length;c--;for(var d=a.data.length,e=document.getElementById(app.current.app+(void 0==app.current.tab?"":app.current.tab)+"List").getElementsByTagName("tbody")[0],f=e.getElementsByTagName("tr"),g=0;g<d;g++){var h=encodeURI(a.data[g].uri),l=document.createElement("tr");l.setAttribute("data-type",a.data[g].Type);l.setAttribute("data-uri",h);"song"==a.data[g].Type?l.setAttribute("data-name",
a.data[g].Title):l.setAttribute("data-name",a.data[g].name);switch(a.data[g].Type){case "dir":case "smartpls":case "plist":h="";for(var k=0;k<settings["cols"+b].length;k++)h+='<td data-col="'+settings["cols"+b][k]+'">',"Type"==settings["cols"+b][k]?h="dir"==a.data[g].Type?h+'<span class="material-icons">folder_open</span>':h+'<span class="material-icons">list</span>':"Title"==settings["cols"+b][k]&&(h+=a.data[g].name),h+="</td>";h+='<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
l.innerHTML=h;break;case "song":h=Math.floor(a.data[g].Duration/60);k=a.data[g].Duration-60*h;a.data[g].Duration=h+":"+(10>k?"0":"")+k;h="";for(k=0;k<settings["cols"+b].length;k++)h+='<td data-col="'+settings["cols"+b][k]+'">',h="Type"==settings["cols"+b][k]?h+'<span class="material-icons">music_note</span>':h+a.data[g][settings["cols"+b][k]],h+="</td>";h+='<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';l.innerHTML=h}g<f.length?f[g].replaceWith(l):e.append(l)}for(g=
f.length-1;g>=d;g--)f[g].remove();setPagination(a.totalEntities);0==d&&(e.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td colspan="'+c+'">No results</td></tr>');document.getElementById(app.current.app+(void 0==app.current.tab?"":app.current.tab)+"List").classList.remove("opacity05");document.getElementById("cardFooterBrowse").innerText=a.totalEntities+" Entries"}
function parsePlaylists(a){"All"==app.current.view?(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"),document.getElementById("BrowsePlaylistsDetailColsBtn").parentNode.classList.add("hide")):(-1<a.uri.indexOf(".")||1==a.smartpls?(document.getElementById("BrowsePlaylistsDetailList").setAttribute("data-ro",
"true"),document.getElementById("btnPlaylistClear").parentNode.classList.add("hide")):(document.getElementById("BrowsePlaylistsDetailList").setAttribute("data-ro","false"),document.getElementById("btnPlaylistClear").parentNode.classList.remove("hide")),document.getElementById("BrowsePlaylistsDetailList").setAttribute("data-uri",a.uri),1==a.smartpls?document.getElementById("BrowsePlaylistsDetailList").getElementsByTagName("caption")[0].innerHTML="Smart playlist: "+a.uri+'<small class="pull-right">'+
a.totalEntities+" Songs </small>":document.getElementById("BrowsePlaylistsDetailList").getElementsByTagName("caption")[0].innerHTML="Playlist: "+a.uri+'<small class="pull-right">'+a.totalEntities+" Songs </small>",document.getElementById("BrowsePlaylistsDetailList").classList.remove("hide"),document.getElementById("BrowsePlaylistsAllList").classList.add("hide"),document.getElementById("btnBrowsePlaylistsAll").parentNode.classList.remove("hide"),settings.featTags&&document.getElementById("BrowsePlaylistsDetailColsBtn").parentNode.classList.remove("hide"));
var b=a.data.length,c=document.getElementById(app.current.app+app.current.tab+app.current.view+"List").getElementsByTagName("tbody")[0],d=c.getElementsByTagName("tr");if("All"==app.current.view){for(var e=0;e<b;e++){var f=encodeURI(a.data[e].uri),g=new Date(1E3*a.data[e].last_modified),h=document.createElement("tr");h.setAttribute("data-uri",f);h.setAttribute("data-type",a.data[e].Type);h.setAttribute("data-name",a.data[e].name);h.innerHTML='<td data-col="Type"><span class="material-icons">list</span></td><td>'+
a.data[e].name+"</td><td>"+g.toUTCString()+'</td><td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';e<d.length?d[e].replaceWith(h):c.append(h)}document.getElementById("cardFooterBrowse").innerText=a.totalEntities+" Playlists"}else if("Detail"==app.current.view){for(e=0;e<b;e++){f=encodeURI(a.data[e].uri);h=document.createElement("tr");0==a.smartpls&&h.setAttribute("draggable","true");h.setAttribute("id","playlistTrackId"+a.data[e].Pos);h.setAttribute("data-type",
a.data[e].Type);h.setAttribute("data-uri",f);h.setAttribute("data-name",a.data[e].Title);h.setAttribute("data-songpos",a.data[e].Pos);f=Math.floor(a.data[e].Duration/60);g=a.data[e].Duration-60*f;a.data[e].Duration=f+":"+(10>g?"0":"")+g;f="";for(g=0;g<settings.colsBrowsePlaylistsDetail.length;g++)f+='<td data-col="'+settings.colsBrowsePlaylistsDetail[g]+'">'+a.data[e][settings.colsBrowsePlaylistsDetail[g]]+"</td>";f+='<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
h.innerHTML=f;e<d.length?d[e].replaceWith(h):c.append(h)}document.getElementById("cardFooterBrowse").innerText=a.totalEntities+" Songs"}for(e=d.length-1;e>=b;e--)d[e].remove();setPagination(a.totalEntities);0==b&&(a=settings["cols"+list].length,a--,c.innerHTML="All"==app.current.view?'<tr><td><span class="material-icons">error_outline</span></td><td colspan="'+a+'">No playlists found.</td></tr>':'<tr><td><span class="material-icons">error_outline</span></td><td colspan="'+a+'">Empty playlist.</td></tr>');
document.getElementById(app.current.app+app.current.tab+app.current.view+"List").classList.remove("opacity05")}
function parseListDBtags(a){scrollTo(0);if(""!=app.current.search){document.getElementById("BrowseDatabaseAlbumList").classList.remove("hide");document.getElementById("BrowseDatabaseTagList").classList.add("hide");document.getElementById("btnBrowseDatabaseByTag").parentNode.classList.add("hide");document.getElementById("btnBrowseDatabaseTag").parentNode.classList.remove("hide");document.getElementById("BrowseDatabaseAddAllSongs").parentNode.parentNode.classList.remove("hide");document.getElementById("BrowseDatabaseColsBtn").parentNode.classList.remove("hide");
document.getElementById("btnBrowseDatabaseTag").innerHTML="&laquo; "+app.current.view;document.getElementById("BrowseDatabaseAlbumListCaption").innerHTML="<h2>"+a.searchtagtype+": "+a.searchstr+'</h2><small class="pull-right">'+a.totalEntities+" Entries</small><hr/>";for(var b=a.data.length,c=document.getElementById("BrowseDatabaseAlbumList"),d=c.getElementsByClassName("card"),e=0;e<b;e++){var f=genId(a.data[e].value),g=document.createElement("div");g.classList.add("card","ml-4","mr-4","mb-4","w-100");
g.setAttribute("id","card"+f);g.setAttribute("data-album",encodeURI(a.data[e].value));var h='<div class="card-header"><span id="albumartist'+f+'"></span> &ndash; '+a.data[e].value+'</div> <div class="card-body"><div class="row">';settings.featCoverimage&&(h+=' <div class="col-md-auto"><a class="card-img-left"></a></div>');h+=' <div class="col"><table class="tblAlbumTitles table table-sm table-hover" id="tbl'+f+'"><thead><tr></tr></thead><tbody></tbody></table></div> </div></div></div>';g.innerHTML=
h;e<d.length?d[e].replaceWith(g):c.append(g);"IntersectionObserver"in window?createListTitleObserver(document.getElementById("card"+f)):sendAPI({cmd:"MPD_API_DATABASE_TAG_ALBUM_TITLE_LIST",data:{album:a.data[e].value,search:app.current.search,tag:app.current.view}},parseListTitles)}for(e=d.length-1;e>=b;e--)d[e].remove();setPagination(a.totalEntities);setCols("BrowseDatabase",".tblAlbumTitles");a=document.querySelectorAll(".tblAlbumTitles");for(e=0;e<a.length;e++)dragAndDropTableHeader(a[e]);document.getElementById("BrowseDatabaseAlbumList").classList.remove("opacity05")}else{document.getElementById("BrowseDatabaseAlbumList").classList.add("hide");
document.getElementById("BrowseDatabaseTagList").classList.remove("hide");document.getElementById("btnBrowseDatabaseByTag").parentNode.classList.remove("hide");document.getElementById("BrowseDatabaseAddAllSongs").parentNode.parentNode.classList.add("hide");document.getElementById("BrowseDatabaseColsBtn").parentNode.classList.add("hide");document.getElementById("btnBrowseDatabaseTag").parentNode.classList.add("hide");document.getElementById("BrowseDatabaseTagListCaption").innerHTML=app.current.view+
'<small class="pull-right">'+a.totalEntities+" Tags</small>";b=a.data.length;c=document.getElementById(app.current.app+app.current.tab+"TagList").getElementsByTagName("tbody")[0];d=c.getElementsByTagName("tr");for(e=0;e<b;e++)f=encodeURI(a.data[e].value),d[e]&&d[e].getAttribute("data-uri")==f||(g=document.createElement("tr"),g.setAttribute("data-uri",f),g.innerHTML='<td data-col="Type"><span class="material-icons">album</span></td><td>'+a.data[e].value+"</td>",e<d.length?d[e].replaceWith(g):c.append(g));
for(e=d.length-1;e>=b;e--)d[e].remove();setPagination(a.totalEntities);0==b&&(c.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td>No entries found.</td></tr>');document.getElementById("BrowseDatabaseTagList").classList.remove("opacity05")}}function createListTitleObserver(a){(new IntersectionObserver(getListTitles,{root:null,rootMargin:"0px"})).observe(a)}
document.getElementById("btnBrowseDatabaseTag").innerHTML="&laquo; "+app.current.view;document.getElementById("BrowseDatabaseAlbumListCaption").innerHTML="<h2>"+a.searchtagtype+": "+a.searchstr+"</h2><hr/>";document.getElementById("cardFooterBrowse").innerText=a.totalEntities+" Entries";for(var b=a.data.length,c=document.getElementById("BrowseDatabaseAlbumList"),d=c.getElementsByClassName("card"),e=0;e<b;e++){var f=genId(a.data[e].value),g=document.createElement("div");g.classList.add("card","ml-4",
"mr-4","mb-4","w-100");g.setAttribute("id","card"+f);g.setAttribute("data-album",encodeURI(a.data[e].value));var h='<div class="card-header"><span id="albumartist'+f+'"></span> &ndash; '+a.data[e].value+'</div> <div class="card-body"><div class="row">';settings.featCoverimage&&(h+=' <div class="col-md-auto"><a class="card-img-left"></a></div>');h+=' <div class="col"><table class="tblAlbumTitles table table-sm table-hover" id="tbl'+f+'"><thead><tr></tr></thead><tbody></tbody></table></div> </div></div></div>';
g.innerHTML=h;e<d.length?d[e].replaceWith(g):c.append(g);"IntersectionObserver"in window?createListTitleObserver(document.getElementById("card"+f)):sendAPI({cmd:"MPD_API_DATABASE_TAG_ALBUM_TITLE_LIST",data:{album:a.data[e].value,search:app.current.search,tag:app.current.view}},parseListTitles)}for(e=d.length-1;e>=b;e--)d[e].remove();setPagination(a.totalEntities);setCols("BrowseDatabase",".tblAlbumTitles");a=document.querySelectorAll(".tblAlbumTitles");for(e=0;e<a.length;e++)dragAndDropTableHeader(a[e]);
document.getElementById("BrowseDatabaseAlbumList").classList.remove("opacity05")}else{document.getElementById("BrowseDatabaseAlbumList").classList.add("hide");document.getElementById("BrowseDatabaseTagList").classList.remove("hide");document.getElementById("btnBrowseDatabaseByTag").parentNode.classList.remove("hide");document.getElementById("BrowseDatabaseAddAllSongs").parentNode.parentNode.classList.add("hide");document.getElementById("BrowseDatabaseColsBtn").parentNode.classList.add("hide");document.getElementById("btnBrowseDatabaseTag").parentNode.classList.add("hide");
document.getElementById("BrowseDatabaseTagListCaption").innerText=app.current.view;document.getElementById("cardFooterBrowse").innerText=a.totalEntities+" Tags";b=a.data.length;c=document.getElementById(app.current.app+app.current.tab+"TagList").getElementsByTagName("tbody")[0];d=c.getElementsByTagName("tr");for(e=0;e<b;e++)f=encodeURI(a.data[e].value),g=document.createElement("tr"),g.setAttribute("data-uri",f),g.innerHTML='<td data-col="Type"><span class="material-icons">album</span></td><td>'+a.data[e].value+
"</td>",e<d.length?d[e].replaceWith(g):c.append(g);for(e=d.length-1;e>=b;e--)d[e].remove();setPagination(a.totalEntities);0==b&&(c.innerHTML='<tr><td><span class="material-icons">error_outline</span></td><td>No entries found.</td></tr>');document.getElementById("BrowseDatabaseTagList").classList.remove("opacity05")}}function createListTitleObserver(a){(new IntersectionObserver(getListTitles,{root:null,rootMargin:"0px"})).observe(a)}
function getListTitles(a,b){a.forEach(function(a){0<a.intersectionRatio&&(b.unobserve(a.target),a=decodeURI(a.target.getAttribute("data-album")),sendAPI({cmd:"MPD_API_DATABASE_TAG_ALBUM_TITLE_LIST",data:{album:a,search:app.current.search,tag:app.current.view}},parseListTitles))})}
function parseListTitles(a){var b=genId(a.Album),c=document.getElementById("card"+b),d=c.getElementsByTagName("tbody")[0],e=c.querySelector(".card-header");e.setAttribute("data-uri",encodeURI(a.data[0].uri.replace(/\/[^\/]+$/,"")));e.setAttribute("data-name",a.Album);e.setAttribute("data-type","dir");e.addEventListener("click",function(a){showMenu(this,a)},!1);e.classList.add("clickable");if(c=c.getElementsByTagName("a")[0])c.style.backgroundImage='url("'+a.cover+'")',c.setAttribute("data-uri",encodeURI(a.data[0].uri.replace(/\/[^\/]+$/,
""))),c.setAttribute("data-name",a.Album),c.setAttribute("data-type","dir"),c.addEventListener("click",function(a){showMenu(this,a)},!1);document.getElementById("albumartist"+b).innerText=a.AlbumArtist;b="";c=a.data.length;for(e=0;e<c;e++){if(a.data[e].Duration){var f=Math.floor(a.data[e].Duration/60),g=a.data[e].Duration-60*f;a.data[e].Duration=f+":"+(10>g?"0":"")+g}b+='<tr data-type="song" data-name="'+a.data[e].Title+'" data-uri="'+encodeURI(a.data[e].uri)+'">';for(f=0;f<settings.colsBrowseDatabase.length;f++)b+=
@ -119,18 +131,19 @@ function setPagination(a){var b=Math.ceil(a/settings.maxElementsPerPage),c=app.c
(g+1)+"</button>";document.getElementById(c+d[e]+"Pages").innerHTML=f}else document.getElementById(c+d[e]+"Page").setAttribute("disabled","disabled");a>app.current.page+settings.maxElementsPerPage?(document.getElementById(c+d[e]+"Next").removeAttribute("disabled"),document.getElementById(c+d[e]).classList.remove("hide"),document.getElementById(c+"ButtonsBottom").classList.remove("hide")):(document.getElementById(c+d[e]+"Next").setAttribute("disabled","disabled"),document.getElementById(c+d[e]).classList.add("hide"),
document.getElementById(c+"ButtonsBottom").classList.add("hide"));0<app.current.page?(document.getElementById(c+d[e]+"Prev").removeAttribute("disabled"),document.getElementById(c+d[e]).classList.remove("hide"),document.getElementById(c+"ButtonsBottom").classList.remove("hide")):document.getElementById(c+d[e]+"Prev").setAttribute("disabled","disabled")}}
function appendQueue(a,b,c){switch(a){case "song":case "dir":sendAPI({cmd:"MPD_API_QUEUE_ADD_TRACK",data:{uri:b}});showNotification('"'+c+'" added',"","","success");break;case "plist":sendAPI({cmd:"MPD_API_QUEUE_ADD_PLAYLIST",data:{plist:b}}),showNotification('"'+c+'" added',"","","success")}}function appendAfterQueue(a,b,c,d){switch(a){case "song":sendAPI({cmd:"MPD_API_QUEUE_ADD_TRACK_AFTER",data:{uri:b,to:c}}),showNotification('"'+d+'" added to pos '+c,"","","success")}}
function replaceQueue(a,b,c){switch(a){case "song":case "dir":sendAPI({cmd:"MPD_API_QUEUE_REPLACE_TRACK",data:{uri:b}});showNotification('"'+c+'" replaced',"","","success");break;case "plist":sendAPI({cmd:"MPD_API_QUEUE_REPLACE_PLAYLIST",data:{plist:b}}),showNotification('"'+c+'" replaced',"","","success")}}function songClick(){var a=domCache.currentTrack.getAttribute("data-uri");""!=a&&songDetails(a)}
function artistClick(){var a=domCache.currentArtist.getAttribute("data-albumartist");""!=a&&(settings.tags.includes("AlbumArtist")?appGoto("Browse","Database","AlbumArtist","0/-/"+a):settings.tags.includes("Artist")&&appGoto("Browse","Database","Artist","0/-/"+a))}function albumClick(){var a=domCache.currentAlbum.getAttribute("data-album");""!=a&&appGoto("Browse","Database","Album","0/-/"+a)}
function songDetails(a){sendAPI({cmd:"MPD_API_DATABASE_SONGDETAILS",data:{uri:a}},parseSongDetails);modalSongDetails.show()}
function parseSongDetails(a){var b=document.getElementById("modalSongDetails");b.getElementsByClassName("album-cover")[0].style.backgroundImage='url("'+a.data.cover+'")';b.getElementsByTagName("h1")[0].innerText=a.data.Title;for(var c="",d=0;d<settings.tags.length;d++)c+="<tr><th>"+settings.tags[d]+"</th><td>"+a.data[settings.tags[d]]+"</td></tr>";var e=a.data.Duration;d=Math.floor(e/60);e-=60*d;c+="<tr><th>Duration</th><td>"+(d+":"+(10>e?"0":"")+e)+"</td></tr>";c=settings.featLibrary?c+('<tr><th>Filename</th><td><a class="text-success" href="/library/'+
a.data.uri+'">'+a.data.uri+"</a></td></tr>"):c+("<tr><th>Filename</th><td>"+a.data.uri+"</td></tr>");1==settings.featStickers&&(d="not voted",0==a.data.like?d='<span class="material-icons">thumb_down_alt</span>':2==a.data.like&&(d='<span class="material-icons">thumb_up_alt</span>'),c+='<tr><th colspan="2">Statistics</th></tr><tr><th>Play count</th><td>'+a.data.playCount+"</td></tr><tr><th>Skip count</th><td>"+a.data.skipCount+"</td></tr><tr><th>Last played</th><td>"+(0==a.data.lastPlayed?"never":
(new Date(1E3*a.data.lastPlayed)).toUTCString())+"</td></tr><tr><th>Like</th><td>"+d+"</td></tr>");b.getElementsByTagName("tbody")[0].innerHTML=c}function execSyscmd(a){sendAPI({cmd:"MPD_API_SYSCMD",data:{cmd:a}})}function playlistDetails(a){document.getElementById("BrowsePlaylistsAllList").classList.add("opacity05");appGoto("Browse","Playlists","Detail","0/-/"+a)}
function removeFromPlaylist(a,b){b--;sendAPI({cmd:"MPD_API_PLAYLIST_RM_TRACK",data:{uri:a,track:b}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05")}function playlistClear(){var a=document.getElementById("BrowsePlaylistsDetailList").getAttribute("data-uri");sendAPI({cmd:"MPD_API_PLAYLIST_CLEAR_AND_LIST",data:{uri:a}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05")}
function replaceQueue(a,b,c){switch(a){case "song":case "dir":sendAPI({cmd:"MPD_API_QUEUE_REPLACE_TRACK",data:{uri:b}});showNotification('"'+c+'" replaced',"","","success");break;case "plist":sendAPI({cmd:"MPD_API_QUEUE_REPLACE_PLAYLIST",data:{plist:b}}),showNotification('"'+c+'" replaced',"","","success")}}function clickTitle(){var a=decodeURI(domCache.currentTitle.getAttribute("data-uri"));""!=a&&songDetails(a)}
function gotoBrowse(a){var b=a.parentNode.getAttribute("data-tag");a=decodeURI(a.parentNode.getAttribute("data-name"));""!=b&&""!=a&&"-"!=a&&settings.browsetags.includes(b)&&appGoto("Browse","Database",b,"0/-/"+a)}function songDetails(a){sendAPI({cmd:"MPD_API_DATABASE_SONGDETAILS",data:{uri:a}},parseSongDetails);modalSongDetails.show()}
function parseSongDetails(a){var b=document.getElementById("modalSongDetails");b.getElementsByClassName("album-cover")[0].style.backgroundImage='url("'+a.data.cover+'")';b.getElementsByTagName("h1")[0].innerText=a.data.Title;for(var c="",d=0;d<settings.tags.length;d++)c+="<tr><th>"+settings.tags[d]+'</th><td data-tag="'+settings.tags[d]+'" data-name="'+encodeURI(a.data[settings.tags[d]])+'">',c=settings.browsetags.includes(settings.tags[d])?c+('<a class="text-success" href="#">'+a.data[settings.tags[d]]+
"</a>"):c+a.data[settings.tags[d]],c+="</td></tr>";var e=a.data.Duration;d=Math.floor(e/60);e-=60*d;c+="<tr><th>Duration</th><td>"+(d+":"+(10>e?"0":"")+e)+"</td></tr>";c=settings.featLibrary?c+('<tr><th>Filename</th><td><a class="text-success" href="/library/'+encodeURI(a.data.uri)+'">'+a.data.uri+"</a></td></tr>"):c+("<tr><th>Filename</th><td>"+a.data.uri+"</td></tr>");1==settings.featStickers&&(c+='<tr><th colspan="2">Statistics</th></tr><tr><th>Play count</th><td>'+a.data.playCount+"</td></tr><tr><th>Skip count</th><td>"+
a.data.skipCount+"</td></tr><tr><th>Last played</th><td>"+(0==a.data.lastPlayed?"never":(new Date(1E3*a.data.lastPlayed)).toUTCString())+'</td></tr><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>');
b.getElementsByTagName("tbody")[0].innerHTML=c;setVoteSongBtns(a.data.like,a.data.uri)}function execSyscmd(a){sendAPI({cmd:"MPD_API_SYSCMD",data:{cmd:a}})}function playlistDetails(a){document.getElementById("BrowsePlaylistsAllList").classList.add("opacity05");appGoto("Browse","Playlists","Detail","0/-/"+a)}function removeFromPlaylist(a,b){b--;sendAPI({cmd:"MPD_API_PLAYLIST_RM_TRACK",data:{uri:a,track:b}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05")}
function playlistClear(){var a=document.getElementById("BrowsePlaylistsDetailList").getAttribute("data-uri");sendAPI({cmd:"MPD_API_PLAYLIST_CLEAR_AND_LIST",data:{uri:a}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05")}
function getAllPlaylists(a){var b=a.data.length,c="";0==a.offset&&("addToPlaylistPlaylist"==playlistEl?c="<option></option><option>New Playlist</option>":"selectJukeboxPlaylist"==playlistEl&&(c="<option>Database</option>"));for(var d=0;d<b;d++)c+="<option","selectJukeboxPlaylist"==playlistEl&&a.data[d].uri==settings.jukeboxPlaylist&&(c+=" selected"),c+=">"+a.data[d].uri+"</option>";0==a.offset?document.getElementById(playlistEl).innerHTML=c:document.getElementById(playlistEl).innerHTML+=c;a.totalEntities>
a.returnedEntities&&(a.offset+=settings.maxElementsPerPage,sendAPI({cmd:"MPD_API_PLAYLIST_LIST",data:{offset:a.offset,filter:"-"}},getAllPlaylists))}function updateSmartPlaylists(){sendAPI({cmd:"MPD_API_SMARTPLS_UPDATE_ALL"})}
function voteSong(a){var b=domCache.currentTrack.getAttribute("data-uri");""!=b&&(2==a&&domCache.btnVoteUp.classList.contains("active-fg-green")?a=1:0==a&&domCache.btnVoteDown.classList.contains("active-fg-red")&&(a=1),sendAPI({cmd:"MPD_API_LIKE",data:{uri:b,like:a}}),setVoteSongBtns(a,b))}
function setVoteSongBtns(a,b){""==b||0==b.indexOf("http://")||0==b.indexOf("https://")?(domCache.btnVoteUp.setAttribute("disabled","disabled"),domCache.btnVoteDown.setAttribute("disabled","disabled")):(domCache.btnVoteUp.removeAttribute("disabled"),domCache.btnVoteDown.removeAttribute("disabled"));0==a?(domCache.btnVoteUp.classList.remove("active-fg-green"),domCache.btnVoteDown.classList.add("active-fg-red")):1==a?(domCache.btnVoteUp.classList.remove("active-fg-green"),domCache.btnVoteDown.classList.remove("active-fg-red")):
2==a&&(domCache.btnVoteUp.classList.add("active-fg-green"),domCache.btnVoteDown.classList.remove("active-fg-red"))}
function voteSong(a){var b=domCache.currentTitle.getAttribute("data-uri");""!=b&&(2==a&&domCache.btnVoteUp.classList.contains("active-fg-green")?a=1:0==a&&domCache.btnVoteDown.classList.contains("active-fg-red")&&(a=1),sendAPI({cmd:"MPD_API_LIKE",data:{uri:b,like:a}}),setVoteSongBtns(a,b))}
function setVoteSongBtns(a,b){domCache.btnVoteUp2=document.getElementById("btnVoteUp2");domCache.btnVoteDown2=document.getElementById("btnVoteDown2");""==b||0==b.indexOf("http://")||0==b.indexOf("https://")?(domCache.btnVoteUp.setAttribute("disabled","disabled"),domCache.btnVoteDown.setAttribute("disabled","disabled"),domCache.btnVoteUp2&&(domCache.btnVoteUp2.setAttribute("disabled","disabled"),domCache.btnVoteDown2.setAttribute("disabled","disabled"))):(domCache.btnVoteUp.removeAttribute("disabled"),
domCache.btnVoteDown.removeAttribute("disabled"),domCache.btnVoteUp2&&(domCache.btnVoteUp2.removeAttribute("disabled"),domCache.btnVoteDown2.removeAttribute("disabled")));0==a?(domCache.btnVoteUp.classList.remove("active-fg-green"),domCache.btnVoteDown.classList.add("active-fg-red"),domCache.btnVoteUp2&&(domCache.btnVoteUp2.classList.remove("active-fg-green"),domCache.btnVoteDown2.classList.add("active-fg-red"))):1==a?(domCache.btnVoteUp.classList.remove("active-fg-green"),domCache.btnVoteDown.classList.remove("active-fg-red"),
domCache.btnVoteUp2&&(domCache.btnVoteUp2.classList.remove("active-fg-green"),domCache.btnVoteDown2.classList.remove("active-fg-red"))):2==a&&(domCache.btnVoteUp.classList.add("active-fg-green"),domCache.btnVoteDown.classList.remove("active-fg-red"),domCache.btnVoteUp2&&(domCache.btnVoteUp2.classList.add("active-fg-green"),domCache.btnVoteDown2.classList.remove("active-fg-red")))}
function toggleAddToPlaylistFrm(){var a=document.getElementById("toggleAddToPlaylistBtn");toggleBtn("toggleAddToPlaylistBtn");a.classList.contains("active")?(document.getElementById("addToPlaylistFrm").classList.remove("hide"),document.getElementById("addStreamFooter").classList.add("hide"),document.getElementById("addToPlaylistFooter").classList.remove("hide")):(document.getElementById("addToPlaylistFrm").classList.add("hide"),document.getElementById("addStreamFooter").classList.remove("hide"),document.getElementById("addToPlaylistFooter").classList.add("hide"))}
function saveSearchAsSmartPlaylist(){parseSmartPlaylist({type:"smartpls",data:{playlist:"",type:"search",tag:app.current.filter,searchstr:app.current.search}})}
function parseSmartPlaylist(a){var b=document.getElementById("saveSmartPlaylistName");b.value=a.data.playlist;b.classList.remove("is-invalid");document.getElementById("saveSmartPlaylistType").value=a.data.type;document.getElementById("saveSmartPlaylistFrm").classList.remove("was-validated");document.getElementById("saveSmartPlaylistSearch").classList.add("hide");document.getElementById("saveSmartPlaylistSticker").classList.add("hide");document.getElementById("saveSmartPlaylistNewest").classList.add("hide");
@ -155,10 +168,11 @@ function showMenu(a,b){b.preventDefault();b.stopPropagation();hideMenu();if(!a.g
"Songdetails"):"")+("plist"==b||"smartpls"==b?addMenuItem({cmd:"playlistDetails",options:[c]},"View playlist"):""),"Search"==app.current.app&&(c=dirname(c),f+='<div class="dropdown-divider"></div><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><div class="collapse" id="advancedMenu">'+addMenuItem({cmd:"appendQueue",options:[b,c,d]},"Append to queue")+addMenuItem({cmd:"appendAfterQueue",
options:[b,c,e,d]},"Add after current playing song")+addMenuItem({cmd:"replaceQueue",options:[b,c,d]},"Replace queue")+(settings.featPlaylists?addMenuItem({cmd:"showAddToPlaylist",options:[c]},"Add to playlist"):"")+"</div>")):"Browse"==app.current.app&&"Playlists"==app.current.tab&&"All"==app.current.view?f+=addMenuItem({cmd:"appendQueue",options:[b,c,d]},"Append to queue")+addMenuItem({cmd:"replaceQueue",options:[b,c,d]},"Replace queue")+("smartpls"==b?addMenuItem({cmd:"playlistDetails",options:[c]},
"View playlist"):addMenuItem({cmd:"playlistDetails",options:[c]},"Edit playlist"))+("smartpls"==b?addMenuItem({cmd:"showSmartPlaylist",options:[c]},"Edit smart playlist"):"")+(0!=c.indexOf("myMPDsmart")?addMenuItem({cmd:"showRenamePlaylist",options:[c]},"Rename playlist")+addMenuItem({cmd:"showDelPlaylist",options:[c]},"Delete playlist"):""):"Browse"==app.current.app&&"Playlists"==app.current.tab&&"Detail"==app.current.view?(e=document.getElementById("BrowsePlaylistsDetailList"),f+=addMenuItem({cmd:"appendQueue",
options:[b,c,d]},"Append to queue")+addMenuItem({cmd:"replaceQueue",options:[b,c,d]},"Replace queue")+("false"==e.getAttribute("data-ro")?addMenuItem({cmd:"removeFromPlaylist",options:[e.getAttribute("data-uri"),a.parentNode.parentNode.getAttribute("data-songpos")]},"Remove"):"")+addMenuItem({cmd:"showAddToPlaylist",options:[c]},"Add to playlist")+(-1==c.indexOf("http")?addMenuItem({cmd:"songDetails",options:[c]},"Songdetails"):"")):"Queue"==app.current.app&&(f+=addMenuItem({cmd:"delQueueSong",options:["single",
a.parentNode.parentNode.getAttribute("data-trackid")]},"Remove")+addMenuItem({cmd:"delQueueSong",options:["range",0,a.parentNode.parentNode.getAttribute("data-songpos")]},"Remove all upwards")+addMenuItem({cmd:"delQueueSong",options:["range",parseInt(a.parentNode.parentNode.getAttribute("data-songpos"))-1,-1]},"Remove all downwards")+(-1==c.indexOf("http")?addMenuItem({cmd:"songDetails",options:[c]},"Songdetails"):""));new Popover(a,{trigger:"click",delay:0,dismissible:!0,template:'<div class="popover" role="tooltip"><div class="arrow"></div><div class="popover-content">'+
f+"</div></div>"});b=a.Popover;a.setAttribute("data-init","true");a.addEventListener("shown.bs.popover",function(a){a.target.setAttribute("data-popover","true");document.getElementsByClassName("popover-content")[0].addEventListener("click",function(a){a.preventDefault();a.stopPropagation();if("A"==a.target.nodeName&&(a=a.target.getAttribute("data-href"))){a=JSON.parse(b64DecodeUnicode(a));if("function"===typeof window[a.cmd])switch(a.cmd){case "sendAPI":sendAPI.apply(null,$jscomp.arrayFromIterable(a.options));
break;default:window[a.cmd].apply(null,$jscomp.arrayFromIterable(a.options))}hideMenu()}},!1);if(a=document.getElementById("advancedMenuLink"))a.addEventListener("click",function(a){a=this.getElementsByTagName("span")[0];a.innerText="keyboard_arrow_right"==a.innerText?"keyboard_arrow_down":"keyboard_arrow_right"},!1),new Collapse(a)},!1);b.show()}}
options:[b,c,d]},"Append to queue")+addMenuItem({cmd:"replaceQueue",options:[b,c,d]},"Replace queue")+("false"==e.getAttribute("data-ro")?addMenuItem({cmd:"removeFromPlaylist",options:[e.getAttribute("data-uri"),a.parentNode.parentNode.getAttribute("data-songpos")]},"Remove"):"")+addMenuItem({cmd:"showAddToPlaylist",options:[c]},"Add to playlist")+(-1==c.indexOf("http")?addMenuItem({cmd:"songDetails",options:[c]},"Songdetails"):"")):"Queue"==app.current.app&&"Current"==app.current.tab?f+=addMenuItem({cmd:"delQueueSong",
options:["single",a.parentNode.parentNode.getAttribute("data-trackid")]},"Remove")+addMenuItem({cmd:"delQueueSong",options:["range",0,a.parentNode.parentNode.getAttribute("data-songpos")]},"Remove all upwards")+addMenuItem({cmd:"delQueueSong",options:["range",parseInt(a.parentNode.parentNode.getAttribute("data-songpos"))-1,-1]},"Remove all downwards")+(-1==c.indexOf("http")?addMenuItem({cmd:"songDetails",options:[c]},"Songdetails"):""):"Queue"==app.current.app&&"LastPlayed"==app.current.tab&&(f+=
addMenuItem({cmd:"appendQueue",options:[b,c,d]},"Append to queue")+addMenuItem({cmd:"replaceQueue",options:[b,c,d]},"Replace queue")+addMenuItem({cmd:"showAddToPlaylist",options:[c]},"Add to playlist")+(-1==c.indexOf("http")?addMenuItem({cmd:"songDetails",options:[c]},"Songdetails"):""));new Popover(a,{trigger:"click",delay:0,dismissible:!0,template:'<div class="popover" role="tooltip"><div class="arrow"></div><div class="popover-content">'+f+"</div></div>"});b=a.Popover;a.setAttribute("data-init",
"true");a.addEventListener("shown.bs.popover",function(a){a.target.setAttribute("data-popover","true");document.getElementsByClassName("popover-content")[0].addEventListener("click",function(a){a.preventDefault();a.stopPropagation();if("A"==a.target.nodeName){var b=a.target.getAttribute("data-href");b&&(b=JSON.parse(b64DecodeUnicode(b)),parseCmd(a,b),hideMenu())}},!1);if(a=document.getElementById("advancedMenuLink"))a.addEventListener("click",function(a){a=this.getElementsByTagName("span")[0];a.innerText=
"keyboard_arrow_right"==a.innerText?"keyboard_arrow_down":"keyboard_arrow_right"},!1),new Collapse(a)},!1);b.show()}}
function sendAPI(a,b){var c=new XMLHttpRequest;c.open("POST","/api",!0);c.setRequestHeader("Content-type","application/json");c.onreadystatechange=function(){if(4==c.readyState)if(""!=c.responseText){var d=JSON.parse(c.responseText);"error"==d.type?(showNotification("Error",d.data,d.data,"danger"),console.log("Error: "+d.data)):"result"==d.type&&"ok"!=d.data?showNotification(d.data,"","","success"):void 0!=b&&"function"==typeof b&&b(d)}else console.log("Empty response for request: "+JSON.stringify(a))};
c.send(JSON.stringify(a))}function openLocalPlayer(){window.open("/player.html#"+settings.mpdstream,"LocalPlayer")}function updateDB(){sendAPI({cmd:"MPD_API_DATABASE_UPDATE"});updateDBstarted(!0)}function rescanDB(){sendAPI({cmd:"MPD_API_DATABASE_RESCAN"});updateDBstarted(!0)}
function updateDBstarted(a){1==a?(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")):showNotification("Database update started","","","success")}
@ -176,12 +190,12 @@ function saveQueue(){var a=document.getElementById("saveQueueName").value,b=a.re
function showNotification(a,b,c,d){1==settings.notificationWeb&&(b=new Notification(a,{icon:"assets/favicon.ico",body:b}),setTimeout(function(a){a.close()},3E3,b));1==settings.notificationPage&&(document.getElementById("alertBox")?b=document.getElementById("alertBox"):(b=document.createElement("div"),b.setAttribute("id","alertBox"),b.addEventListener("click",function(){hideNotification()},!1)),b.classList.remove("alert-success","alert-danger"),b.classList.add("alert","alert-"+d),b.innerHTML="<div><strong>"+
a+"</strong><br/>"+c+"</div>",document.getElementsByTagName("main")[0].append(b),document.getElementById("alertBox").classList.add("alertBoxActive"),alertTimeout&&clearTimeout(alertTimeout),alertTimeout=setTimeout(function(){hideNotification()},3E3))}function hideNotification(){document.getElementById("alertBox")&&(document.getElementById("alertBox").classList.remove("alertBoxActive"),setTimeout(function(){var a=document.getElementById("alertBox");a&&a.remove()},600))}
function notificationsSupported(){return"Notification"in window}
function songChange(a){if("error"!=a.type&&"result"!=a.type){var b=a.data.Title+a.data.Artist+a.data.Album+a.data.uri+a.data.currentSongId;if(lastSong!=b){var c="",d="",e="myMPD: ";domCache.currentCover.style.backgroundImage='url("'+a.data.cover+'")';"undefined"!=typeof a.data.Artist&&0<a.data.Artist.length&&"-"!=a.data.Artist?(c+=a.data.Artist,d+=a.data.Artist,e+=a.data.Artist+" - ",domCache.currentArtist.innerText=a.data.Artist,void 0!=a.data.AlbumArtist?domCache.currentArtist.setAttribute("data-albumartist",
a.data.AlbumArtist):void 0!=a.data.Artist?domCache.currentArtist.setAttribute("data-albumartist",a.data.Artist):domCache.currentArtist.setAttribute("data-albumartist","")):domCache.currentArtist.innerText="";"undefined"!=typeof a.data.Album&&0<a.data.Album.length&&"-"!=a.data.Album?(c+=" - "+a.data.Album,d+="<br/>"+a.data.Album,domCache.currentAlbum.innerText=a.data.Album,domCache.currentAlbum.setAttribute("data-album",a.data.Album)):domCache.currentAlbum.innerText="";"undefined"!=typeof a.data.Title&&
0<a.data.Title.length?(e+=a.data.Title,domCache.currentTrack.innerText=a.data.Title,domCache.currentTrack.setAttribute("data-uri",a.data.uri)):(domCache.currentTrack.innerText="",domCache.currentTrack.setAttribute("data-uri",""));document.title=e;1==settings.featStickers&&setVoteSongBtns(a.data.like,a.data.uri);if(e=document.getElementById("queueTrackId"+a.data.currentSongId))e.getElementsByTagName("td")[1].innerText=a.data.Title;showNotification(a.data.Title,c,d,"success");lastSong=b}}}
function songChange(a){if("error"!=a.type&&"result"!=a.type){var b=a.data.Title+a.data.Artist+a.data.Album+a.data.uri+a.data.currentSongId;if(lastSong!=b){var c="",d="",e="myMPD: ";domCache.currentCover.style.backgroundImage='url("'+a.data.cover+'")';"undefined"!=typeof a.data.Artist&&0<a.data.Artist.length&&"-"!=a.data.Artist&&(c+=a.data.Artist,d+=a.data.Artist,e+=a.data.Artist+" - ");"undefined"!=typeof a.data.Album&&0<a.data.Album.length&&"-"!=a.data.Album&&(c+=" - "+a.data.Album,d+="<br/>"+a.data.Album);
"undefined"!=typeof a.data.Title&&0<a.data.Title.length?(e+=a.data.Title,domCache.currentTitle.innerText=a.data.Title,domCache.currentTitle.setAttribute("data-uri",encodeURI(a.data.uri))):(domCache.currentTitle.innerText="",domCache.currentTitle.setAttribute("data-uri",""));document.title=e;1==settings.featStickers&&setVoteSongBtns(a.data.like,a.data.uri);for(e=0;e<settings.colsPlayback.length;e++){var f=document.getElementById("current"+settings.colsPlayback[e]);f.getElementsByTagName("h4")[0].innerText=
a.data[settings.colsPlayback[e]];f.setAttribute("data-name",encodeURI(a.data[settings.colsPlayback[e]]))}if(e=document.getElementById("queueTrackId"+a.data.currentSongId))e.getElementsByTagName("td")[1].innerText=a.data.Title;"play"==playstate&&showNotification(a.data.Title,c,d,"success");lastSong=b;lastSongObj=a}}}
function doSetFilterLetter(a){var b=document.getElementById(a+"Letters").getElementsByClassName("active")[0];b&&b.classList.remove("active");b=app.current.filter;"0"==b&&(b="#");document.getElementById(a).innerText="Filter"+("-"!=b?": "+b:"");if("-"!=b){a=document.getElementById(a+"Letters").getElementsByTagName("button");for(var c=a.length,d=0;d<c;d++)if(a[d].innerText==b){a[d].classList.add("active");break}}}
function addFilterLetter(a){for(var b='<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>',c=65;90>=c;c++)b+='<button class="mr-1 mb-1 btn-sm btn btn-secondary">'+String.fromCharCode(c)+"</button>";a=document.getElementById(a);a.innerHTML=b;a.addEventListener("click",function(a){switch(a.target.innerText){case "delete":b="-";break;case "#":b="0";break;default:b=a.target.innerText}appGoto(app.current.app,
app.current.tab,app.current.view,"0/"+b+"/"+app.current.search)},!1)}function selectTag(a,b,c){a=document.getElementById(a);var d=a.querySelector(".active");d&&d.classList.remove("active");if(d=a.querySelector("[data-tag="+c+"]"))d.classList.add("active"),document.getElementById(b).innerText=d.innerText}
function addTagList(a,b){var c="";"searchtags"==b&&(1==settings.featTags&&(c+='<button type="button" class="btn btn-secondary btn-sm btn-block" data-tag="any">Any Tag</button>'),c+='<button type="button" class="btn btn-secondary btn-sm btn-block" data-tag="filename">Filename</button>');for(var d=0;d<settings[b].length;d++)c+='<button type="button" class="btn btn-secondary btn-sm btn-block" data-tag="'+settings[b][d]+'">'+settings[b][d]+"</button>";document.getElementById(a).innerHTML=c}
function gotoTagList(){appGoto(app.current.app,app.current.tab,app.current.view,"0/-/")}function chVolume(a){a=parseInt(domCache.volumeBar.value)+a;0>a?a=0:100<a&&(a=100);domCache.volumeBar.value=a;sendAPI({cmd:"MPD_API_PLAYER_VOLUME_SET",data:{volume:a}})}function beautifyDuration(a){var b=Math.floor(a/86400),c=Math.floor(a/3600)-24*b,d=Math.floor(a/60)-60*c-1440*b;a=a-86400*b-3600*c-60*d;return(0<b?b+"\u2009d ":"")+(0<c?c+"\u2009h "+(10>d?"0":""):"")+d+"\u2009m "+(10>a?"0":"")+a+"\u2009s"}
function genId(a){return"id"+a.replace(/[^\w\-]/g,"")}appInit();
function gotoTagList(){appGoto(app.current.app,app.current.tab,app.current.view,"0/-/")}function openModal(a){window[a].show()}function openDropdown(a){window[a].toggle()}function focusSearch(){"Queue"==app.current.app?document.getElementById("searchqueuestr").focus():"Search"==app.current.app?document.getElementById("searchstr").focus():appGoto("Search")}
function chVolume(a){a=parseInt(domCache.volumeBar.value)+a;0>a?a=0:100<a&&(a=100);domCache.volumeBar.value=a;sendAPI({cmd:"MPD_API_PLAYER_VOLUME_SET",data:{volume:a}})}function beautifyDuration(a){var b=Math.floor(a/86400),c=Math.floor(a/3600)-24*b,d=Math.floor(a/60)-60*c-1440*b;a=a-86400*b-3600*c-60*d;return(0<b?b+"\u2009d ":"")+(0<c?c+"\u2009h "+(10>d?"0":""):"")+d+"\u2009m "+(10>a?"0":"")+a+"\u2009s"}function genId(a){return"id"+a.replace(/[^\w\-]/g,"")}appInit();

View File

@ -10,5 +10,5 @@ function(){function a(a){return function(d){c||(c=!0,a.call(b,d))}}var b=this,c=
void 0;try{d=a.then}catch(h){this.reject_(h);return}"function"==typeof d?this.settleSameAsThenable_(d,a):this.fulfill_(a)};c.prototype.reject_=function(a){this.settle_(2,a)};c.prototype.fulfill_=function(a){this.settle_(1,a)};c.prototype.settle_=function(a,b){if(0!=this.state_)throw Error("Cannot settle("+a+", "+b+"): Promise already settled in state"+this.state_);this.state_=a;this.result_=b;this.executeOnSettledCallbacks_()};c.prototype.executeOnSettledCallbacks_=function(){if(null!=this.onSettledCallbacks_){for(var a=
0;a<this.onSettledCallbacks_.length;++a)l.asyncExecute(this.onSettledCallbacks_[a]);this.onSettledCallbacks_=null}};var l=new b;c.prototype.settleSameAsPromise_=function(a){var b=this.createResolveAndReject_();a.callWhenSettled_(b.resolve,b.reject)};c.prototype.settleSameAsThenable_=function(a,b){var c=this.createResolveAndReject_();try{a.call(b,c.resolve,c.reject)}catch(k){c.reject(k)}};c.prototype.then=function(a,b){function d(a,b){return"function"==typeof a?function(b){try{f(a(b))}catch(m){e(m)}}:
b}var f,e,g=new c(function(a,b){f=a;e=b});this.callWhenSettled_(d(a,f),d(b,e));return g};c.prototype.catch=function(a){return this.then(void 0,a)};c.prototype.callWhenSettled_=function(a,b){function c(){switch(d.state_){case 1:a(d.result_);break;case 2:b(d.result_);break;default:throw Error("Unexpected state: "+d.state_);}}var d=this;null==this.onSettledCallbacks_?l.asyncExecute(c):this.onSettledCallbacks_.push(c)};c.resolve=f;c.reject=function(a){return new c(function(b,c){c(a)})};c.race=function(a){return new c(function(b,
c){for(var d=$jscomp.makeIterator(a),e=d.next();!e.done;e=d.next())f(e.value).callWhenSettled_(b,c)})};c.all=function(a){var b=$jscomp.makeIterator(a),d=b.next();return d.done?f([]):new c(function(a,c){function e(b){return function(c){g[b]=c;h--;0==h&&a(g)}}var g=[],h=0;do g.push(void 0),h++,f(d.value).callWhenSettled_(e(g.length-1),c),d=b.next();while(!d.done)})};return c},"es6","es3");var CACHE="myMPD-cache-v4.5.1",urlsToCache="/ /player.html /css/bootstrap.min.css /css/mympd.min.css /js/bootstrap-native-v4.min.js /js/mympd.min.js /js/player.min.js /assets/appicon-167.png /assets/appicon-192.png /assets/appicon-512.png /assets/coverimage-httpstream.png /assets/coverimage-notavailable.png /assets/coverimage-loading.png /assets/favicon.ico /assets/MaterialIcons-Regular.ttf /assets/MaterialIcons-Regular.woff /assets/MaterialIcons-Regular.woff2".split(" ");
c){for(var d=$jscomp.makeIterator(a),e=d.next();!e.done;e=d.next())f(e.value).callWhenSettled_(b,c)})};c.all=function(a){var b=$jscomp.makeIterator(a),d=b.next();return d.done?f([]):new c(function(a,c){function e(b){return function(c){g[b]=c;h--;0==h&&a(g)}}var g=[],h=0;do g.push(void 0),h++,f(d.value).callWhenSettled_(e(g.length-1),c),d=b.next();while(!d.done)})};return c},"es6","es3");var CACHE="myMPD-cache-v4.6.0",urlsToCache="/ /player.html /css/bootstrap.min.css /css/mympd.min.css /js/bootstrap-native-v4.min.js /js/mympd.min.js /js/player.min.js /js/keymap.min.js /assets/appicon-167.png /assets/appicon-192.png /assets/appicon-512.png /assets/coverimage-httpstream.png /assets/coverimage-notavailable.png /assets/coverimage-loading.png /assets/favicon.ico /assets/MaterialIcons-Regular.ttf /assets/MaterialIcons-Regular.woff /assets/MaterialIcons-Regular.woff2".split(" ");
self.addEventListener("install",function(a){a.waitUntil(caches.open(CACHE).then(function(a){return a.addAll(urlsToCache)}))});self.addEventListener("fetch",function(a){if(a.request.url.match("^http://"))return!1;a.respondWith(caches.match(a.request).then(function(b){return b?b:fetch(a.request)}))});self.addEventListener("activate",function(a){a.waitUntil(caches.keys().then(function(a){return Promise.all(a.map(function(a){if(a!=CACHE)return caches.delete(a)}))}))});

View File

@ -2408,6 +2408,7 @@ MG_INTERNAL void mg_call(struct mg_connection *nc,
(nc->flags & _MG_CALLBACK_MODIFIABLE_FLAGS_MASK);
}
}
if (ev != MG_EV_POLL) nc->mgr->num_calls++;
if (ev != MG_EV_POLL) {
DBG(("%p after %s flags=0x%lx rmbl=%d smbl=%d", nc,
ev_handler == nc->handler ? "user" : "proto", nc->flags,
@ -2585,19 +2586,14 @@ void mg_mgr_free(struct mg_mgr *m) {
MG_FREE((char *) m->nameserver);
}
time_t mg_mgr_poll(struct mg_mgr *m, int timeout_ms) {
int i;
time_t now = 0; /* oh GCC, seriously ? */
if (m->num_ifaces == 0) {
LOG(LL_ERROR, ("cannot poll: no interfaces"));
return 0;
}
int mg_mgr_poll(struct mg_mgr *m, int timeout_ms) {
int i, num_calls_before = m->num_calls;
for (i = 0; i < m->num_ifaces; i++) {
now = m->ifaces[i]->vtable->poll(m->ifaces[i], timeout_ms);
m->ifaces[i]->vtable->poll(m->ifaces[i], timeout_ms);
}
return now;
return (m->num_calls - num_calls_before);
}
int mg_vprintf(struct mg_connection *nc, const char *fmt, va_list ap) {
@ -2801,7 +2797,6 @@ MG_INTERNAL void mg_ssl_handshake(struct mg_connection *nc) {
enum mg_ssl_if_result res;
if (nc->flags & MG_F_SSL_HANDSHAKE_DONE) return;
res = mg_ssl_if_handshake(nc);
LOG(LL_DEBUG, ("%p %d res %d", nc, server_side, res));
if (res == MG_SSL_OK) {
nc->flags |= MG_F_SSL_HANDSHAKE_DONE;
@ -2932,10 +2927,12 @@ static int mg_recv_tcp(struct mg_connection *nc, char *buf, size_t len) {
mg_hexdump_connection(nc, nc->mgr->hexdump_file, buf, n, MG_EV_RECV);
}
#endif
mbuf_trim(&nc->recv_mbuf);
mg_call(nc, NULL, nc->user_data, MG_EV_RECV, &n);
} else if (n < 0) {
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
}
mbuf_trim(&nc->recv_mbuf);
return n;
}
@ -3047,7 +3044,7 @@ void mg_if_can_send_cb(struct mg_connection *nc) {
}
} else
#endif
{
if (len > 0) {
if (nc->flags & MG_F_UDP) {
n = nc->iface->vtable->udp_send(nc, buf, len);
} else {
@ -3585,6 +3582,162 @@ struct mg_iface *mg_find_iface(struct mg_mgr *mgr,
}
return NULL;
}
double mg_mgr_min_timer(const struct mg_mgr *mgr) {
double min_timer = 0;
struct mg_connection *nc;
for (nc = mgr->active_connections; nc != NULL; nc = nc->next) {
if (nc->ev_timer_time <= 0) continue;
if (min_timer == 0 || nc->ev_timer_time < min_timer) {
min_timer = nc->ev_timer_time;
}
}
return min_timer;
}
#ifdef MG_MODULE_LINES
#line 1 "mongoose/src/mg_net_if_null.c"
#endif
/*
* Copyright (c) 2018 Cesanta Software Limited
* All rights reserved
*
* This software is dual-licensed: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. For the terms of this
* license, see <http://www.gnu.org/licenses/>.
*
* You are free to use this software under the terms of the GNU General
* Public License, 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.
*
* Alternatively, you can license this software under a commercial
* license, as set out in <https://www.cesanta.com/license>.
*/
static void mg_null_if_connect_tcp(struct mg_connection *c,
const union socket_address *sa) {
c->flags |= MG_F_CLOSE_IMMEDIATELY;
(void) sa;
}
static void mg_null_if_connect_udp(struct mg_connection *c) {
c->flags |= MG_F_CLOSE_IMMEDIATELY;
}
static int mg_null_if_listen_tcp(struct mg_connection *c,
union socket_address *sa) {
(void) c;
(void) sa;
return -1;
}
static int mg_null_if_listen_udp(struct mg_connection *c,
union socket_address *sa) {
(void) c;
(void) sa;
return -1;
}
static int mg_null_if_tcp_send(struct mg_connection *c, const void *buf,
size_t len) {
(void) c;
(void) buf;
(void) len;
return -1;
}
static int mg_null_if_udp_send(struct mg_connection *c, const void *buf,
size_t len) {
(void) c;
(void) buf;
(void) len;
return -1;
}
int mg_null_if_tcp_recv(struct mg_connection *c, void *buf, size_t len) {
(void) c;
(void) buf;
(void) len;
return -1;
}
int mg_null_if_udp_recv(struct mg_connection *c, void *buf, size_t len,
union socket_address *sa, size_t *sa_len) {
(void) c;
(void) buf;
(void) len;
(void) sa;
(void) sa_len;
return -1;
}
static int mg_null_if_create_conn(struct mg_connection *c) {
(void) c;
return 1;
}
static void mg_null_if_destroy_conn(struct mg_connection *c) {
(void) c;
}
static void mg_null_if_sock_set(struct mg_connection *c, sock_t sock) {
(void) c;
(void) sock;
}
static void mg_null_if_init(struct mg_iface *iface) {
(void) iface;
}
static void mg_null_if_free(struct mg_iface *iface) {
(void) iface;
}
static void mg_null_if_add_conn(struct mg_connection *c) {
c->sock = INVALID_SOCKET;
c->flags |= MG_F_CLOSE_IMMEDIATELY;
}
static void mg_null_if_remove_conn(struct mg_connection *c) {
(void) c;
}
static time_t mg_null_if_poll(struct mg_iface *iface, int timeout_ms) {
struct mg_mgr *mgr = iface->mgr;
struct mg_connection *nc, *tmp;
double now = mg_time();
/* We basically just run timers and poll. */
for (nc = mgr->active_connections; nc != NULL; nc = tmp) {
tmp = nc->next;
mg_if_poll(nc, now);
}
(void) timeout_ms;
return (time_t) now;
}
static void mg_null_if_get_conn_addr(struct mg_connection *c, int remote,
union socket_address *sa) {
(void) c;
(void) remote;
(void) sa;
}
#define MG_NULL_IFACE_VTABLE \
{ \
mg_null_if_init, mg_null_if_free, mg_null_if_add_conn, \
mg_null_if_remove_conn, mg_null_if_poll, mg_null_if_listen_tcp, \
mg_null_if_listen_udp, mg_null_if_connect_tcp, mg_null_if_connect_udp, \
mg_null_if_tcp_send, mg_null_if_udp_send, mg_null_if_tcp_recv, \
mg_null_if_udp_recv, mg_null_if_create_conn, mg_null_if_destroy_conn, \
mg_null_if_sock_set, mg_null_if_get_conn_addr, \
}
const struct mg_iface_vtable mg_null_iface_vtable = MG_NULL_IFACE_VTABLE;
#if MG_NET_IF == MG_NET_IF_NULL
const struct mg_iface_vtable mg_default_iface_vtable = MG_NULL_IFACE_VTABLE;
#endif /* MG_NET_IF == MG_NET_IF_NULL */
#ifdef MG_MODULE_LINES
#line 1 "mongoose/src/mg_net_if_socket.c"
#endif
@ -4847,6 +5000,8 @@ static void mg_ssl_mbed_log(void *ctx, int level, const char *file, int line,
}
/* mbedTLS passes strings with \n at the end, strip it. */
LOG(cs_level, ("%p %.*s", ctx, (int) (strlen(str) - 1), str));
(void) ctx;
(void) str;
(void) file;
(void) line;
(void) cs_level;
@ -5036,9 +5191,9 @@ static void mg_ssl_if_mbed_free_certs_and_keys(struct mg_ssl_if_ctx *ctx) {
if (ctx->ca_cert != NULL) {
mbedtls_ssl_conf_ca_chain(ctx->conf, NULL, NULL);
#ifdef MBEDTLS_X509_CA_CHAIN_ON_DISK
if (ctx->ca_cert->ca_chain_file != NULL) {
MG_FREE((void *) ctx->ca_cert->ca_chain_file);
ctx->ca_cert->ca_chain_file = NULL;
if (ctx->conf->ca_chain_file != NULL) {
MG_FREE((void *) ctx->conf->ca_chain_file);
ctx->conf->ca_chain_file = NULL;
}
#endif
mbedtls_x509_crt_free(ctx->ca_cert);
@ -5145,15 +5300,13 @@ static enum mg_ssl_if_result mg_use_ca_cert(struct mg_ssl_if_ctx *ctx,
mbedtls_x509_crt_init(ctx->ca_cert);
#ifdef MBEDTLS_X509_CA_CHAIN_ON_DISK
ca_cert = strdup(ca_cert);
if (mbedtls_x509_crt_set_ca_chain_file(ctx->ca_cert, ca_cert) != 0) {
return MG_SSL_ERROR;
}
mbedtls_ssl_conf_ca_chain_file(ctx->conf, ca_cert, NULL);
#else
if (mbedtls_x509_crt_parse_file(ctx->ca_cert, ca_cert) != 0) {
return MG_SSL_ERROR;
}
#endif
mbedtls_ssl_conf_ca_chain(ctx->conf, ctx->ca_cert, NULL);
#endif
mbedtls_ssl_conf_authmode(ctx->conf, MBEDTLS_SSL_VERIFY_REQUIRED);
return MG_SSL_OK;
}
@ -6155,6 +6308,10 @@ static size_t mg_http_parse_chunk(char *buf, size_t len, char **chunk_data,
n *= 16;
n += (s[i] >= '0' && s[i] <= '9') ? s[i] - '0' : tolower(s[i]) - 'a' + 10;
i++;
if (i > 6) {
/* Chunk size is unreasonable. */
return 0;
}
}
/* Skip new line */
@ -6460,6 +6617,7 @@ void mg_http_handler(struct mg_connection *nc, int ev,
}
} else {
/* We did receive all HTTP body. */
int request_done = 1;
int trigger_ev = nc->listener ? MG_EV_HTTP_REQUEST : MG_EV_HTTP_REPLY;
char addr[32];
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
@ -6471,12 +6629,32 @@ void mg_http_handler(struct mg_connection *nc, int ev,
mg_http_call_endpoint_handler(nc, trigger_ev, hm);
mbuf_remove(io, hm->message.len);
pd->rcvd -= hm->message.len;
#if MG_ENABLE_FILESYSTEM
/* We don't have a generic mechanism of communicating that we are done
* responding to a request (should probably add one). But if we are
* serving
* a file, we are definitely not done. */
if (pd->file.fp != NULL) request_done = 0;
#endif
#if MG_ENABLE_HTTP_CGI
/* If this is a CGI request, we are not done either. */
if (pd->cgi.cgi_nc != NULL) request_done = 0;
#endif
if (request_done) {
/* This request is done but we may receive another on this connection.
*/
mg_http_conn_destructor(pd);
nc->proto_data = NULL;
if (io->len > 0) {
/* We already have data for the next one, restart parsing. */
pd = mg_http_get_proto_data(nc);
pd->rcvd = io->len;
goto again;
}
}
}
}
}
static size_t mg_get_line_len(const char *buf, size_t buf_len) {
size_t len = 0;
@ -8328,7 +8506,7 @@ void mg_file_upload_handler(struct mg_connection *nc, int ev, void *ev_data,
if (lfn.p != mp->file_name) MG_FREE((char *) lfn.p);
LOG(LL_DEBUG,
("%p Receiving file %s -> %s", nc, mp->file_name, fus->lfn));
fus->fp = mg_fopen(fus->lfn, "w");
fus->fp = mg_fopen(fus->lfn, "wb");
if (fus->fp == NULL) {
mg_printf(nc,
"HTTP/1.1 500 Internal Server Error\r\n"
@ -11812,7 +11990,9 @@ static void mg_resolve_async_eh(struct mg_connection *nc, int ev,
void *user_data = nc->user_data;
#endif
if (ev != MG_EV_POLL) DBG(("ev=%d user_data=%p", ev, user_data));
if (ev != MG_EV_POLL) {
DBG(("ev=%d user_data=%p", ev, user_data));
}
req = (struct mg_resolve_async_request *) user_data;
@ -15024,6 +15204,7 @@ static err_t mg_lwip_tcp_recv_cb(void *arg, struct tcp_pcb *tpcb,
}
mg_lwip_recv_common(nc, p);
mgos_unlock();
(void) err;
return ERR_OK;
}
@ -15036,6 +15217,10 @@ static err_t mg_lwip_tcp_sent_cb(void *arg, struct tcp_pcb *tpcb,
nc->send_mbuf.len == 0 && tpcb->unsent == NULL && tpcb->unacked == NULL) {
mg_lwip_post_signal(MG_SIG_CLOSE_CONN, nc);
}
if (nc->send_mbuf.len > 0 || (nc->flags & MG_F_WANT_WRITE)) {
mg_lwip_mgr_schedule_poll(nc->mgr);
}
(void) num_sent;
return ERR_OK;
}
@ -15397,6 +15582,10 @@ static int mg_lwip_if_can_send(struct mg_connection *nc,
can_send = (cs->pcb.udp != NULL);
} else {
can_send = (cs->pcb.tcp != NULL && cs->pcb.tcp->snd_buf > 0);
/* See comment above. */
#if CS_PLATFORM == CS_P_ESP8266
if (cs->pcb.tcp->unacked != NULL) can_send = 0;
#endif
}
}
return can_send;
@ -15716,38 +15905,6 @@ time_t mg_lwip_if_poll(struct mg_iface *iface, int timeout_ms) {
return now;
}
uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr) {
struct mg_connection *nc;
double now;
double min_timer = 0;
int num_timers = 0;
mg_ev_mgr_lwip_process_signals(mgr);
for (nc = mg_next(mgr, NULL); nc != NULL; nc = mg_next(mgr, nc)) {
struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock;
if (nc->ev_timer_time > 0) {
if (num_timers == 0 || nc->ev_timer_time < min_timer) {
min_timer = nc->ev_timer_time;
}
num_timers++;
}
/* We want and can send data, request a poll immediately. */
if (nc->sock != INVALID_SOCKET && mg_lwip_if_can_send(nc, cs)) {
return 0;
}
}
uint32_t timeout_ms = ~0;
now = mg_time();
if (num_timers > 0) {
/* If we have a timer that is past due, do a poll ASAP. */
if (min_timer < now) return 0;
double timer_timeout_ms = (min_timer - now) * 1000 + 1 /* rounding */;
if (timer_timeout_ms < timeout_ms) {
timeout_ms = timer_timeout_ms;
}
}
return timeout_ms;
}
#endif /* MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL */
#ifdef MG_MODULE_LINES
#line 1 "common/platforms/wince/wince_libc.c"

View File

@ -23,7 +23,7 @@
#ifndef CS_MONGOOSE_SRC_COMMON_H_
#define CS_MONGOOSE_SRC_COMMON_H_
#define MG_VERSION "6.12"
#define MG_VERSION "6.13"
/* Local tweaks, applied before any of Mongoose's own headers. */
#ifdef MG_LOCALS
@ -105,6 +105,7 @@
#define MG_NET_IF_SIMPLELINK 2
#define MG_NET_IF_LWIP_LOW_LEVEL 3
#define MG_NET_IF_PIC32 4
#define MG_NET_IF_NULL 5
#define MG_SSL_IF_OPENSSL 1
#define MG_SSL_IF_MBEDTLS 2
@ -1944,7 +1945,7 @@ char *inet_ntoa(struct in_addr in);
#include <stm32_sdk_hal.h>
#define to64(x) strtoll(x, NULL, 10)
#define INT64_FMT PRId64
#define INT64_FMT "lld"
#define SIZE_T_FMT "u"
typedef struct stat cs_stat_t;
#define DIRSEP '/'
@ -2030,7 +2031,6 @@ typedef int sock_t;
#if MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL
struct mg_mgr;
struct mg_connection;
uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr);
void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle,
int interval, int count);
#endif
@ -2312,8 +2312,6 @@ struct mg_str mg_strstrip(struct mg_str s);
*/
/*
* === Memory Buffers
*
* Mbufs are mutable/growing memory buffers, like C++ strings.
* Mbuf can append data to the end of a buffer or insert data into arbitrary
* position in the middle of a buffer. The buffer grows automatically when
@ -3718,6 +3716,12 @@ void mg_if_recv_udp_cb(struct mg_connection *nc, void *buf, int len,
/* Deliver a POLL event to the connection. */
int mg_if_poll(struct mg_connection *nc, double now);
/*
* Return minimal timer value amoung connections in the manager.
* Returns 0 if there aren't any timers.
*/
double mg_mgr_min_timer(const struct mg_mgr *mgr);
#ifdef __cplusplus
}
#endif /* __cplusplus */
@ -3875,6 +3879,7 @@ struct mg_mgr {
#endif
void *user_data; /* User data */
int num_ifaces;
int num_calls;
struct mg_iface **ifaces; /* network interfaces */
const char *nameserver; /* DNS server to use */
};
@ -3987,17 +3992,17 @@ void mg_mgr_init_opt(struct mg_mgr *mgr, void *user_data,
*
* Closes and deallocates all active connections.
*/
void mg_mgr_free(struct mg_mgr *);
void mg_mgr_free(struct mg_mgr *mgr);
/*
* This function performs the actual IO and must be called in a loop
* (an event loop). It returns the current timestamp.
* (an event loop). It returns number of user events generated (except POLLs).
* `milli` is the maximum number of milliseconds to sleep.
* `mg_mgr_poll()` checks all connections for IO readiness. If at least one
* of the connections is IO-ready, `mg_mgr_poll()` triggers the respective
* event handlers and returns.
*/
time_t mg_mgr_poll(struct mg_mgr *, int milli);
int mg_mgr_poll(struct mg_mgr *mgr, int milli);
#if MG_ENABLE_BROADCAST
/*

View File

@ -55,7 +55,7 @@ small {
min-height: 300px;
}
.card-footer-playback {
.cardFooterPlayback {
padding: 0px;
}
@ -312,3 +312,12 @@ caption {
#menu-dbupdate {
padding-left:1rem;
}
div.key {
border: 1px solid #bbb;
background-color: #eee;
border-radius: 2px;
width: 20px;
heigth: 20px;
text-align: center;
}

View File

@ -18,11 +18,11 @@
<body>
<header>
<nav class="navbar navbar-expand navbar-dark fixed-top bg-dark">
<div class="dropdown col-auto mr-auto pl-0" id="mainMenu">
<a class="dropdown-toggle navbar-brand" data-toggle="dropdown" href="#">
<div class="dropdown col-auto mr-auto pl-0">
<a class="dropdown-toggle navbar-brand" href="#" id="mainMenu">
<span class="material-icons header-logo">play_circle_outline</span>myMPD
</a>
<div class="dropdown-menu bg-dark">
<div class="dropdown-menu bg-dark" id="mainMenuDropdown">
<a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "showAddToPlaylist", "options": ["stream"]}'>Add Stream</a>
<a id="navDBupdate" class="dropdown-item text-light bg-dark" data-toggle="collapse" href="#menu-dbupdate"><span class="material-icons material-icons-left">keyboard_arrow_right</span>Update</a>
<div class="collapse" id="menu-dbupdate">
@ -52,8 +52,8 @@
skip_next
</button>
</div>
<div class="btn-group">
<button id="volumeIcon" class="btn btn-secondary dropdown-toggle pl-2 pr-2 material-icons" type="button" data-toggle="dropdown">
<div class="btn-group dropdown">
<button id="volumeMenu" class="btn btn-secondary dropdown-toggle pl-2 pr-2 material-icons" type="button" data-toggle="dropdown">
volume_up
</button>
<div class="dropdown-menu dropdown-menu-right bg-dark">
@ -81,6 +81,12 @@
<div class="card" id="cardPlayback">
<div class="card-header">Playback
<div class="btn-group mr-0 featTags pull-right">
<button id="PlaybackColsBtn" class="btn btn-sm btn-light dropdown-toggle material-icons material-icons-small" type="button" data-toggle="dropdown">settings</button>
<div class="dropdown-menu dropdown-menu-right bg-dark px-2" id="PlaybackColsDropdown"><form></form>
<button data-href='{"cmd": "saveColsPlayback", "options": ["Playback"]}' class="btn btn-success btn-block btn-sm mt-2">Apply</button>
</div>
</div>
<div class="btn-group btn-group-sm featStickers pull-right">
<button title="Dislike song" id="btnVoteDown" data-href='{"cmd": "voteSong", "options": [0]}' class="btn btn-sm btn-light material-icons">thumb_down</button>
<button title="Like song" id="btnVoteUp" data-href='{"cmd": "voteSong", "options": [2]}' class="btn btn-sm btn-light material-icons">thumb_up</button>
@ -89,16 +95,11 @@
<div class="card-body">
<div class="album-cover featCoverimage" id="currentCover"></div>
<div class="album-desc">
<h2 id="currentTrack" data-href='{"cmd": "songClick", "options": []}'></h2>
<div class="featTags">
<small>Artist</small>
<h4 id="currentArtist" data-href='{"cmd": "artistClick", "options": []}'></h4>
<small>Album</small>
<h4 id="currentAlbum" data-href='{"cmd": "albumClick", "options": []}'></h4>
<h2 id="currentTitle" data-href='{"cmd": "clickTitle", "options": []}'></h2>
<div class="featTags" id="cardPlaybackTags"></div>
</div>
</div>
</div>
<div class="card-footer card-footer-playback">
<div class="card-footer cardFooterPlayback">
<div class="d-flex align-items-center">
<button data-href='{"cmd": "clickPlay", "options": []}' class="mr-1 ml-1 btn btn-light material-icons btnPlay progressBarPlay">pause</button>
<input type="range" min="0" max="100" step="1" class="mr-1 ml-1 form-control-range flex-grow-1" id="progressBar">
@ -108,11 +109,19 @@
</div>
<div class="card hide" id="cardQueue">
<div class="card-header">
Queue<span id="panel-heading-queue" class="text pull-right"></span>
<div class="card-header" id="cardHeaderQueue">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<a data-href='{"cmd": "appGoto", "options": ["Queue", "Current"]}' class="nav-link text-dark" href="#" id="cardQueueNavCurrent">Queue</a>
</li>
<li class="nav-item">
<a data-href='{"cmd": "appGoto", "options": ["Queue", "LastPlayed"]}' class="nav-link text-dark" href="#" id="cardQueueNavLastPlayed">Last Played</a>
</li>
</ul>
</div>
<div class="card-body">
<div class="btn-toolbar card-toolbar" id="queue-buttons">
<div class="card-body hide" id="cardQueueCurrent">
<div class="btn-toolbar card-toolbar" id="QueueCurrentButtonsTop">
<div class="btn-group mr-2 featPlaylists">
<button type="button" class="btn btn-secondary material-icons" data-toggle="modal" data-target="#modalSaveQueue" title="Save queue">
save
@ -146,25 +155,25 @@
</div>
</div>
</form>
<div id="QueuePaginationTop" class="btn-group mr-2 hide">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueuePaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div id="QueueCurrentPaginationTop" class="btn-group mr-2 hide">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueueCurrentPaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div class="input-group-append">
<button id="QueuePaginationTopPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueuePaginationTopPages">
<button id="QueueCurrentPaginationTopPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueueCurrentPaginationTopPages">
</div>
</div>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueuePaginationTopNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueueCurrentPaginationTopNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
</div>
<div class="btn-group mr-2 featTags">
<button id="QueueColsBtn" class="btn btn-secondary dropdown-toggle material-icons" type="button" data-toggle="dropdown">settings</button>
<div class="dropdown-menu bg-dark px-2" id="QueueColsDropdown"><form></form>
<button data-href='{"cmd": "saveCols", "options": ["Queue"]}' class="btn btn-success btn-block btn-sm mt-2">Apply</button>
<button id="QueueCurrentColsBtn" class="btn btn-secondary dropdown-toggle material-icons" type="button" data-toggle="dropdown">settings</button>
<div class="dropdown-menu bg-dark px-2" id="QueueCurrentColsDropdown"><form></form>
<button data-href='{"cmd": "saveCols", "options": ["QueueCurrent"]}' class="btn btn-success btn-block btn-sm mt-2">Apply</button>
</div>
</div>
</div>
<div class="table-responsive-md">
<table id="QueueList" class="table table-hover table-sm" data-version="">
<table id="QueueCurrentList" class="table table-hover table-sm" data-version="">
<thead>
<tr>
<th>#</th>
@ -179,27 +188,83 @@
</tbody>
</table>
</div>
<div class="btn-toolbar hide" id="QueueButtonsBottom">
<div class="btn-toolbar hide" id="QueueCurrentButtonsBottom">
<div class="btn-group mr-2">
<button type="button" class="btn btn-secondary material-icons" data-href='{"cmd": "scrollTo", "options: [0]}' title="To top">
keyboard_arrow_up
</button>
</div>
<div id="QueuePaginationBottom" class="btn-group mr-2 dropup">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueuePaginationBottomPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div id="QueueCurrentPaginationBottom" class="btn-group mr-2 dropup">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueueCurrentPaginationBottomPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div class="input-group-append">
<button id="QueuePaginationBottomPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueuePaginationBottomPages">
<button id="QueueCurrentPaginationBottomPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueueCurrentPaginationBottomPages">
</div>
</div>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueuePaginationBottomNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
</div>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueueCurrentPaginationBottomNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
</div>
</div>
</div>
<div class="card-body hide" id="cardQueueLastPlayed">
<div class="btn-toolbar card-toolbar">
<div id="QueueLastPlayedPaginationTop" class="btn-group mr-2 hide">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueueLastPlayedPaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div class="input-group-append">
<button id="QueueLastPlayedPaginationTopPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueueLastPlayedPaginationTopPages">
</div>
</div>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueueLastPlayedPaginationTopNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
</div>
<div class="btn-group mr-2 featTags">
<button id="QueueLastPlayedColsBtn" class="btn btn-secondary dropdown-toggle material-icons" type="button" data-toggle="dropdown">settings</button>
<div class="dropdown-menu bg-dark px-2" id="QueueLastPlayedColsDropdown"><form></form>
<button data-href='{"cmd": "saveCols", "options": ["QueueLastPlayed"]}' class="btn btn-success btn-block btn-sm mt-2">Apply</button>
</div>
</div>
</div>
<div class="table-responsive-md">
<table id="QueueLastPlayedList" class="table table-hover table-sm">
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Artist</th>
<th>Album</th>
<th>Duration</th>
<th></th>
</tr>
</thead>
<tbody class="clickable">
</tbody>
</table>
</div>
<div class="btn-toolbar hide" id="QueueLastPlayedButtonsBottom">
<div class="btn-group mr-2">
<button type="button" class="btn btn-secondary material-icons" data-href='{"cmd": "scrollTo", "options: [0]}' title="To top">
keyboard_arrow_up
</button>
</div>
<div id="QueueLastPlayedPaginationBottom" class="btn-group mr-2 dropup">
<button data-href='{"cmd": "gotoPage", "options": ["prev"]}' id="QueueLastPlayedPaginationBottomPrev" title="Previous Page" type="button" class="btn btn-secondary">&laquo;</button>
<div class="input-group-append">
<button id="QueueLastPlayedPaginationBottomPage" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">1 / 1</button>
<div class="dropdown-menu bg-dark px-2 pages" id="QueueLastPlayedPaginationBottomPages">
</div>
</div>
<button data-href='{"cmd": "gotoPage", "options": ["next"]}' id="QueueLastPlayedPaginationBottomNext" title="Next Page" type="button" class="btn btn-secondary input-group-append">&raquo;</button>
</div>
</div>
</div>
<div class="card-footer" id="cardFooterQueue">
</div>
</div>
<div class="card hide" id="cardBrowse">
<div class="card-header" id="panel-heading-browse">
<div class="card-header" id="cardHeaderBrowse">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item featTags">
<a data-href='{"cmd": "appGoto", "options": ["Browse", "Database"]}' class="nav-link text-dark" href="#" id="cardBrowseNavDatabase">Database</a>
@ -441,6 +506,8 @@
</div>
</div>
</div>
<div class="card-footer" id="cardFooterBrowse">
</div>
</div>
<div class="card hide" id="cardSearch">
@ -523,6 +590,8 @@
</div>
</div>
</div>
<div class="card-footer" id="cardFooterSearch">
</div>
</div>
</main>
@ -530,7 +599,7 @@
<nav class="navbar navbar-expand navbar-dark fixed-bottom bg-dark">
<div class="d-flex flex-fill navbar-nav" id="navbar-bottom">
<div id="navPlayback" class="nav-item flex-fill text-center"><a data-href='{"cmd": "appGoto", "options": ["Playback"]}' class="nav-link" href="#">Playback</a></div>
<div id="navQueue" class="nav-item flex-fill text-center"><a data-href='{"cmd": "appGoto", "options": ["Queue"]}' class="nav-link" href="#">Queue</a></div>
<div id="navQueue" class="nav-item flex-fill text-center"><a data-href='{"cmd": "appGoto", "options": ["Queue"]}' class="nav-link" href="#">Queue <span id="badgeQueueItems" class="badge badge-secondary"></span></a></div>
<div class="nav-item flex-fill text-center" id="navBrowse"><a data-href='{"cmd": "appGoto", "options": ["Browse"]}' class="nav-link" href="#">Browse</a></div>
<div class="nav-item flex-fill text-center" id="navSearch"><a data-href='{"cmd": "appGoto", "options": ["Search"]}' class="nav-link" href="#">Search</a></div>
</div>
@ -941,6 +1010,32 @@
</div>
</div>
<div class="modal fade" id="modalHelp" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><span class="material-icons title-icon">keyboard</span> Keyboard Shortcuts</h5>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="table-responsive-md">
<table class="table table-sm">
<thead>
<tr><th>Key</th><th>Action</th></tr>
</thead>
<tbody id="tbodyShortcuts">
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script src="/js/keymap.min.js"></script>
<script src="/js/bootstrap-native-v4.min.js"></script>
<script src="/js/mympd.min.js"></script>
</body>

30
htdocs/js/keymap.js Normal file
View File

@ -0,0 +1,30 @@
var keymap = {
"ArrowLeft": {"cmd": "clickPrev", "options": [], "desc": "Previous Song", "key": "keyboard_arrow_left"},
"ArrowRight": {"cmd": "clickNext", "options": [], "desc": "Next Song", "key": "keyboard_arrow_right"},
" ": {"cmd": "clickPlay", "options": [], "desc": "Toggle Play / Pause", "key": "space_bar"},
"s": {"cmd": "clickStop", "options": [], "desc": "Stop Playing"},
"-": {"cmd": "chVolume", "options": [-5], "desc": "Volume Down"},
"+": {"cmd": "chVolume", "options": [5], "desc": "Volume Up"},
"c": {"cmd": "MPD_API_QUEUE_CLEAR", "options": [], "desc": "Clear Queue"},
"u": {"cmd": "updateDB", "options": [], "desc": "Update Database"},
"r": {"cmd": "rescanDB", "options": [], "desc": "Rescan Database"},
"l": {"cmd": "openLocalPlayer", "options": [], "desc": "Open Local Player", "req": "featLocalplayer"},
"p": {"cmd": "updateSmartPlaylists", "options": [], "desc": "Update Smart Playlists", "req": "featSmartpls"},
"a": {"cmd": "showAddToPlaylist", "options": ["stream"], "desc": "Add Stream"},
"t": {"cmd": "openModal", "options": ["modalSettings"], "desc": "Open Settings"},
"y": {"cmd": "openModal", "options": ["modalAbout"], "desc": "Open About"},
"i": {"cmd": "clickTitle", "options": [], "desc": "Open Song Details"},
"1": {"cmd": "appGoto", "options": ["Playback"], "desc": "Goto Playback"},
"2": {"cmd": "appGoto", "options": ["Queue","Current"], "desc": "Goto Queue"},
"3": {"cmd": "appGoto", "options": ["Queue","LastPlayed"], "desc": "Goto Last Played"},
"4": {"cmd": "appGoto", "options": ["Browse","Database"], "desc": "Goto Browse Database", "req": "featTags"},
"5": {"cmd": "appGoto", "options": ["Browse","Playlists"], "desc": "Goto Browse Playlists", "req": "featPlaylists"},
"6": {"cmd": "appGoto", "options": ["Browse","Filesystem"], "desc": "Goto Browse Filesystem"},
"7": {"cmd": "appGoto", "options": ["Search"], "desc": "Goto Search"},
"m": {"cmd": "openDropdown", "options": ["dropdownMainMenu"], "desc": "Open Main Menu"},
"v": {"cmd": "openDropdown", "options": ["dropdownVolumeMenu"], "desc": "Open Volume Menu"},
"S": {"cmd": "MPD_API_QUEUE_SHUFFLE", "options": [], "desc": "Shuffle Queue"},
"C": {"cmd": "MPD_API_QUEUE_CROP", "options": [], "desc": "Crop Queue"},
"?": {"cmd": "openModal", "options": ["modalHelp"], "desc": "Open Help"},
"/": {"cmd": "focusSearch", "options": [], "desc": "Focus Search"}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
var CACHE = 'myMPD-cache-v4.5.1';
var CACHE = 'myMPD-cache-v4.6.0';
var urlsToCache = [
'/',
'/player.html',
@ -7,6 +7,7 @@ var urlsToCache = [
'/js/bootstrap-native-v4.min.js',
'/js/mympd.min.js',
'/js/player.min.js',
'/js/keymap.min.js',
'/assets/appicon-167.png',
'/assets/appicon-192.png',
'/assets/appicon-512.png',

View File

@ -11,6 +11,10 @@ mympd (${VERSION}-1) stable; urgency=medium
-- Juergen Mang <mail@jcgames.de> $(date +"%a, %d %b %Y %H:%m:%S %z")
EOL
if [ "$1" != "u" ]
then
./mkclean.sh
tar -czvf ../mympd_${VERSION}.orig.tar.gz *
dpkg-buildpackage -rfakeroot
fi

View File

@ -3,6 +3,7 @@
[ -e $PWD/htdocs/js/mympd.min.js ] || ln -s $PWD/htdocs/js/mympd.js $PWD/htdocs/js/mympd.min.js
[ -e $PWD/htdocs/js/player.min.js ] || ln -s $PWD/htdocs/js/player.js $PWD/htdocs/js/player.min.js
[ -e $PWD/htdocs/js/bootstrap-native-v4.min.js ] || ln -s $PWD/dist/htdocs/js/bootstrap-native-v4.js $PWD/htdocs/js/bootstrap-native-v4.min.js
[ -e $PWD/htdocs/js/keymap.min.js ] || ln -s $PWD/htdocs/js/keymap.js $PWD/htdocs/js/keymap.min.js
[ -e $PWD/htdocs/css/mympd.min.css ] || ln -s $PWD/htdocs/css/mympd.css $PWD/htdocs/css/mympd.min.css
[ -e $PWD/htdocs/css/bootstrap.min.css ] || ln -s $PWD/dist/htdocs/css/bootstrap.min.css $PWD/htdocs/css/bootstrap.min.css

View File

@ -11,6 +11,8 @@ then
java -jar dist/buildtools/closure-compiler.jar htdocs/js/mympd.js > dist/htdocs/js/mympd.min.js
[ htdocs/sw.js -nt dist/htdocs/sw.min.js ] && \
java -jar dist/buildtools/closure-compiler.jar htdocs/sw.js > dist/htdocs/sw.min.js
[ htdocs/js/keymap.js -nt dist/htdocs/js/keymap.min.js ] && \
java -jar dist/buildtools/closure-compiler.jar htdocs/js/keymap.js > dist/htdocs/js/keymap.min.js
else
echo "dist/buildtools/closure-compiler.jar not found, using non-minified files"
[ htdocs/js/player.js -nt dist/htdocs/js/player.min.js ] && \
@ -19,6 +21,8 @@ else
cp htdocs/js/mympd.js dist/htdocs/js/mympd.min.js
[ htdocs/sw.js -nt dist/htdocs/sw.min.js ] && \
cp htdocs/sw.js dist/htdocs/sw.min.js
[ htdocs/js/keymap.js -nt dist/htdocs/js/keymap.min.js ] && \
cp htdocs/js/keymap.js dist/htdocs/js/keymap.min.js
fi
if [ -f dist/buildtools/closure-stylesheets.jar ] && [ "$java" != "" ]

View File

@ -140,6 +140,45 @@ int list_push(struct list *l, const char *data, int value) {
return 0;
}
int list_insert(struct list *l, const char *data, int value) {
struct node *n = malloc(sizeof(struct node));
n->value = value;
n->data = strdup(data);
n->next = l->list;
l->list = n;
l->length++;
return 0;
}
struct node *list_node_extract(struct list *l, unsigned idx) {
if (l->list == NULL) { return NULL; }
struct node *current = l->list, **previous = &l->list;
for (; idx > 0; idx--) {
if (current->next == NULL)
return NULL;
previous = &current->next;
current = current->next;
}
/* set the previous node's 'next' value to the current
* nodes next value */
*previous = current->next;
/* null out this node's next value since it's not part of
* a list anymore */
current->next = NULL;
l->length--;
return current;
}
int list_shift(struct list *l, unsigned idx) {
struct node * extracted = list_node_extract(l, idx);
if (extracted == NULL)
return -1;
free(extracted->data);
free(extracted);
return 0;
}
int list_free(struct list *l) {
struct node *current = l->list, *tmp = NULL;
while (current != NULL) {

View File

@ -1,6 +1,6 @@
struct node {
char *data;
int value;
long value;
struct node *next;
};
@ -13,6 +13,9 @@ struct list {
int list_init(struct list *l);
int list_push(struct list *l, const char *data, int value);
int list_insert(struct list *l, const char *data, int value);
int list_shift(struct list *l, unsigned idx);
struct node *list_node_extract(struct list *l, unsigned idx);
int list_replace(struct list *l, int pos, const char *data, int value);
int list_free(struct list *l);
int list_get_value(const struct list *l, const char *data);

View File

@ -118,9 +118,9 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) {
int len = strlen(cols);
if (len > 1)
cols[len - 2] = '\0';
if (strcmp(p_charbuf1,"colsQueue")==0) {
free(mympd_state.colsQueue);
mympd_state.colsQueue = strdup(cols);
if (strcmp(p_charbuf1,"colsQueueCurrent")==0) {
free(mympd_state.colsQueueCurrent);
mympd_state.colsQueueCurrent = strdup(cols);
}
else if (strcmp(p_charbuf1,"colsSearch")==0) {
free(mympd_state.colsSearch);
@ -138,6 +138,14 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) {
free(mympd_state.colsBrowseFilesystem);
mympd_state.colsBrowseFilesystem = strdup(cols);
}
else if (strcmp(p_charbuf1,"colsPlayback")==0) {
free(mympd_state.colsPlayback);
mympd_state.colsPlayback = strdup(cols);
}
else if (strcmp(p_charbuf1,"colsQueueLastPlayed")==0) {
free(mympd_state.colsQueueLastPlayed);
mympd_state.colsQueueLastPlayed = strdup(cols);
}
mympd_state_set(p_charbuf1, cols);
free(p_charbuf1);
}
@ -392,6 +400,12 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) {
n = mympd_put_queue(mpd.buf, uint_buf1, &mpd.queue_version, &mpd.queue_length);
}
break;
case MPD_API_QUEUE_LAST_PLAYED:
je = json_scanf(msg.p, msg.len, "{data: {offset: %u}}", &uint_buf1);
if (je == 1) {
n = mympd_put_last_played_songs(mpd.buf, uint_buf1);
}
break;
case MPD_API_PLAYER_CURRENT_SONG:
n = mympd_put_current_song(mpd.buf);
break;
@ -684,11 +698,15 @@ void mympd_parse_idle(struct mg_mgr *s, int idle_bitmask) {
break;
case MPD_IDLE_PLAYER:
len = mympd_put_state(mpd.buf, &mpd.song_id, &mpd.next_song_id, &mpd.last_song_id, &mpd.queue_version, &mpd.queue_length);
if (config.stickers && mpd.song_id != mpd.last_song_id && mpd.last_update_sticker_song_id != mpd.song_id) {
if (mpd.song_id != mpd.last_song_id) {
if (mpd.last_last_played_id != mpd.song_id)
mympd_last_played_list(mpd.song_id);
if (config.stickers && mpd.last_update_sticker_song_id != mpd.song_id) {
mympd_count_song_id(mpd.song_id, "playCount", 1);
mympd_last_played_song_id(mpd.song_id);
mpd.last_update_sticker_song_id = mpd.song_id;
}
}
break;
case MPD_IDLE_MIXER:
len = mympd_put_volume(mpd.buf);
@ -786,7 +804,7 @@ void mympd_mpd_features() {
printf("\nmyMPD enabled searchtags: ");
token = strtok(searchtaglist, s);
while (token != NULL) {
if (list_get_value(&mpd_tags, token) == 1) {
if (list_get_value(&mympd_tags, token) == 1) {
list_push(&mympd_searchtags, token, 1);
printf("%s ", token);
}
@ -795,7 +813,7 @@ void mympd_mpd_features() {
printf("\nmyMPD enabled browsetags: ");
token = strtok(browsetaglist, s);
while (token != NULL) {
if (list_get_value(&mpd_tags, token) == 1) {
if (list_get_value(&mympd_tags, token) == 1) {
list_push(&mympd_browsetags, token, 1);
printf("%s ", token);
}
@ -994,8 +1012,41 @@ void mympd_like_song_uri(const char *uri, int value) {
LOG_ERROR_AND_RECOVER("mpd_send_sticker_set");
}
void mympd_last_played_list(int song_id) {
struct mpd_song *song;
char tmpfile[400];
char cfgfile[400];
snprintf(cfgfile, 400, "%s/state/last_played", config.varlibdir);
snprintf(tmpfile, 400, "%s/tmp/last_played", config.varlibdir);
if (song_id > -1) {
song = mpd_run_get_queue_song_id(mpd.conn, song_id);
if (song) {
list_insert(&last_played, mpd_song_get_uri(song), time(NULL));
mpd.last_last_played_id = song_id;
mpd_song_free(song);
if (last_played.length > config.last_played_count) {
list_shift(&last_played, last_played.length -1);
}
FILE *fp = fopen(tmpfile, "w");
if (fp == NULL) {
printf("Error opening %s\n", tmpfile);
return;
}
struct node *current = last_played.list;
while (current != NULL) {
fprintf(fp, "%ld::%s\n", current->value, current->data);
current = current->next;
}
fclose(fp);
rename(tmpfile, cfgfile);
}
}
}
void mympd_last_played_song_id(int song_id) {
struct mpd_song *song;
if (song_id > -1) {
song = mpd_run_get_queue_song_id(mpd.conn, song_id);
if (song) {
@ -1437,12 +1488,16 @@ int mympd_put_settings(char *buffer) {
}
len += json_printf(&out, "]");
}
len += json_printf(&out, ", colsQueue: %s", mympd_state.colsQueue);
len += json_printf(&out, ", colsSearch: %s", mympd_state.colsSearch);
len += json_printf(&out, ", colsBrowseDatabase: %s", mympd_state.colsBrowseDatabase);
len += json_printf(&out, ", colsBrowsePlaylistsDetail: %s", mympd_state.colsBrowsePlaylistsDetail);
len += json_printf(&out, ", colsBrowseFilesystem: %s", mympd_state.colsBrowseFilesystem);
len += json_printf(&out, "}}");
len += json_printf(&out, ", colsQueueCurrent: %s, colsSearch: %s, colsBrowseDatabase: %s, colsBrowsePlaylistsDetail: %s, "
"colsBrowseFilesystem: %s, colsPlayback: %s, colsQueueLastPlayed: %s}}",
mympd_state.colsQueueCurrent,
mympd_state.colsSearch,
mympd_state.colsBrowseDatabase,
mympd_state.colsBrowsePlaylistsDetail,
mympd_state.colsBrowseFilesystem,
mympd_state.colsPlayback,
mympd_state.colsQueueLastPlayed
);
CHECK_RETURN_LEN();
return len;
@ -1611,6 +1666,51 @@ int mympd_put_songdetails(char *buffer, char *uri) {
return len;
}
int mympd_put_last_played_songs(char *buffer, unsigned int offset) {
const struct mpd_song *song;
struct mpd_entity *entity;
int len;
unsigned int entity_count = 0;
unsigned int entities_returned = 0;
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
len = json_printf(&out, "{type: last_played_songs, data: [");
struct node *current = last_played.list;
while (current != NULL) {
entity_count++;
if (entity_count > offset && entity_count <= offset + config.max_elements_per_page) {
if (entities_returned++)
len += json_printf(&out, ",");
len += json_printf(&out, "{Pos: %d, LastPlayed: %ld, ", entity_count, current->value);
if (!mpd_send_list_all_meta(mpd.conn, current->data))
RETURN_ERROR_AND_RECOVER("mpd_send_list_all_meta");
if ((entity = mpd_recv_entity(mpd.conn)) != NULL) {
song = mpd_entity_get_song(entity);
if (mpd.feat_tags == true)
PUT_SONG_TAGS();
else
PUT_MIN_SONG_TAGS();
mpd_entity_free(entity);
mpd_response_finish(mpd.conn);
}
len += json_printf(&out, "}");
}
current = current->next;
}
len += json_printf(&out, "], totalEntities: %d, offset: %d, returnedEntities: %d}",
entity_count,
offset,
entities_returned
);
CHECK_RETURN_LEN();
return len;
}
int mympd_put_queue(char *buffer, unsigned int offset, unsigned *queue_version, unsigned *queue_length) {
struct mpd_entity *entity;
unsigned long totalTime = 0;
@ -2119,7 +2219,7 @@ int mympd_search_queue(char *buffer, char *mpdtagtype, unsigned int offset, char
if (entity_count > offset && entity_count <= offset + config.max_elements_per_page) {
if (entities_returned++)
len += json_printf(&out, ", ");
len += json_printf(&out, "{type: song, id: %d, pos: %d, ",
len += json_printf(&out, "{type: song, id: %d, Pos: %d, ",
mpd_song_get_id(song),
mpd_song_get_pos(song)
);

View File

@ -86,6 +86,7 @@
X(MPD_API_QUEUE_ADD_PLAYLIST) \
X(MPD_API_QUEUE_REPLACE_PLAYLIST) \
X(MPD_API_QUEUE_SHUFFLE) \
X(MPD_API_QUEUE_LAST_PLAYED) \
X(MPD_API_PLAYLIST_CLEAR) \
X(MPD_API_PLAYLIST_RENAME) \
X(MPD_API_PLAYLIST_MOVE_TRACK) \
@ -157,6 +158,7 @@ struct t_mpd {
unsigned queue_version;
unsigned queue_length;
int last_update_sticker_song_id;
int last_last_played_id;
// Features
const unsigned* protocol;
@ -171,7 +173,7 @@ struct list mpd_tags;
struct list mympd_tags;
struct list mympd_searchtags;
struct list mympd_browsetags;
struct list last_played;
struct list syscmds;
typedef struct {
@ -199,6 +201,7 @@ typedef struct {
bool localplayer;
long streamport;
const char *streamurl;
unsigned long last_played_count;
} t_config;
t_config config;
@ -216,11 +219,13 @@ typedef struct {
int jukeboxMode;
const char *jukeboxPlaylist;
int jukeboxQueueLength;
char* colsQueue;
char *colsQueueCurrent;
char *colsSearch;
char *colsBrowseDatabase;
char *colsBrowsePlaylistsDetail;
char *colsBrowseFilesystem;
char *colsPlayback;
char *colsQueueLastPlayed;
} t_mympd_state;
t_mympd_state mympd_state;
@ -240,6 +245,7 @@ void mympd_like_song_uri(const char *uri, int value);
void mympd_last_played_song_uri(const char *uri);
void mympd_last_played_song_id(int song_id);
void mympd_get_sticker(const char *uri, t_sticker *sticker);
void mympd_last_played_list(int song_id);
void mympd_jukebox();
bool mympd_state_get(char *name, char *value);
bool mympd_state_set(const char *name, const char *value);
@ -269,6 +275,7 @@ int mympd_put_songs_in_album(char *buffer, char *album, char *search, char *tag)
int mympd_put_playlists(char *buffer, unsigned int offset, char *filter);
int mympd_put_playlist_list(char *buffer, char *uri, unsigned int offset, char *filter);
int mympd_put_songdetails(char *buffer, char *uri);
int mympd_put_last_played_songs(char *buffer, unsigned int offset);
int mympd_queue_crop(char *buffer);
void mympd_disconnect();
#endif

View File

@ -199,6 +199,8 @@ static int inihandler(void* user, const char* section, const char* name, const c
p_config->localplayer = false;
else if (MATCH("streamurl"))
p_config->streamurl = strdup(value);
else if (MATCH("last_played_count"))
p_config->last_played_count = strtol(value, &crap, 10);
else
return 0; /* unknown section/name, error */
@ -277,11 +279,11 @@ void read_statefiles() {
mympd_state_set("jukeboxQueueLength", "1");
}
if (mympd_state_get("colsQueue", value))
mympd_state.colsQueue = strdup(value);
if (mympd_state_get("colsQueueCurrent", value))
mympd_state.colsQueueCurrent = strdup(value);
else {
mympd_state.colsQueue = strdup("[\"Pos\",\"Title\",\"Artist\",\"Album\",\"Duration\"]");
mympd_state_set("colsQueue", mympd_state.colsQueue);
mympd_state.colsQueueCurrent = strdup("[\"Pos\",\"Title\",\"Artist\",\"Album\",\"Duration\"]");
mympd_state_set("colsQueueCurrent", mympd_state.colsQueueCurrent);
}
if (mympd_state_get("colsSearch", value))
@ -311,6 +313,45 @@ void read_statefiles() {
mympd_state.colsBrowseFilesystem = strdup("[\"Type\",\"Title\",\"Artist\",\"Album\",\"Duration\"]");
mympd_state_set("colsBrowseFilesystem", mympd_state.colsBrowseFilesystem);
}
if (mympd_state_get("colsPlayback", value))
mympd_state.colsPlayback = strdup(value);
else {
mympd_state.colsPlayback = strdup("[\"Artist\",\"Album\",\"Genre\"]");
mympd_state_set("colsPlayback", mympd_state.colsPlayback);
}
if (mympd_state_get("colsQueueLastPlayed", value))
mympd_state.colsQueueLastPlayed = strdup(value);
else {
mympd_state.colsQueueLastPlayed = strdup("[\"Pos\",\"Title\",\"Artist\",\"Album\",\"LastPlayed\"]");
mympd_state_set("colsQueueLastPlayed", mympd_state.colsQueueLastPlayed);
}
}
int read_last_played() {
char cfgfile[400];
char *line;
char *data;
size_t n = 0;
ssize_t read;
long value;
snprintf(cfgfile, 400, "%s/state/last_played", config.varlibdir);
FILE *fp = fopen(cfgfile, "r");
if (fp == NULL) {
printf("Error opening %s\n", cfgfile);
return 0;
}
while ((read = getline(&line, &n, fp)) > 0) {
value = strtol(line, &data, 10);
if (strlen(data) > 2)
data = data + 2;
strtok(data, "\n");
list_push(&last_played, data, value);
}
fclose(fp);
return last_played.length;;
}
bool testdir(char *name, char *dirname) {
@ -356,6 +397,7 @@ int main(int argc, char **argv) {
config.browsetaglist = "Artist,Album,AlbumArtist,Genre,Composer,Performer";
config.smartpls = true;
config.max_elements_per_page = 100;
config.last_played_count = 20;
char *etcdir = strdup(argv[1]);
config.etcdir = dirname(etcdir);
config.syscmds = false;
@ -364,6 +406,7 @@ int main(int argc, char **argv) {
mpd.timeout = 3000;
mpd.last_update_sticker_song_id = -1;
mpd.last_song_id = -1;
mpd.last_last_played_id = -1;
mpd.feat_library = false;
if (argc == 2) {
@ -457,8 +500,10 @@ int main(int argc, char **argv) {
mpd.feat_library = true;
printf("Enabling coverimage support\n");
}
else
else {
printf("Disabling coverimage support\n");
config.coverimage = false;
}
snprintf(testdirname, 400, "%s/tmp", config.varlibdir);
if (!testdir("Temp dir", testdirname))
@ -480,6 +525,8 @@ int main(int argc, char **argv) {
list_init(&mpd_tags);
list_init(&mympd_tags);
list_init(&last_played);
printf("Reading last played songs: %d\n", read_last_played());
if (config.ssl == true)
mg_set_protocol_http_websocket(nc_http);