mirror of
				https://github.com/SuperBFG7/ympd
				synced 2025-10-31 05:43:01 +00:00 
			
		
		
		
	Fix: code cleanups
Fix: use strtol not atoi
This commit is contained in:
		| @@ -48,9 +48,9 @@ install(FILES dist/htdocs/player.html DESTINATION share/${PROJECT_NAME}/htdocs/) | |||||||
| install(FILES dist/htdocs/sw.min.js DESTINATION share/${PROJECT_NAME}/htdocs/) | 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/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/bootstrap-native-v4.min.js DESTINATION share/${PROJECT_NAME}/htdocs/js/) | ||||||
| install(FILES dist/htdocs/js/mpd.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/css/bootstrap.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/) | install(FILES dist/htdocs/css/bootstrap.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/) | ||||||
| install(FILES dist/htdocs/css/mpd.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) | install(DIRECTORY htdocs/assets DESTINATION share/${PROJECT_NAME}/htdocs) | ||||||
| install(DIRECTORY DESTINATION /var/lib/${PROJECT_NAME}/) | install(DIRECTORY DESTINATION /var/lib/${PROJECT_NAME}/) | ||||||
| install(FILES contrib/mympd.conf DESTINATION /etc/${PROJECT_NAME}/) | install(FILES contrib/mympd.conf DESTINATION /etc/${PROJECT_NAME}/) | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								dist/htdocs/index.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/htdocs/index.html
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -49,8 +49,8 @@ function playlistMoveTrack(a,b){sendAPI({cmd:"MPD_API_PLAYLIST_MOVE_TRACK",data: | |||||||
| function webSocketConnect(){socket=new WebSocket(getWsUrl());try{socket.onopen=function(){console.log("connected");showNotification("Connected to myMPD","","","success");modalConnectionError.hide();appRoute();sendAPI({cmd:"MPD_API_GET_STATE"},parseState)},socket.onmessage=function(a){if(a.data!==lastState&&0!=a.data.length){try{var b=JSON.parse(a.data)}catch(c){console.log("Invalid JSON data received: "+a.data)}switch(b.type){case "update_state":parseState(b);break;case "disconnected":showNotification("myMPD lost connection to MPD", | function webSocketConnect(){socket=new WebSocket(getWsUrl());try{socket.onopen=function(){console.log("connected");showNotification("Connected to myMPD","","","success");modalConnectionError.hide();appRoute();sendAPI({cmd:"MPD_API_GET_STATE"},parseState)},socket.onmessage=function(a){if(a.data!==lastState&&0!=a.data.length){try{var b=JSON.parse(a.data)}catch(c){console.log("Invalid JSON data received: "+a.data)}switch(b.type){case "update_state":parseState(b);break;case "disconnected":showNotification("myMPD lost connection to MPD", | ||||||
| "","","danger");break;case "update_queue":"Queue"===app.current.app&&getQueue();break;case "update_options":getSettings();break;case "update_outputs":sendAPI({cmd:"MPD_API_GET_OUTPUTS"},parseOutputs);break;case "error":showNotification(b.data,"","","danger")}}},socket.onclose=function(){console.log("disconnected");modalConnectionError.show();setTimeout(function(){console.log("reconnect");webSocketConnect()},3E3)}}catch(a){alert("Error: "+a)}} | "","","danger");break;case "update_queue":"Queue"===app.current.app&&getQueue();break;case "update_options":getSettings();break;case "update_outputs":sendAPI({cmd:"MPD_API_GET_OUTPUTS"},parseOutputs);break;case "error":showNotification(b.data,"","","danger")}}},socket.onclose=function(){console.log("disconnected");modalConnectionError.show();setTimeout(function(){console.log("reconnect");webSocketConnect()},3E3)}}catch(a){alert("Error: "+a)}} | ||||||
| function getWsUrl(){var a=document.URL;if("https"==a.substring(0,5)){var b="wss://";a=a.substr(8)}else b="ws://","http"==a.substring(0,4)&&(a=a.substr(7));a=a.split("#");var c=/\/$/.test(a[0])?"":"/";return b+a[0]+c+"ws"} | function getWsUrl(){var a=document.URL;if("https"==a.substring(0,5)){var b="wss://";a=a.substr(8)}else b="ws://","http"==a.substring(0,4)&&(a=a.substr(7));a=a.split("#");var c=/\/$/.test(a[0])?"":"/";return b+a[0]+c+"ws"} | ||||||
| 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* | 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.mympd_version;document.getElementById("mpdVersion").innerText=a.data.mpd_version}function toggleBtn(a,b){if(a=document.getElementById(a))void 0==b&&(b=a.classList.contains("active")?0:1),1==b?(a.classList.add("active"),a.setAttribute("aria-pressed","true")):(a.classList.remove("active"),a.setAttribute("aria-pressed","false"))} | 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?a.classList.add("active"):a.classList.remove("active")} | ||||||
| function parseSettings(a){toggleBtn("btnRandom",a.data.random);toggleBtn("btnConsume",a.data.consume);toggleBtn("btnSingle",a.data.single);toggleBtn("btnRepeat",a.data.repeat);void 0!=a.data.crossfade?(document.getElementById("inputCrossfade").removeAttribute("disabled"),document.getElementById("inputCrossfade").value=a.data.crossfade):document.getElementById("inputCrossfade").setAttribute("disabled","disabled");void 0!=a.data.mixrampdb?(document.getElementById("inputMixrampdb").removeAttribute("disabled"), | function parseSettings(a){toggleBtn("btnRandom",a.data.random);toggleBtn("btnConsume",a.data.consume);toggleBtn("btnSingle",a.data.single);toggleBtn("btnRepeat",a.data.repeat);void 0!=a.data.crossfade?(document.getElementById("inputCrossfade").removeAttribute("disabled"),document.getElementById("inputCrossfade").value=a.data.crossfade):document.getElementById("inputCrossfade").setAttribute("disabled","disabled");void 0!=a.data.mixrampdb?(document.getElementById("inputMixrampdb").removeAttribute("disabled"), | ||||||
| document.getElementById("inputMixrampdb").value=a.data.mixrampdb):document.getElementById("inputMixrampdb").setAttribute("disabled","disabled");void 0!=a.data.mixrampdelay?(document.getElementById("inputMixrampdelay").removeAttribute("disabled"),document.getElementById("inputMixrampdelay").value=a.data.mixrampdelay):document.getElementById("inputMixrampdelay").setAttribute("disabled","disabled");document.getElementById("selectReplaygain").value=a.data.replaygain;var b=document.getElementById("btnnotifyWeb"); | document.getElementById("inputMixrampdb").value=a.data.mixrampdb):document.getElementById("inputMixrampdb").setAttribute("disabled","disabled");void 0!=a.data.mixrampdelay?(document.getElementById("inputMixrampdelay").removeAttribute("disabled"),document.getElementById("inputMixrampdelay").value=a.data.mixrampdelay):document.getElementById("inputMixrampdelay").setAttribute("disabled","disabled");document.getElementById("selectReplaygain").value=a.data.replaygain;var b=document.getElementById("btnnotifyWeb"); | ||||||
| notificationsSupported()?a.data.notificationWeb?(toggleBtn("btnnotifyWeb",a.data.notificationWeb),Notification.requestPermission(function(b){"permission"in Notification||(Notification.permission=b);"granted"===b?toggleBtn("btnnotifyWeb",1):(toggleBtn("btnnotifyWeb",0),a.data.notificationWeb=0)})):toggleBtn("btnnotifyWeb",0):(b.setAttribute("disabled","disabled"),toggleBtn("btnnotifyWeb",0));toggleBtn("btnnotifyPage",a.data.notificationPage);b=document.getElementsByClassName("stickers");for(var c= | notificationsSupported()?a.data.notificationWeb?(toggleBtn("btnnotifyWeb",a.data.notificationWeb),Notification.requestPermission(function(b){"permission"in Notification||(Notification.permission=b);"granted"===b?toggleBtn("btnnotifyWeb",1):(toggleBtn("btnnotifyWeb",0),a.data.notificationWeb=0)})):toggleBtn("btnnotifyWeb",0):(b.setAttribute("disabled","disabled"),toggleBtn("btnnotifyWeb",0));toggleBtn("btnnotifyPage",a.data.notificationPage);b=document.getElementsByClassName("stickers");for(var c= | ||||||
| @@ -62,10 +62,10 @@ function parseState(a){if(JSON.stringify(a)!==JSON.stringify(lastState)){if(1==a | |||||||
| 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");-1==a.data.volume?(domCache.volumePrct.innerText="Volumecontrol disabled",domCache.volumeControl.classList.add("hide")):(domCache.volumeControl.classList.remove("hide"),domCache.volumePrct.innerText= | 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");-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;setCounter(a.data.currentSongId,a.data.totalTime,a.data.elapsedTime);sendAPI({cmd:"MPD_API_GET_CURRENT_SONG"},songChange);"-1"==a.data.songPos&&(domCache.currentTrack.innerText="Not playing",domCache.currentAlbum.innerText="",domCache.currentArtist.innerText="",domCache.currentCover.style.backgroundImage="");lastState=a}} | 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;setCounter(a.data.currentSongId,a.data.totalTime,a.data.elapsedTime);sendAPI({cmd:"MPD_API_GET_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 getQueue(){2<=app.current.search.length?sendAPI({cmd:"MPD_API_SEARCH_QUEUE",data:{mpdtag:app.current.filter,offset:app.current.page,searchstr:app.current.search}},parseQueue):sendAPI({cmd:"MPD_API_GET_QUEUE",data:{offset:app.current.page}},parseQueue)} | function getQueue(){2<=app.current.search.length?sendAPI({cmd:"MPD_API_SEARCH_QUEUE",data:{mpdtag:app.current.filter,offset:app.current.page,searchstr:app.current.search}},parseQueue):sendAPI({cmd:"MPD_API_GET_QUEUE",data:{offset:app.current.page}},parseQueue)} | ||||||
| function parseQueue(a){if("Queue"===app.current.app){0<a.totalTime?document.getElementById("panel-heading-queue").innerText=a.totalEntities+" Songs \u2013 "+beautifyDuration(a.totalTime):0<a.totalEntities?document.getElementById("panel-heading-queue").innerText=a.totalEntities+" Songs":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 e= | function parseQueue(a){if("Queue"===app.current.app){0<a.totalTime&&a.totalEntities<=settings.maxElementsPerPage?document.getElementById("panel-heading-queue").innerText=a.totalEntities+" Songs \u2013 "+beautifyDuration(a.totalTime):0<a.totalEntities?document.getElementById("panel-heading-queue").innerText=a.totalEntities+" Songs":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.getElementsByTagName("tr"),d=0;d<b;d++)if(!e[d]||e[d].getAttribute("data-trackid")!=a.data[d].id||e[d].getAttribute("data-songpos")!=a.data[d].pos+1){var f=Math.floor(a.data[d].duration/60),g=a.data[d].duration-60*f;f=f+":"+(10>g?"0":"")+g;g=document.createElement("tr");g.setAttribute("draggable","true");g.setAttribute("data-trackid",a.data[d].id);g.setAttribute("id","queueTrackId"+a.data[d].id);g.setAttribute("data-songpos",a.data[d].pos+1);g.setAttribute("data-duration",f);g.setAttribute("data-uri", | c=c.getElementsByTagName("tbody")[0];for(var e=c.getElementsByTagName("tr"),d=0;d<b;d++)if(!e[d]||e[d].getAttribute("data-trackid")!=a.data[d].id||e[d].getAttribute("data-songpos")!=a.data[d].pos+1){var f=Math.floor(a.data[d].duration/60),g=a.data[d].duration-60*f;f=f+":"+(10>g?"0":"")+g;g=document.createElement("tr");g.setAttribute("draggable","true");g.setAttribute("data-trackid",a.data[d].id);g.setAttribute("id","queueTrackId"+a.data[d].id);g.setAttribute("data-songpos",a.data[d].pos+1);g.setAttribute("data-duration", | ||||||
| a.data[d].uri);g.innerHTML="<td>"+(a.data[d].pos+1)+"</td><td>"+a.data[d].title+"</td><td>"+a.data[d].artist+"</td><td>"+a.data[d].album+"</td><td>"+f+'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';d<e.length?e[d].replaceWith(g):c.append(g)}for(d=e.length-1;d>=b;d--)e[d].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&& | f);g.setAttribute("data-uri",a.data[d].uri);g.innerHTML="<td>"+(a.data[d].pos+1)+"</td><td>"+a.data[d].title+"</td><td>"+a.data[d].artist+"</td><td>"+a.data[d].album+"</td><td>"+f+'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';d<e.length?e[d].replaceWith(g):c.append(g)}for(d=e.length-1;d>=b;d--)e[d].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>': | ||||||
| 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")}} | "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 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=a.data.length,c=document.getElementById(app.current.app+(void 0==app.current.tab?"":app.current.tab)+"List").getElementsByTagName("tbody")[0],e=c.getElementsByTagName("tr"),d=0;d<b;d++){var f=encodeURI(a.data[d].uri);if(!e[d]||e[d].getAttribute("data-uri")!=f){var g=document.createElement("tr");g.setAttribute("data-type",a.data[d].type);g.setAttribute("data-uri",f);g.setAttribute("data-name", | function parseFilesystem(a){if("Browse"===app.current.app||"Filesystem"===app.current.tab||"Search"===app.current.app){for(var b=a.data.length,c=document.getElementById(app.current.app+(void 0==app.current.tab?"":app.current.tab)+"List").getElementsByTagName("tbody")[0],e=c.getElementsByTagName("tr"),d=0;d<b;d++){var f=encodeURI(a.data[d].uri);if(!e[d]||e[d].getAttribute("data-uri")!=f){var g=document.createElement("tr");g.setAttribute("data-type",a.data[d].type);g.setAttribute("data-uri",f);g.setAttribute("data-name", | ||||||
| a.data[d].name);switch(a.data[d].type){case "dir":g.innerHTML='<td><span class="material-icons">folder_open</span></td><td colspan="4">'+a.data[d].name+'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';break;case "song":f=Math.floor(a.data[d].duration/60);var h=a.data[d].duration-60*f;g.innerHTML='<td><span class="material-icons">music_note</span></td><td>'+a.data[d].title+"</td><td>"+a.data[d].artist+"</td><td>"+a.data[d].album+"</td><td>"+f+":"+(10>h?"0":"")+h+'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>'; | a.data[d].name);switch(a.data[d].type){case "dir":g.innerHTML='<td><span class="material-icons">folder_open</span></td><td colspan="4">'+a.data[d].name+'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';break;case "song":f=Math.floor(a.data[d].duration/60);var h=a.data[d].duration-60*f;g.innerHTML='<td><span class="material-icons">music_note</span></td><td>'+a.data[d].title+"</td><td>"+a.data[d].artist+"</td><td>"+a.data[d].album+"</td><td>"+f+":"+(10>h?"0":"")+h+'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>'; | ||||||
| @@ -85,8 +85,8 @@ data:{albumartist:a.searchstr,album:a.data[d].value}},parseListTitles));for(d=e. | |||||||
| function parseListTitles(a){if("Browse"===app.current.app||"Database"===app.current.tab||"Album"===app.current.view){var b=genId(a.album),c=document.getElementById("card"+b);b=c.getElementsByTagName("tbody")[0];var e=c.getElementsByTagName("img")[0];c=e.parentNode;e.setAttribute("src",a.cover);c.setAttribute("data-uri",encodeURI(a.data[0].uri.replace(/\/[^\/]+$/,"")));c.setAttribute("data-name",a.album);c.setAttribute("data-type","dir");e="";for(var d=a.data.length,f=0;f<d;f++)e+='<tr data-type="song" data-name="'+ | function parseListTitles(a){if("Browse"===app.current.app||"Database"===app.current.tab||"Album"===app.current.view){var b=genId(a.album),c=document.getElementById("card"+b);b=c.getElementsByTagName("tbody")[0];var e=c.getElementsByTagName("img")[0];c=e.parentNode;e.setAttribute("src",a.cover);c.setAttribute("data-uri",encodeURI(a.data[0].uri.replace(/\/[^\/]+$/,"")));c.setAttribute("data-name",a.album);c.setAttribute("data-type","dir");e="";for(var d=a.data.length,f=0;f<d;f++)e+='<tr data-type="song" data-name="'+ | ||||||
| a.data[f].title+'" data-uri="'+encodeURI(a.data[f].uri)+'"><td>'+a.data[f].track+"</td><td>"+a.data[f].title+'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td></tr>';b.innerHTML=e;c.addEventListener("click",function(a){a.preventDefault();showMenu(this)},!1);b.parentNode.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&& | a.data[f].title+'" data-uri="'+encodeURI(a.data[f].uri)+'"><td>'+a.data[f].track+"</td><td>"+a.data[f].title+'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td></tr>';b.innerHTML=e;c.addEventListener("click",function(a){a.preventDefault();showMenu(this)},!1);b.parentNode.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&& | ||||||
| (a.preventDefault(),showMenu(a.target))},!1)}} | (a.preventDefault(),showMenu(a.target))},!1)}} | ||||||
| function setPagination(a){var b=Math.ceil(a/settings.max_elements_per_page),c=app.current.app+(void 0==app.current.tab?"":app.current.tab);0==b&&(b=1);for(var e=["PaginationTop","PaginationBottom"],d=0;2>d;d++){document.getElementById(c+e[d]+"Page").innerText=app.current.page/settings.max_elements_per_page+1+" / "+b;if(1<b){document.getElementById(c+e[d]+"Page").removeAttribute("disabled");for(var f="",g=0;g<b;g++)f+='<button data-page="'+g*settings.max_elements_per_page+'" type="button" class="mr-1 mb-1 btn-sm btn btn-secondary">'+ | function setPagination(a){var b=Math.ceil(a/settings.maxElementsPerPage),c=app.current.app+(void 0==app.current.tab?"":app.current.tab);0==b&&(b=1);for(var e=["PaginationTop","PaginationBottom"],d=0;2>d;d++){document.getElementById(c+e[d]+"Page").innerText=app.current.page/settings.maxElementsPerPage+1+" / "+b;if(1<b){document.getElementById(c+e[d]+"Page").removeAttribute("disabled");for(var f="",g=0;g<b;g++)f+='<button data-page="'+g*settings.maxElementsPerPage+'" type="button" class="mr-1 mb-1 btn-sm btn btn-secondary">'+ | ||||||
| (g+1)+"</button>";document.getElementById(c+e[d]+"Pages").innerHTML=f}else document.getElementById(c+e[d]+"Page").setAttribute("disabled","disabled");a>app.current.page+settings.max_elements_per_page?(document.getElementById(c+e[d]+"Next").removeAttribute("disabled"),document.getElementById(c+e[d]).classList.remove("hide"),document.getElementById(c+"ButtonsBottom").classList.remove("hide")):(document.getElementById(c+e[d]+"Next").setAttribute("disabled","disabled"),document.getElementById(c+e[d]).classList.add("hide"), | (g+1)+"</button>";document.getElementById(c+e[d]+"Pages").innerHTML=f}else document.getElementById(c+e[d]+"Page").setAttribute("disabled","disabled");a>app.current.page+settings.maxElementsPerPage?(document.getElementById(c+e[d]+"Next").removeAttribute("disabled"),document.getElementById(c+e[d]).classList.remove("hide"),document.getElementById(c+"ButtonsBottom").classList.remove("hide")):(document.getElementById(c+e[d]+"Next").setAttribute("disabled","disabled"),document.getElementById(c+e[d]).classList.add("hide"), | ||||||
| document.getElementById(c+"ButtonsBottom").classList.add("hide"));0<app.current.page?(document.getElementById(c+e[d]+"Prev").removeAttribute("disabled"),document.getElementById(c+e[d]).classList.remove("hide"),document.getElementById(c+"ButtonsBottom").classList.remove("hide")):document.getElementById(c+e[d]+"Prev").setAttribute("disabled","disabled")}} | document.getElementById(c+"ButtonsBottom").classList.add("hide"));0<app.current.page?(document.getElementById(c+e[d]+"Prev").removeAttribute("disabled"),document.getElementById(c+e[d]).classList.remove("hide"),document.getElementById(c+"ButtonsBottom").classList.remove("hide")):document.getElementById(c+e[d]+"Prev").setAttribute("disabled","disabled")}} | ||||||
| function appendQueue(a,b,c){switch(a){case "song":sendAPI({cmd:"MPD_API_ADD_TRACK",data:{uri:b}});showNotification('"'+c+'" added',"","","success");break;case "dir":sendAPI({cmd:"MPD_API_ADD_TRACK",data:{uri:b}});showNotification('"'+c+'" added',"","","success");break;case "plist":sendAPI({cmd:"MPD_API_ADD_PLAYLIST",data:{plist:b}}),showNotification('"'+c+'" added',"","","success")}} | function appendQueue(a,b,c){switch(a){case "song":sendAPI({cmd:"MPD_API_ADD_TRACK",data:{uri:b}});showNotification('"'+c+'" added',"","","success");break;case "dir":sendAPI({cmd:"MPD_API_ADD_TRACK",data:{uri:b}});showNotification('"'+c+'" added',"","","success");break;case "plist":sendAPI({cmd:"MPD_API_ADD_PLAYLIST",data:{plist:b}}),showNotification('"'+c+'" added',"","","success")}} | ||||||
| function appendAfterQueue(a,b,c,e){switch(a){case "song":sendAPI({cmd:"MPD_API_ADD_TRACK_AFTER",data:{uri:b,to:c}}),showNotification('"'+e+'" added to pos '+c,"","","success")}} | function appendAfterQueue(a,b,c,e){switch(a){case "song":sendAPI({cmd:"MPD_API_ADD_TRACK_AFTER",data:{uri:b,to:c}}),showNotification('"'+e+'" added to pos '+c,"","","success")}} | ||||||
| @@ -96,7 +96,7 @@ function parseSongDetails(a){var b=document.getElementById("modalSongDetails");b | |||||||
| 2==f?'<span class="material-icons">thumb_up_alt</span>':"not voted":"uri"==d&&(f='<a class="text-success" href="/library/'+f+'">'+f+"</a>");b[e].getElementsByTagName("td")[0].innerHTML=f}}}function playlistDetails(a){appGoto("Browse","Playlists","Detail","0/-/"+a)} | 2==f?'<span class="material-icons">thumb_up_alt</span>':"not voted":"uri"==d&&(f='<a class="text-success" href="/library/'+f+'">'+f+"</a>");b[e].getElementsByTagName("td")[0].innerHTML=f}}}function playlistDetails(a){appGoto("Browse","Playlists","Detail","0/-/"+a)} | ||||||
| function removeFromPlaylist(a,b){b--;sendAPI({cmd:"MPD_API_RM_PLAYLIST_TRACK",data:{uri:a,track:b}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05");sendAPI({cmd:"MPD_API_GET_PLAYLIST_LIST",data:{offset:app.current.page,filter:app.current.filter,uri:app.current.search}},parsePlaylists)} | function removeFromPlaylist(a,b){b--;sendAPI({cmd:"MPD_API_RM_PLAYLIST_TRACK",data:{uri:a,track:b}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05");sendAPI({cmd:"MPD_API_GET_PLAYLIST_LIST",data:{offset:app.current.page,filter:app.current.filter,uri:app.current.search}},parsePlaylists)} | ||||||
| function playlistClear(){var a=document.getElementById("BrowsePlaylistsDetailList").getAttribute("data-uri");sendAPI({cmd:"MPD_API_PLAYLIST_CLEAR",data:{uri:a}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05");sendAPI({cmd:"MPD_API_GET_PLAYLIST_LIST",data:{offset:app.current.page,filter:app.current.filter,uri:app.current.search}},parsePlaylists)} | function playlistClear(){var a=document.getElementById("BrowsePlaylistsDetailList").getAttribute("data-uri");sendAPI({cmd:"MPD_API_PLAYLIST_CLEAR",data:{uri:a}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05");sendAPI({cmd:"MPD_API_GET_PLAYLIST_LIST",data:{offset:app.current.page,filter:app.current.filter,uri:app.current.search}},parsePlaylists)} | ||||||
| function getAllPlaylists(a){for(var b=a.data.length,c="<option></option><option>New Playlist</option>",e=0;e<b;e++)c+="<option>"+a.data[e].uri+"</option>";document.getElementById("addToPlaylistPlaylist").innerHTML+=c;a.totalEntities>a.returnedEntities&&(a.offset+=settings.max_elements_per_page,sendAPI({cmd:"MPD_API_GET_PLAYLISTS",data:{offset:a.offset,filter:"-"}},getAllPlaylists))} | function getAllPlaylists(a){for(var b=a.data.length,c="<option></option><option>New Playlist</option>",e=0;e<b;e++)c+="<option>"+a.data[e].uri+"</option>";document.getElementById("addToPlaylistPlaylist").innerHTML+=c;a.totalEntities>a.returnedEntities&&(a.offset+=settings.maxElementsPerPage,sendAPI({cmd:"MPD_API_GET_PLAYLISTS",data:{offset:a.offset,filter:"-"}},getAllPlaylists))} | ||||||
| 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 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")): | 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"))} | 2==a&&(domCache.btnVoteUp.classList.add("active-fg-green"),domCache.btnVoteDown.classList.remove("active-fg-red"))} | ||||||
| @@ -126,10 +126,10 @@ function confirmSettings(){var a=!0,b=document.getElementById("inputCrossfade"); | |||||||
| mixrampdb:1==settings.mixramp?document.getElementById("inputMixrampdb").value:settings.mixrampdb,mixrampdelay:1==settings.mixramp?document.getElementById("inputMixrampdelay").value:settings.mixrampdelay,notificationWeb:document.getElementById("btnnotifyWeb").classList.contains("active")?1:0,notificationPage:document.getElementById("btnnotifyPage").classList.contains("active")?1:0}},getSettings),modalSettings.hide()):document.getElementById("settingsFrm").classList.add("was-validated")} | mixrampdb:1==settings.mixramp?document.getElementById("inputMixrampdb").value:settings.mixrampdb,mixrampdelay:1==settings.mixramp?document.getElementById("inputMixrampdelay").value:settings.mixrampdelay,notificationWeb:document.getElementById("btnnotifyWeb").classList.contains("active")?1:0,notificationPage:document.getElementById("btnnotifyPage").classList.contains("active")?1:0}},getSettings),modalSettings.hide()):document.getElementById("settingsFrm").classList.add("was-validated")} | ||||||
| function addAllFromBrowse(){sendAPI({cmd:"MPD_API_ADD_TRACK",data:{uri:app.current.search}});showNotification("Added all songs","","","success")}function addAllFromSearch(){2<=app.current.search.length&&(sendAPI({cmd:"MPD_API_SEARCH_ADD",data:{filter:app.current.filter,searchstr:app.current.search}}),showNotification("Added "+parseInt(document.getElementById("panel-heading-search").innerText)+" songs from search","","","success"))} | function addAllFromBrowse(){sendAPI({cmd:"MPD_API_ADD_TRACK",data:{uri:app.current.search}});showNotification("Added all songs","","","success")}function addAllFromSearch(){2<=app.current.search.length&&(sendAPI({cmd:"MPD_API_SEARCH_ADD",data:{filter:app.current.filter,searchstr:app.current.search}}),showNotification("Added "+parseInt(document.getElementById("panel-heading-search").innerText)+" songs from search","","","success"))} | ||||||
| function addAllFromSearchPlist(a){if(2<=app.current.search.length){var b=app.current.filter;"Any Tag"==b&&(b="any");sendAPI({cmd:"MPD_API_SEARCH_ADD_PLIST",data:{plist:a,filter:b,searchstr:app.current.search}});showNotification("Added "+parseInt(document.getElementById("panel-heading-search").innerText)+" songs from search to "+a,"","","success")}}function scrollTo(a){document.body.scrollTop=a;document.documentElement.scrollTop=a} | function addAllFromSearchPlist(a){if(2<=app.current.search.length){var b=app.current.filter;"Any Tag"==b&&(b="any");sendAPI({cmd:"MPD_API_SEARCH_ADD_PLIST",data:{plist:a,filter:b,searchstr:app.current.search}});showNotification("Added "+parseInt(document.getElementById("panel-heading-search").innerText)+" songs from search to "+a,"","","success")}}function scrollTo(a){document.body.scrollTop=a;document.documentElement.scrollTop=a} | ||||||
| function gotoPage(a){switch(a){case "next":app.current.page+=settings.max_elements_per_page;break;case "prev":app.current.page-=settings.max_elements_per_page;0>app.current.page&&(app.current.page=0);break;default:app.current.page=a}appGoto(app.current.app,app.current.tab,app.current.view,app.current.page+"/"+app.current.filter+"/"+app.current.search)} | function gotoPage(a){switch(a){case "next":app.current.page+=settings.maxElementsPerPage;break;case "prev":app.current.page-=settings.maxElementsPerPage;0>app.current.page&&(app.current.page=0);break;default:app.current.page=a}appGoto(app.current.app,app.current.tab,app.current.view,app.current.page+"/"+app.current.filter+"/"+app.current.search)} | ||||||
| function saveQueue(){var a=document.getElementById("saveQueueName").value,b=a.replace(/\w/g,"");""!=a&&""==b?(sendAPI({cmd:"MPD_API_SAVE_QUEUE",data:{plist:a}}),modalSavequeue.hide()):(document.getElementById("saveQueueName").classList.add("is-invalid"),document.getElementById("saveQueueFrm").classList.add("was-validated"))} | function saveQueue(){var a=document.getElementById("saveQueueName").value,b=a.replace(/\w/g,"");""!=a&&""==b?(sendAPI({cmd:"MPD_API_SAVE_QUEUE",data:{plist:a}}),modalSavequeue.hide()):(document.getElementById("saveQueueName").classList.add("is-invalid"),document.getElementById("saveQueueFrm").classList.add("was-validated"))} | ||||||
| function showNotification(a,b,c,e){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-"+e),b.innerHTML="<div><strong>"+ | function showNotification(a,b,c,e){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-"+e),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(){document.getElementById("alertBox").remove()},600))} | 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 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="",e="",d="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,e+=a.data.artist,d+=a.data.artist+" - ",domCache.currentArtist.innerText=a.data.artist,domCache.currentArtist.setAttribute("data-albumartist",a.data.albumartist)): | 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="",e="",d="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,e+=a.data.artist,d+=a.data.artist+" - ",domCache.currentArtist.innerText=a.data.artist,domCache.currentArtist.setAttribute("data-albumartist",a.data.albumartist)): | ||||||
| domCache.currentArtist.innerText="";"undefined"!=typeof a.data.album&&0<a.data.album.length&&"-"!=a.data.album?(c+=" - "+a.data.album,e+="<br/>"+a.data.album,domCache.currentAlbum.innerText=a.data.album):domCache.currentAlbum.innerText="";"undefined"!=typeof a.data.title&&0<a.data.title.length?(d+=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","")); | domCache.currentArtist.innerText="";"undefined"!=typeof a.data.album&&0<a.data.album.length&&"-"!=a.data.album?(c+=" - "+a.data.album,e+="<br/>"+a.data.album,domCache.currentAlbum.innerText=a.data.album):domCache.currentAlbum.innerText="";"undefined"!=typeof a.data.title&&0<a.data.title.length?(d+=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","")); | ||||||
							
								
								
									
										2
									
								
								dist/htdocs/player.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/htdocs/player.html
									
									
									
									
										vendored
									
									
								
							| @@ -1 +1 @@ | |||||||
| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="description" content="myMPD - fast and lightweight MPD webclient"><meta name="author" content="mail@jcgames.de"><title>myMPD: Local Player</title><link href="css/bootstrap.min.css" rel="stylesheet"><link href="css/mpd.min.css" rel="stylesheet"><link href="assets/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon"><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="apple-mobile-web-app-status-bar-style" content="black"/><link rel="apple-touch-icon" href="assets/appicon.png"/></head><body><header><nav class="navbar navbar-expand navbar-dark fixed-top bg-dark"><a class="navbar-brand" data-toggle="dropdown" href="#"><span class="material-icons header-logo">play_circle_outline</span>myMPD</a></nav></header><main role="main" class="container"><div class="card"><div class="card-header">Local Player</div><div class="card-body"><audio id="player" preload="none" controls=""></audio></div></div></main><script type="text/javascript" src="js/player.min.js"></script></body></html> | <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="description" content="myMPD - fast and lightweight MPD webclient"><meta name="author" content="mail@jcgames.de"><title>myMPD: Local Player</title><link href="css/bootstrap.min.css" rel="stylesheet"><link href="css/mympd.min.css" rel="stylesheet"><link href="assets/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon"><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="apple-mobile-web-app-status-bar-style" content="black"/><link rel="apple-touch-icon" href="assets/appicon.png"/></head><body><header><nav class="navbar navbar-expand navbar-dark fixed-top bg-dark"><a class="navbar-brand" data-toggle="dropdown" href="#"><span class="material-icons header-logo">play_circle_outline</span>myMPD</a></nav></header><main role="main" class="container"><div class="card"><div class="card-header">Local Player</div><div class="card-body"><audio id="player" preload="none" controls=""></audio></div></div></main><script type="text/javascript" src="js/player.min.js"></script></body></html> | ||||||
							
								
								
									
										2
									
								
								dist/htdocs/sw.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/htdocs/sw.min.js
									
									
									
									
										vendored
									
									
								
							| @@ -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= | 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)}}: | 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, | 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-v3.6.0",urlsToCache="/ /player.html /css/bootstrap.min.css /css/mpd.min.css /js/bootstrap-native-v4.min.js /js/mpd.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/favicon.ico /assets/MaterialIcons-Regular.eot /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-v3.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 /assets/appicon-167.png /assets/appicon-192.png /assets/appicon-512.png /assets/coverimage-httpstream.png /assets/coverimage-notavailable.png /assets/favicon.ico /assets/MaterialIcons-Regular.eot /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){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)}))}))}); | self.addEventListener("install",function(a){a.waitUntil(caches.open(CACHE).then(function(a){return a.addAll(urlsToCache)}))});self.addEventListener("fetch",function(a){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)}))}))}); | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ | |||||||
|   <meta name="apple-mobile-web-app-status-bar-style" content="black"> |   <meta name="apple-mobile-web-app-status-bar-style" content="black"> | ||||||
|   <meta name="theme-color" content="#343a40"> |   <meta name="theme-color" content="#343a40"> | ||||||
|   <link href="/css/bootstrap.min.css" rel="stylesheet"> |   <link href="/css/bootstrap.min.css" rel="stylesheet"> | ||||||
|   <link href="/css/mpd.css" rel="stylesheet"> |   <link href="/css/mympd.css" rel="stylesheet"> | ||||||
|   <link href="/assets/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">   |   <link href="/assets/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">   | ||||||
|   <link rel="manifest" href="/mympd.webmanifest"> |   <link rel="manifest" href="/mympd.webmanifest"> | ||||||
|   <link rel="apple-touch-icon" href="/assets/appicon-167.png"> |   <link rel="apple-touch-icon" href="/assets/appicon-167.png"> | ||||||
| @@ -31,8 +31,8 @@ | |||||||
|             <a id="nav-add2homescreen" class="dropdown-item text-light bg-dark hide" href="#">Add2HomeScreen</a> |             <a id="nav-add2homescreen" class="dropdown-item text-light bg-dark hide" href="#">Add2HomeScreen</a> | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|         <div class="btn-toolbar col-auto pl-0 pr-0" role="toolbar"> |         <div class="btn-toolbar col-auto pl-0 pr-0"> | ||||||
|           <div class="btn-group mr-2" role="group" id="playControlBtns"> |           <div class="btn-group mr-2" id="playControlBtns"> | ||||||
|             <button data-href="{'cmd':'clickPrev','options':[]}" id="btnPrev" type="button" class="btn btn-secondary pl-2 pr-2 material-icons"> |             <button data-href="{'cmd':'clickPrev','options':[]}" id="btnPrev" type="button" class="btn btn-secondary pl-2 pr-2 material-icons"> | ||||||
|               skip_previous |               skip_previous | ||||||
|             </button> |             </button> | ||||||
| @@ -46,14 +46,14 @@ | |||||||
|               skip_next |               skip_next | ||||||
|             </button> |             </button> | ||||||
|           </div> |           </div> | ||||||
|           <div class="btn-group" role="group"> |           <div class="btn-group"> | ||||||
|             <button id="volumeIcon" class="btn btn-secondary dropdown-toggle pl-2 pr-2 material-icons" type="button" data-toggle="dropdown"> |             <button id="volumeIcon" class="btn btn-secondary dropdown-toggle pl-2 pr-2 material-icons" type="button" data-toggle="dropdown"> | ||||||
|               volume_up |               volume_up | ||||||
|             </button> |             </button> | ||||||
|             <div class="dropdown-menu dropdown-menu-right bg-dark"> |             <div class="dropdown-menu dropdown-menu-right bg-dark"> | ||||||
|               <h2 class="dropdown-header text-light">Volume: <span id="volumePrct"></span></h2> |               <h2 class="dropdown-header text-light">Volume: <span id="volumePrct"></span></h2> | ||||||
|               <form class="px-4 py-0 pb-3" id="volumeControl"> |               <form class="px-4 py-0 pb-3" id="volumeControl"> | ||||||
|                 <div class="btn-group" role="group"> |                 <div class="btn-group"> | ||||||
|                   <button data-href="{'cmd':'chVolume','options':[-5]}" class="btn btn-secondary">−</button> |                   <button data-href="{'cmd':'chVolume','options':[-5]}" class="btn btn-secondary">−</button> | ||||||
|                   <div class="btn btn-secondary"> |                   <div class="btn btn-secondary"> | ||||||
|                     <input type="range" min="0" max="100" step="1" class="form-control-range" id="volumeBar"> |                     <input type="range" min="0" max="100" step="1" class="form-control-range" id="volumeBar"> | ||||||
| @@ -70,11 +70,16 @@ | |||||||
|   </header> |   </header> | ||||||
|   <main class="container"> |   <main class="container"> | ||||||
|     <noscript> |     <noscript> | ||||||
|       <div class="alert alert-danger" role="alert">JavaScript is disabled!</div> |       <div class="alert alert-danger">JavaScript is disabled!</div> | ||||||
|     </noscript> |     </noscript> | ||||||
|      |      | ||||||
|     <div class="card" id="cardPlayback"> |     <div class="card" id="cardPlayback"> | ||||||
|       <div class="card-header">Playback</div> |       <div class="card-header">Playback | ||||||
|  |         <div class="btn-group btn-group-sm stickers 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> | ||||||
|  |         </div> | ||||||
|  |       </div> | ||||||
|       <div class="card-body"> |       <div class="card-body"> | ||||||
|         <div class="album-cover" id="currentCover"></div> |         <div class="album-cover" id="currentCover"></div> | ||||||
|         <div class="album-desc"> |         <div class="album-desc"> | ||||||
| @@ -83,13 +88,6 @@ | |||||||
|           <h4 id="currentArtist" data-href="{'cmd': 'artistClick', 'options': []}"></h4> |           <h4 id="currentArtist" data-href="{'cmd': 'artistClick', 'options': []}"></h4> | ||||||
|           <small>Album</small> |           <small>Album</small> | ||||||
|           <h4 id="currentAlbum"></h4> |           <h4 id="currentAlbum"></h4> | ||||||
|           <div class="stickers"> |  | ||||||
|             <small>Vote</small><br/> |  | ||||||
|             <div class="btn-group"> |  | ||||||
|               <button id="btnVoteDown" data-href="{'cmd': 'voteSong', 'options': ['0']}" class="btn btn-sm btn-light material-icons">thumb_down</button> |  | ||||||
|               <button id="btnVoteUp" data-href="{'cmd': 'voteSong', 'options': ['2']}" class="btn btn-sm btn-light material-icons">thumb_up</button> |  | ||||||
|             </div> |  | ||||||
|           </div> |  | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|       <div class="card-footer card-footer-playback"> |       <div class="card-footer card-footer-playback"> | ||||||
| @@ -106,7 +104,7 @@ | |||||||
|         Queue<span id="panel-heading-queue" class="text pull-right"></span> |         Queue<span id="panel-heading-queue" class="text pull-right"></span> | ||||||
|       </div> |       </div> | ||||||
|       <div class="card-body"> |       <div class="card-body"> | ||||||
|         <div class="btn-toolbar card-toolbar" id="queue-buttons" role="toolbar"> |         <div class="btn-toolbar card-toolbar" id="queue-buttons"> | ||||||
|           <div class="btn-group mr-2"> |           <div class="btn-group mr-2"> | ||||||
|             <button type="button" class="btn btn-secondary material-icons" data-toggle="modal" data-target="#modalSaveQueue" title="Save queue"> |             <button type="button" class="btn btn-secondary material-icons" data-toggle="modal" data-target="#modalSaveQueue" title="Save queue"> | ||||||
|               save |               save | ||||||
| @@ -127,7 +125,7 @@ | |||||||
|               </div> |               </div> | ||||||
|             </div> |             </div> | ||||||
|           </div> |           </div> | ||||||
|           <form id="searchqueue" role="search"> |           <form id="searchqueue"> | ||||||
|             <div class="input-group mr-2"> |             <div class="input-group mr-2"> | ||||||
|               <input type="text" class="form-control" placeholder="Search Queue" id="searchqueuestr"/> |               <input type="text" class="form-control" placeholder="Search Queue" id="searchqueuestr"/> | ||||||
|               <div class="input-group-append"> |               <div class="input-group-append"> | ||||||
| @@ -178,7 +176,7 @@ | |||||||
|             </tbody> |             </tbody> | ||||||
|           </table> |           </table> | ||||||
|         </div> |         </div> | ||||||
|         <div class="btn-toolbar hide" id="QueueButtonsBottom" role="toolbar"> |         <div class="btn-toolbar hide" id="QueueButtonsBottom"> | ||||||
|           <div class="btn-group mr-2"> |           <div class="btn-group mr-2"> | ||||||
|             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd':'scrollTo','options':[0]}" title="To top"> |             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd':'scrollTo','options':[0]}" title="To top"> | ||||||
|               keyboard_arrow_up |               keyboard_arrow_up | ||||||
| @@ -213,7 +211,7 @@ | |||||||
|       </div> |       </div> | ||||||
|        |        | ||||||
|       <div class="card-body hide" id="cardBrowsePlaylists"> |       <div class="card-body hide" id="cardBrowsePlaylists"> | ||||||
|         <div class="btn-toolbar card-toolbar" id="BrowsePlaylistsButtons" role="toolbar"> |         <div class="btn-toolbar card-toolbar" id="BrowsePlaylistsButtons"> | ||||||
|           <div class="btn-group mr-2 hide"> |           <div class="btn-group mr-2 hide"> | ||||||
|             <button data-href="{'cmd': 'appGoto', 'options': ['Browse','Playlists','All']}" id="btnBrowsePlaylistsAll" type="button" class="btn btn-secondary">« Playlists</button> |             <button data-href="{'cmd': 'appGoto', 'options': ['Browse','Playlists','All']}" id="btnBrowsePlaylistsAll" type="button" class="btn btn-secondary">« Playlists</button> | ||||||
|           </div> |           </div> | ||||||
| @@ -276,7 +274,7 @@ | |||||||
|             </tbody> |             </tbody> | ||||||
|           </table>           |           </table>           | ||||||
|         </div> |         </div> | ||||||
|         <div class="btn-toolbar hide" id="BrowsePlaylistsButtonsBottom" role="toolbar"> |         <div class="btn-toolbar hide" id="BrowsePlaylistsButtonsBottom"> | ||||||
|           <div class="btn-group mr-2"> |           <div class="btn-group mr-2"> | ||||||
|             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd': 'scrollTo', 'options': [0]}" title="To top"> |             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd': 'scrollTo', 'options': [0]}" title="To top"> | ||||||
|               keyboard_arrow_up |               keyboard_arrow_up | ||||||
| @@ -295,7 +293,7 @@ | |||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div class="card-body hide" id="cardBrowseDatabase"> |       <div class="card-body hide" id="cardBrowseDatabase"> | ||||||
|         <div class="btn-toolbar card-toolbar" id="BrowseDatabaseButtons" role="toolbar"> |         <div class="btn-toolbar card-toolbar" id="BrowseDatabaseButtons"> | ||||||
|           <div class="btn-group mr-2 hide"> |           <div class="btn-group mr-2 hide"> | ||||||
|             <button data-href="{'cmd': 'appGoto', 'options': ['Browse','Database','Artist']}" id="btnBrowseDatabaseArtist" type="button" class="btn btn-secondary">« Artists</button> |             <button data-href="{'cmd': 'appGoto', 'options': ['Browse','Database','Artist']}" id="btnBrowseDatabaseArtist" type="button" class="btn btn-secondary">« Artists</button> | ||||||
|           </div> |           </div> | ||||||
| @@ -334,7 +332,7 @@ | |||||||
|          |          | ||||||
|         <div id="BrowseDatabaseAlbumList" class="row hide"></div> |         <div id="BrowseDatabaseAlbumList" class="row hide"></div> | ||||||
|          |          | ||||||
|         <div class="btn-toolbar hide" id="BrowseDatabaseButtonsBottom" role="toolbar"> |         <div class="btn-toolbar hide" id="BrowseDatabaseButtonsBottom"> | ||||||
|           <div class="btn-group mr-2"> |           <div class="btn-group mr-2"> | ||||||
|             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd': 'scrollTo', 'options': [0]}" title="To top"> |             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd': 'scrollTo', 'options': [0]}" title="To top"> | ||||||
|               keyboard_arrow_up |               keyboard_arrow_up | ||||||
| @@ -354,7 +352,7 @@ | |||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div class="card-body hide" id="cardBrowseFilesystem"> |       <div class="card-body hide" id="cardBrowseFilesystem"> | ||||||
|         <div class="btn-toolbar card-toolbar" id="BrowseFilesystemButtons" role="toolbar"> |         <div class="btn-toolbar card-toolbar" id="BrowseFilesystemButtons"> | ||||||
|           <div class="btn-group mr-2"> |           <div class="btn-group mr-2"> | ||||||
|             <button id="BrowseFilesystemFilter" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">Filter</button> |             <button id="BrowseFilesystemFilter" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">Filter</button> | ||||||
|             <div class="dropdown-menu bg-dark px-2 letters" id="BrowseFilesystemFilterLetters"> |             <div class="dropdown-menu bg-dark px-2 letters" id="BrowseFilesystemFilterLetters"> | ||||||
| @@ -406,7 +404,7 @@ | |||||||
|             </tbody> |             </tbody> | ||||||
|           </table> |           </table> | ||||||
|         </div> |         </div> | ||||||
|         <div class="btn-toolbar hide" id="BrowseFilesystemButtonsBottom" role="toolbar"> |         <div class="btn-toolbar hide" id="BrowseFilesystemButtonsBottom"> | ||||||
|           <div class="btn-group mr-2"> |           <div class="btn-group mr-2"> | ||||||
|             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd': 'scrollTo', 'options': [0]}" title="To top"> |             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd': 'scrollTo', 'options': [0]}" title="To top"> | ||||||
|               keyboard_arrow_up |               keyboard_arrow_up | ||||||
| @@ -431,8 +429,8 @@ | |||||||
|         <span id="panel-heading-search" class="text pull-right"></span> |         <span id="panel-heading-search" class="text pull-right"></span> | ||||||
|       </div> |       </div> | ||||||
|       <div class="card-body"> |       <div class="card-body"> | ||||||
|         <div class="btn-toolbar card-toolbar" id="SearchButtons" role="toolbar"> |         <div class="btn-toolbar card-toolbar" id="SearchButtons"> | ||||||
|           <form id="search" role="search"> |           <form id="search"> | ||||||
|             <div class="input-group mr-2"> |             <div class="input-group mr-2"> | ||||||
|               <input type="text" class="form-control" placeholder="Search" id="searchstr"/> |               <input type="text" class="form-control" placeholder="Search" id="searchstr"/> | ||||||
|               <div class="input-group-append"> |               <div class="input-group-append"> | ||||||
| @@ -492,7 +490,7 @@ | |||||||
|             </tbody> |             </tbody> | ||||||
|           </table> |           </table> | ||||||
|         </div> |         </div> | ||||||
|         <div class="btn-toolbar hide" id="SearchButtonsBottom" role="toolbar"> |         <div class="btn-toolbar hide" id="SearchButtonsBottom"> | ||||||
|           <div class="btn-group mr-2"> |           <div class="btn-group mr-2"> | ||||||
|             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd': 'scrollTo', 'options': [0]}" title="To top"> |             <button type="button" class="btn btn-secondary material-icons" data-href="{'cmd': 'scrollTo', 'options': [0]}" title="To top"> | ||||||
|               keyboard_arrow_up |               keyboard_arrow_up | ||||||
| @@ -524,8 +522,8 @@ | |||||||
|   </footer> |   </footer> | ||||||
|  |  | ||||||
|   <!-- Modals --> |   <!-- Modals --> | ||||||
|   <div class="modal fade" id="modalConnectionError" tabindex="-1" role="dialog"> |   <div class="modal fade" id="modalConnectionError" tabindex="-1"> | ||||||
|     <div class="modal-dialog" role="document"> |     <div class="modal-dialog"> | ||||||
|       <div class="modal-content"> |       <div class="modal-content"> | ||||||
|         <div class="modal-header bg-danger text-light"> |         <div class="modal-header bg-danger text-light"> | ||||||
|           <h5 class="modal-title"><span class="material-icons title-icon">error</span> Connection Error</h5> |           <h5 class="modal-title"><span class="material-icons title-icon">error</span> Connection Error</h5> | ||||||
| @@ -537,8 +535,8 @@ | |||||||
|       </div> |       </div> | ||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
|   <div class="modal fade" id="modalAddToPlaylist" tabindex="-1" role="dialog"> |   <div class="modal fade" id="modalAddToPlaylist" tabindex="-1"> | ||||||
|     <div class="modal-dialog" role="document"> |     <div class="modal-dialog"> | ||||||
|       <div class="modal-content"> |       <div class="modal-content"> | ||||||
|         <div class="modal-header"> |         <div class="modal-header"> | ||||||
|           <h5 class="modal-title"><span class="material-icons title-icon">playlist_add</span> <span id="addToPlaylistLabel">Add to playlist</span></h5> |           <h5 class="modal-title"><span class="material-icons title-icon">playlist_add</span> <span id="addToPlaylistLabel">Add to playlist</span></h5> | ||||||
| @@ -588,8 +586,8 @@ | |||||||
|     </div> |     </div> | ||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
|   <div class="modal fade" id="modalRenamePlaylist" tabindex="-1" role="dialog"> |   <div class="modal fade" id="modalRenamePlaylist" tabindex="-1"> | ||||||
|     <div class="modal-dialog" role="document"> |     <div class="modal-dialog"> | ||||||
|       <div class="modal-content"> |       <div class="modal-content"> | ||||||
|         <div class="modal-header"> |         <div class="modal-header"> | ||||||
|           <h5 class="modal-title"><span class="material-icons title-icon">playlist_add</span>Rename playlist</h5> |           <h5 class="modal-title"><span class="material-icons title-icon">playlist_add</span>Rename playlist</h5> | ||||||
| @@ -618,7 +616,7 @@ | |||||||
|       </div> |       </div> | ||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
|   <div class="modal fade" id="modalSettings" tabindex="-1" role="dialog"> |   <div class="modal fade" id="modalSettings" tabindex="-1"> | ||||||
|     <div class="modal-dialog"> |     <div class="modal-dialog"> | ||||||
|       <div class="modal-content"> |       <div class="modal-content"> | ||||||
|         <div class="modal-header"> |         <div class="modal-header"> | ||||||
| @@ -711,7 +709,7 @@ | |||||||
|     </div> |     </div> | ||||||
|   </div> |   </div> | ||||||
|    |    | ||||||
|   <div class="modal fade" id="modalAbout" tabindex="-1" role="dialog"> |   <div class="modal fade" id="modalAbout" tabindex="-1"> | ||||||
|     <div class="modal-dialog"> |     <div class="modal-dialog"> | ||||||
|       <div class="modal-content"> |       <div class="modal-content"> | ||||||
|         <div class="modal-header"> |         <div class="modal-header"> | ||||||
| @@ -748,7 +746,7 @@ | |||||||
|     </div> |     </div> | ||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
|   <div class="modal fade" id="modalSaveQueue" tabindex="-1" role="dialog"> |   <div class="modal fade" id="modalSaveQueue" tabindex="-1"> | ||||||
|     <div class="modal-dialog"> |     <div class="modal-dialog"> | ||||||
|       <div class="modal-content"> |       <div class="modal-content"> | ||||||
|         <div class="modal-header"> |         <div class="modal-header"> | ||||||
| @@ -776,7 +774,7 @@ | |||||||
|     </div> |     </div> | ||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
|   <div class="modal fade" id="modalSongDetails" tabindex="-1" role="dialog"> |   <div class="modal fade" id="modalSongDetails" tabindex="-1"> | ||||||
|     <div class="modal-dialog"> |     <div class="modal-dialog"> | ||||||
|       <div class="modal-content"> |       <div class="modal-content"> | ||||||
|         <div class="modal-header"> |         <div class="modal-header"> | ||||||
| @@ -813,6 +811,6 @@ | |||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
|   <script src="/js/bootstrap-native-v4.min.js"></script> |   <script src="/js/bootstrap-native-v4.min.js"></script> | ||||||
|   <script src="/js/mpd.js"></script> |   <script src="/js/mympd.js"></script> | ||||||
|  </body> |  </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -537,7 +537,7 @@ function appInit() { | |||||||
|                 console.log('ServiceWorker registration successful with scope: ', registration.scope); |                 console.log('ServiceWorker registration successful with scope: ', registration.scope); | ||||||
|                 registration.update(); |                 registration.update(); | ||||||
|             }, function(err) { |             }, function(err) { | ||||||
|                 // registration failed :(
 |                 // Registration failed
 | ||||||
|                 console.log('ServiceWorker registration failed: ', err); |                 console.log('ServiceWorker registration failed: ', err); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
| @@ -558,7 +558,7 @@ function appInit() { | |||||||
|     }); |     }); | ||||||
|      |      | ||||||
|     domCache.btnAdd.addEventListener('click', function(event) { |     domCache.btnAdd.addEventListener('click', function(event) { | ||||||
|         // hide our user interface that shows our A2HS button
 |         // Hide our user interface that shows our A2HS button
 | ||||||
|         domCache.btnAdd.classList.add('hide'); |         domCache.btnAdd.classList.add('hide'); | ||||||
|         // Show the prompt
 |         // Show the prompt
 | ||||||
|         deferredPrompt.prompt(); |         deferredPrompt.prompt(); | ||||||
| @@ -746,16 +746,15 @@ function parseStats(obj) { | |||||||
| 
 | 
 | ||||||
| function toggleBtn(btn, state) { | function toggleBtn(btn, state) { | ||||||
|     var b = document.getElementById(btn); |     var b = document.getElementById(btn); | ||||||
|     if (!b) return; |     if (!b) | ||||||
|  |         return; | ||||||
|     if (state == undefined) |     if (state == undefined) | ||||||
|         state = b.classList.contains('active') ? 0 : 1; |         state = b.classList.contains('active') ? 0 : 1; | ||||||
|     if (state == 1) { | 
 | ||||||
|  |     if (state == 1) | ||||||
|         b.classList.add('active'); |         b.classList.add('active'); | ||||||
|         b.setAttribute('aria-pressed','true'); |     else | ||||||
|     } else { |  | ||||||
|         b.classList.remove('active'); |         b.classList.remove('active'); | ||||||
|         b.setAttribute('aria-pressed','false'); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function parseSettings(obj) { | function parseSettings(obj) { | ||||||
| @@ -1785,9 +1784,9 @@ function confirmSettings() { | |||||||
|     var inputCrossfade = document.getElementById('inputCrossfade'); |     var inputCrossfade = document.getElementById('inputCrossfade'); | ||||||
|     if (!inputCrossfade.getAttribute('disabled')) { |     if (!inputCrossfade.getAttribute('disabled')) { | ||||||
|         var value = parseInt(inputCrossfade.value); |         var value = parseInt(inputCrossfade.value); | ||||||
|         if (!isNaN(value)) { |         if (!isNaN(value)) | ||||||
|             inputCrossfade.value = value; |             inputCrossfade.value = value; | ||||||
|         } else { |         else { | ||||||
|             inputCrossfade.classList.add('is-invalid'); |             inputCrossfade.classList.add('is-invalid'); | ||||||
|             formOK = false; |             formOK = false; | ||||||
|         } |         } | ||||||
| @@ -1796,20 +1795,21 @@ function confirmSettings() { | |||||||
|         var inputMixrampdb = document.getElementById('inputMixrampdb'); |         var inputMixrampdb = document.getElementById('inputMixrampdb'); | ||||||
|         if (!inputMixrampdb.getAttribute('disabled')) { |         if (!inputMixrampdb.getAttribute('disabled')) { | ||||||
|             var value = parseFloat(inputMixrampdb.value); |             var value = parseFloat(inputMixrampdb.value); | ||||||
|             if (!isNaN(value)) { |             if (!isNaN(value)) | ||||||
|                 inputMixrampdb.value = value; |                 inputMixrampdb.value = value; | ||||||
|             } else { |             else { | ||||||
|                 inputMixrampdb.classList.add('is-invalid'); |                 inputMixrampdb.classList.add('is-invalid'); | ||||||
|                 formOK = false; |                 formOK = false; | ||||||
|             }  |             }  | ||||||
|         } |         } | ||||||
|         var inputMixrampdelay = document.getElementById('inputMixrampdelay'); |         var inputMixrampdelay = document.getElementById('inputMixrampdelay'); | ||||||
|         if (!inputMixrampdelay.getAttribute('disabled')) { |         if (!inputMixrampdelay.getAttribute('disabled')) { | ||||||
|             if (inputMixrampdelay.value == 'nan') inputMixrampdelay.value = '-1'; |             if (inputMixrampdelay.value == 'nan')  | ||||||
|  |                 inputMixrampdelay.value = '-1'; | ||||||
|             var value = parseFloat(inputMixrampdelay.value); |             var value = parseFloat(inputMixrampdelay.value); | ||||||
|             if (!isNaN(value)) { |             if (!isNaN(value)) | ||||||
|                 inputMixrampdelay.value = value; |                 inputMixrampdelay.value = value; | ||||||
|             } else { |             else { | ||||||
|                 inputMixrampdelay.classList.add('is-invalid'); |                 inputMixrampdelay.classList.add('is-invalid'); | ||||||
|                 formOK = false; |                 formOK = false; | ||||||
|             } |             } | ||||||
| @@ -1831,10 +1831,9 @@ function confirmSettings() { | |||||||
|             "notificationPage": (document.getElementById('btnnotifyPage').classList.contains('active') ? 1 : 0) |             "notificationPage": (document.getElementById('btnnotifyPage').classList.contains('active') ? 1 : 0) | ||||||
|         }}, getSettings); |         }}, getSettings); | ||||||
|         modalSettings.hide(); |         modalSettings.hide(); | ||||||
|     } else { |     } else | ||||||
|         document.getElementById('settingsFrm').classList.add('was-validated'); |         document.getElementById('settingsFrm').classList.add('was-validated'); | ||||||
| } | } | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| function addAllFromBrowse() { | function addAllFromBrowse() { | ||||||
|     sendAPI({"cmd": "MPD_API_ADD_TRACK", "data": {"uri": app.current.search}}); |     sendAPI({"cmd": "MPD_API_ADD_TRACK", "data": {"uri": app.current.search}}); | ||||||
| @@ -1929,7 +1928,9 @@ function hideNotification() { | |||||||
|     if (document.getElementById('alertBox')) { |     if (document.getElementById('alertBox')) { | ||||||
|         document.getElementById('alertBox').classList.remove('alertBoxActive'); |         document.getElementById('alertBox').classList.remove('alertBoxActive'); | ||||||
|         setTimeout(function() { |         setTimeout(function() { | ||||||
|             document.getElementById('alertBox').remove(); |             var alertBox = document.getElementById('alertBox'); | ||||||
|  |             if (alertBox) | ||||||
|  |                 alertBox.remove(); | ||||||
|         }, 600); |         }, 600); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -1956,17 +1957,17 @@ function songChange(obj) { | |||||||
|         pageTitle += obj.data.artist + ' - '; |         pageTitle += obj.data.artist + ' - '; | ||||||
|         domCache.currentArtist.innerText = obj.data.artist; |         domCache.currentArtist.innerText = obj.data.artist; | ||||||
|         domCache.currentArtist.setAttribute('data-albumartist', obj.data.albumartist); |         domCache.currentArtist.setAttribute('data-albumartist', obj.data.albumartist); | ||||||
|     } else { |     } else | ||||||
|         domCache.currentArtist.innerText = ''; |         domCache.currentArtist.innerText = ''; | ||||||
|     } | 
 | ||||||
|     if (typeof obj.data.album != 'undefined' && obj.data.album.length > 0 && obj.data.album != '-') { |     if (typeof obj.data.album != 'undefined' && obj.data.album.length > 0 && obj.data.album != '-') { | ||||||
|         textNotification += ' - ' + obj.data.album; |         textNotification += ' - ' + obj.data.album; | ||||||
|         htmlNotification += '<br/>' + obj.data.album; |         htmlNotification += '<br/>' + obj.data.album; | ||||||
|         domCache.currentAlbum.innerText = obj.data.album; |         domCache.currentAlbum.innerText = obj.data.album; | ||||||
|     } |     } | ||||||
|     else { |     else | ||||||
|         domCache.currentAlbum.innerText = ''; |         domCache.currentAlbum.innerText = ''; | ||||||
|     } | 
 | ||||||
|     if (typeof obj.data.title != 'undefined' && obj.data.title.length > 0) { |     if (typeof obj.data.title != 'undefined' && obj.data.title.length > 0) { | ||||||
|         pageTitle += obj.data.title; |         pageTitle += obj.data.title; | ||||||
|         domCache.currentTrack.innerText = obj.data.title; |         domCache.currentTrack.innerText = obj.data.title; | ||||||
| @@ -1975,7 +1976,9 @@ function songChange(obj) { | |||||||
|         domCache.currentTrack.innerText = ''; |         domCache.currentTrack.innerText = ''; | ||||||
|         domCache.currentTrack.setAttribute('data-uri', ''); |         domCache.currentTrack.setAttribute('data-uri', ''); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|     document.title = pageTitle; |     document.title = pageTitle; | ||||||
|  | 
 | ||||||
|     if (settings.stickers == true) { |     if (settings.stickers == true) { | ||||||
|         setVoteSongBtns(obj.data.like, obj.data.uri); |         setVoteSongBtns(obj.data.like, obj.data.uri); | ||||||
|     } |     } | ||||||
| @@ -2014,9 +2017,9 @@ function doSetFilterLetter(x) { | |||||||
| function addFilterLetter(x) { | function addFilterLetter(x) { | ||||||
|     var filter = '<button class="mr-1 mb-1 btn btn-sm btn-secondary material-icons material-icons-small">delete</button>' + |     var filter = '<button class="mr-1 mb-1 btn btn-sm btn-secondary material-icons material-icons-small">delete</button>' + | ||||||
|         '<button class="mr-1 mb-1 btn btn-sm btn-secondary">#</button>'; |         '<button class="mr-1 mb-1 btn btn-sm btn-secondary">#</button>'; | ||||||
|     for (var i = 65; i <= 90; i++) { |     for (var i = 65; i <= 90; i++) | ||||||
|         filter += '<button class="mr-1 mb-1 btn-sm btn btn-secondary">' + String.fromCharCode(i) + '</button>'; |         filter += '<button class="mr-1 mb-1 btn-sm btn btn-secondary">' + String.fromCharCode(i) + '</button>'; | ||||||
|     } | 
 | ||||||
|     var letters = document.getElementById(x); |     var letters = document.getElementById(x); | ||||||
|     letters.innerHTML = filter; |     letters.innerHTML = filter; | ||||||
|      |      | ||||||
| @@ -7,7 +7,7 @@ | |||||||
|   <meta name="author" content="mail@jcgames.de"> |   <meta name="author" content="mail@jcgames.de"> | ||||||
|   <title>myMPD: Local Player</title> |   <title>myMPD: Local Player</title> | ||||||
|   <link href="css/bootstrap.min.css" rel="stylesheet"> |   <link href="css/bootstrap.min.css" rel="stylesheet"> | ||||||
|   <link href="css/mpd.css" rel="stylesheet"> |   <link href="css/mympd.css" rel="stylesheet"> | ||||||
|   <link href="assets/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon"> |   <link href="assets/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon"> | ||||||
|   <meta name="apple-mobile-web-app-capable" content="yes" /> |   <meta name="apple-mobile-web-app-capable" content="yes" /> | ||||||
|   <meta name="apple-mobile-web-app-status-bar-style" content="black"/> |   <meta name="apple-mobile-web-app-status-bar-style" content="black"/> | ||||||
|   | |||||||
| @@ -3,9 +3,9 @@ var urlsToCache = [ | |||||||
|     '/', |     '/', | ||||||
|     '/player.html', |     '/player.html', | ||||||
|     '/css/bootstrap.min.css', |     '/css/bootstrap.min.css', | ||||||
|     '/css/mpd.css', |     '/css/mympd.css', | ||||||
|     '/js/bootstrap-native-v4.min.js', |     '/js/bootstrap-native-v4.min.js', | ||||||
|     '/js/mpd.js', |     '/js/mympd.js', | ||||||
|     '/js/player.js', |     '/js/player.js', | ||||||
|     '/assets/appicon-167.png', |     '/assets/appicon-167.png', | ||||||
|     '/assets/appicon-192.png', |     '/assets/appicon-192.png', | ||||||
|   | |||||||
							
								
								
									
										24
									
								
								mkrelease.sh
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								mkrelease.sh
									
									
									
									
									
								
							| @@ -7,16 +7,16 @@ then | |||||||
|   echo "Minifying javascript" |   echo "Minifying javascript" | ||||||
|   [ htdocs/js/player.js -nt dist/htdocs/js/player.min.js ] && \ |   [ htdocs/js/player.js -nt dist/htdocs/js/player.min.js ] && \ | ||||||
|     java -jar dist/buildtools/closure-compiler.jar htdocs/js/player.js > dist/htdocs/js/player.min.js |     java -jar dist/buildtools/closure-compiler.jar htdocs/js/player.js > dist/htdocs/js/player.min.js | ||||||
|   [ htdocs/js/mpd.js -nt  dist/htdocs/js/mpd.min.js ] && \ |   [ htdocs/js/mympd.js -nt  dist/htdocs/js/mympd.min.js ] && \ | ||||||
|     java -jar dist/buildtools/closure-compiler.jar htdocs/js/mpd.js > dist/htdocs/js/mpd.min.js |     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 ] && \ |   [ htdocs/sw.js -nt dist/htdocs/sw.min.js ] && \ | ||||||
|     java -jar dist/buildtools/closure-compiler.jar htdocs/sw.js > dist/htdocs/sw.min.js |     java -jar dist/buildtools/closure-compiler.jar htdocs/sw.js > dist/htdocs/sw.min.js | ||||||
| else | else | ||||||
|   echo "dist/buildtools/closure-compiler.jar not found, using non-minified files" |   echo "dist/buildtools/closure-compiler.jar not found, using non-minified files" | ||||||
|   [ htdocs/js/player.js -nt dist/htdocs/js/player.min.js ] && \ |   [ htdocs/js/player.js -nt dist/htdocs/js/player.min.js ] && \ | ||||||
|     cp htdocs/js/player.js dist/htdocs/js/player.min.js |     cp htdocs/js/player.js dist/htdocs/js/player.min.js | ||||||
|   [ htdocs/js/mpd.js -nt  dist/htdocs/js/mpd.min.js ] && \ |   [ htdocs/js/mympd.js -nt  dist/htdocs/js/mympd.min.js ] && \ | ||||||
|     cp htdocs/js/mpd.js  dist/htdocs/js/mpd.min.js |     cp htdocs/js/mympd.js  dist/htdocs/js/mympd.min.js | ||||||
|   [ htdocs/sw.js -nt dist/htdocs/sw.min.js ] && \ |   [ htdocs/sw.js -nt dist/htdocs/sw.min.js ] && \ | ||||||
|     cp htdocs/sw.js dist/htdocs/sw.min.js     |     cp htdocs/sw.js dist/htdocs/sw.min.js     | ||||||
| fi | fi | ||||||
| @@ -24,19 +24,19 @@ fi | |||||||
| if [ -f dist/buildtools/closure-stylesheets.jar ] && [ "$java" != "" ] | if [ -f dist/buildtools/closure-stylesheets.jar ] && [ "$java" != "" ] | ||||||
| then | then | ||||||
|   echo "Minifying stylesheets" |   echo "Minifying stylesheets" | ||||||
|   [ htdocs/css/mpd.css -nt dist/htdocs/css/mpd.min.css ] && \ |   [ htdocs/css/mympd.css -nt dist/htdocs/css/mympd.min.css ] && \ | ||||||
|     java -jar dist/buildtools/closure-stylesheets.jar --allow-unrecognized-properties htdocs/css/mpd.css > dist/htdocs/css/mpd.min.css |     java -jar dist/buildtools/closure-stylesheets.jar --allow-unrecognized-properties htdocs/css/mympd.css > dist/htdocs/css/mympd.min.css | ||||||
| else | else | ||||||
|   echo "dist/buildtools/closure-stylesheets.jar not found, using non-minified files" |   echo "dist/buildtools/closure-stylesheets.jar not found, using non-minified files" | ||||||
|   [ htdocs/css/mpd.css -nt dist/htdocs/css/mpd.min.css ] && \ |   [ htdocs/css/mympd.css -nt dist/htdocs/css/mympd.min.css ] && \ | ||||||
|     cp htdocs/css/mpd.css dist/htdocs/css/mpd.min.css     |     cp htdocs/css/mympd.css dist/htdocs/css/mympd.min.css     | ||||||
| fi | fi | ||||||
|  |  | ||||||
| echo "Replacing javascript and stylesheets with minified files" | echo "Replacing javascript and stylesheets with minified files" | ||||||
| sed -e 's/mpd\.css/mpd\.min\.css/' -e 's/mpd\.js/mpd\.min\.js/' htdocs/index.html > dist/htdocs/index.html | sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' htdocs/index.html > dist/htdocs/index.html | ||||||
| sed -e 's/mpd\.css/mpd\.min\.css/' -e 's/player\.js/player\.min\.js/' htdocs/player.html > dist/htdocs/player.html | sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/player\.js/player\.min\.js/' htdocs/player.html > dist/htdocs/player.html | ||||||
| sed -i -e 's/mpd\.css/mpd\.min\.css/' -e 's/mpd\.js/mpd\.min\.js/' -e 's/player\.js/player\.min\.js/' dist/htdocs/sw.min.js | sed -i -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' -e 's/player\.js/player\.min\.js/' dist/htdocs/sw.min.js | ||||||
| sed -i -e 's/\/sw\.js/\/sw\.min\.js/' dist/htdocs/js/mpd.min.js | sed -i -e 's/\/sw\.js/\/sw\.min\.js/' dist/htdocs/js/mympd.min.js | ||||||
| echo "Minifying html" | echo "Minifying html" | ||||||
| perl -i -pe 's/^\s*//gm; s/\s*$//gm' dist/htdocs/index.html | perl -i -pe 's/^\s*//gm; s/\s*$//gm' dist/htdocs/index.html | ||||||
| perl -i -pe 's/^\s*//gm; s/\s*$//gm' dist/htdocs/player.html | perl -i -pe 's/^\s*//gm; s/\s*$//gm' dist/htdocs/player.html | ||||||
|   | |||||||
| @@ -31,7 +31,6 @@ | |||||||
| #include <libgen.h> | #include <libgen.h> | ||||||
| #include <poll.h> | #include <poll.h> | ||||||
| #include <mpd/client.h> | #include <mpd/client.h> | ||||||
| #include <mpd/message.h> |  | ||||||
|  |  | ||||||
| #include "mpd_client.h" | #include "mpd_client.h" | ||||||
| #include "config.h" | #include "config.h" | ||||||
| @@ -42,7 +41,7 @@ const char * mpd_cmd_strs[] = { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| static inline enum mpd_cmd_ids get_cmd_id(const char *cmd) { | static inline enum mpd_cmd_ids get_cmd_id(const char *cmd) { | ||||||
|     for (int i = 0; i < sizeof(mpd_cmd_strs) / sizeof(mpd_cmd_strs[0]); i ++) |     for (unsigned i = 0; i < sizeof(mpd_cmd_strs) / sizeof(mpd_cmd_strs[0]); i ++) | ||||||
|         if (!strncmp(cmd, mpd_cmd_strs[i], strlen(mpd_cmd_strs[i]))) |         if (!strncmp(cmd, mpd_cmd_strs[i], strlen(mpd_cmd_strs[i]))) | ||||||
|             return i; |             return i; | ||||||
|  |  | ||||||
| @@ -98,10 +97,10 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) { | |||||||
|         case MPD_API_SET_SETTINGS: |         case MPD_API_SET_SETTINGS: | ||||||
|             je = json_scanf(msg.p, msg.len, "{data: {notificationWeb: %d, notificationPage: %d}}", &state.a, &state.b); |             je = json_scanf(msg.p, msg.len, "{data: {notificationWeb: %d, notificationPage: %d}}", &state.a, &state.b); | ||||||
|             if (je == 2) { |             if (je == 2) { | ||||||
|                 char tmpfile[200]; |                 char tmp_file[200]; | ||||||
|                 snprintf(tmpfile,200,"%s.tmp", config.statefile); |                 snprintf(tmp_file, 199, "%s.tmp", config.statefile); | ||||||
|                 json_fprintf(tmpfile, "{notificationWeb: %d, notificationPage: %d}", state.a, state.b); |                 json_fprintf(tmp_file, "{notificationWeb: %d, notificationPage: %d}", state.a, state.b); | ||||||
|                 rename(tmpfile,config.statefile); |                 rename(tmp_file, config.statefile); | ||||||
|             } |             } | ||||||
|              |              | ||||||
|             je = json_scanf(msg.p, msg.len, "{data: {random: %u}}", &uint_buf1); |             je = json_scanf(msg.p, msg.len, "{data: {random: %u}}", &uint_buf1); | ||||||
| @@ -589,6 +588,7 @@ void mympd_idle(struct mg_mgr *s, int timeout) { | |||||||
|  |  | ||||||
| void mympd_get_sticker(const char *uri, t_sticker *sticker) { | void mympd_get_sticker(const char *uri, t_sticker *sticker) { | ||||||
|     struct mpd_pair *pair; |     struct mpd_pair *pair; | ||||||
|  |     char *crap; | ||||||
|     sticker->playCount = 0; |     sticker->playCount = 0; | ||||||
|     sticker->skipCount = 0; |     sticker->skipCount = 0; | ||||||
|     sticker->lastPlayed = 0; |     sticker->lastPlayed = 0; | ||||||
| @@ -596,13 +596,13 @@ void mympd_get_sticker(const char *uri, t_sticker *sticker) { | |||||||
|     if (mpd_send_sticker_list(mpd.conn, "song", uri)) { |     if (mpd_send_sticker_list(mpd.conn, "song", uri)) { | ||||||
|         while ((pair = mpd_recv_sticker(mpd.conn)) != NULL) { |         while ((pair = mpd_recv_sticker(mpd.conn)) != NULL) { | ||||||
|             if (strcmp(pair->name, "playCount") == 0) |             if (strcmp(pair->name, "playCount") == 0) | ||||||
|                 sticker->playCount = atoi(pair->value); |                 sticker->playCount = strtol(pair->value, &crap, 10); | ||||||
|             else if (strcmp(pair->name, "skipCount") == 0) |             else if (strcmp(pair->name, "skipCount") == 0) | ||||||
|                 sticker->skipCount = atoi(pair->value); |                 sticker->skipCount = strtol(pair->value, &crap, 10); | ||||||
|             else if (strcmp(pair->name, "lastPlayed") == 0) |             else if (strcmp(pair->name, "lastPlayed") == 0) | ||||||
|                 sticker->lastPlayed = atoi(pair->value); |                 sticker->lastPlayed = strtol(pair->value, &crap, 10); | ||||||
|             else if (strcmp(pair->name, "like") == 0) |             else if (strcmp(pair->name, "like") == 0) | ||||||
|                 sticker->like = atoi(pair->value); |                 sticker->like = strtol(pair->value, &crap, 10); | ||||||
|             mpd_return_sticker(mpd.conn, pair); |             mpd_return_sticker(mpd.conn, pair); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -619,7 +619,11 @@ char* mympd_get_song_uri_from_song_id(int song_id) { | |||||||
|             str = strdup(mpd_song_get_uri(song)); |             str = strdup(mpd_song_get_uri(song)); | ||||||
|             mpd_song_free(song); |             mpd_song_free(song); | ||||||
|         } |         } | ||||||
|  |         else | ||||||
|  |             return NULL; | ||||||
|     } |     } | ||||||
|  |     else | ||||||
|  |         return NULL; | ||||||
|     return str; |     return str; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -628,13 +632,16 @@ void mympd_count_song_id(int song_id, char *name, int value) { | |||||||
| } | } | ||||||
|  |  | ||||||
| void mympd_count_song_uri(const char *uri, char *name, int value) { | void mympd_count_song_uri(const char *uri, char *name, int value) { | ||||||
|  |     if (uri == NULL) | ||||||
|  |         return; | ||||||
|     struct mpd_pair *pair; |     struct mpd_pair *pair; | ||||||
|  |     char *crap; | ||||||
|     int old_value = 0; |     int old_value = 0; | ||||||
|     char v[4]; |     char v[4]; | ||||||
|     if (mpd_send_sticker_list(mpd.conn, "song", uri)) { |     if (mpd_send_sticker_list(mpd.conn, "song", uri)) { | ||||||
|         while ((pair = mpd_recv_sticker(mpd.conn)) != NULL) { |         while ((pair = mpd_recv_sticker(mpd.conn)) != NULL) { | ||||||
|             if (strcmp(pair->name, name) == 0) |             if (strcmp(pair->name, name) == 0) | ||||||
|                 old_value = atoi(pair->value); |                 old_value = strtol(pair->value, &crap, 10); | ||||||
|             mpd_return_sticker(mpd.conn, pair); |             mpd_return_sticker(mpd.conn, pair); | ||||||
|         } |         } | ||||||
|     }  |     }  | ||||||
| @@ -644,6 +651,9 @@ void mympd_count_song_uri(const char *uri, char *name, int value) { | |||||||
|     else if (old_value < 0) |     else if (old_value < 0) | ||||||
|         old_value = 0; |         old_value = 0; | ||||||
|     snprintf(v, 3, "%d", old_value); |     snprintf(v, 3, "%d", old_value); | ||||||
|  |     #ifdef DEBUG | ||||||
|  |     fprintf(stderr, "STICKER_COUNT_SONG: \"%s\" -> %s: %s\n", uri, name, v); | ||||||
|  |     #endif     | ||||||
|     if (!mpd_run_sticker_set(mpd.conn, "song", uri, name, v)) |     if (!mpd_run_sticker_set(mpd.conn, "song", uri, name, v)) | ||||||
|         LOG_ERROR_AND_RECOVER("mpd_send_sticker_set"); |         LOG_ERROR_AND_RECOVER("mpd_send_sticker_set"); | ||||||
| } | } | ||||||
| @@ -664,6 +674,8 @@ void mympd_last_played_song_id(int song_id) { | |||||||
| } | } | ||||||
|  |  | ||||||
| void mympd_last_played_song_uri(const char *uri) { | void mympd_last_played_song_uri(const char *uri) { | ||||||
|  |     if (uri == NULL) | ||||||
|  |         return; | ||||||
|     char v[20]; |     char v[20]; | ||||||
|     snprintf(v, 19, "%lu", time(NULL)); |     snprintf(v, 19, "%lu", time(NULL)); | ||||||
|     if (!mpd_run_sticker_set(mpd.conn, "song", uri, "lastPlayed", v)) |     if (!mpd_run_sticker_set(mpd.conn, "song", uri, "lastPlayed", v)) | ||||||
| @@ -721,6 +733,8 @@ void mympd_parse_idle(struct mg_mgr *s) { | |||||||
|                 case MPD_IDLE_MESSAGE: |                 case MPD_IDLE_MESSAGE: | ||||||
|                     len = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"update_message\"}"); |                     len = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"update_message\"}"); | ||||||
|                     break; |                     break; | ||||||
|  |                 default: | ||||||
|  |                     len = 0; | ||||||
|             } |             } | ||||||
|             if (len > 0) |             if (len > 0) | ||||||
|                 mympd_notify(s); |                 mympd_notify(s); | ||||||
| @@ -803,7 +817,7 @@ int mympd_put_welcome(char *buffer) { | |||||||
|  |  | ||||||
| int mympd_put_settings(char *buffer) { | int mympd_put_settings(char *buffer) { | ||||||
|     struct mpd_status *status; |     struct mpd_status *status; | ||||||
|     char *replaygain; |     char *replaygain = strdup(""); | ||||||
|     int len; |     int len; | ||||||
|     int je; |     int je; | ||||||
|     struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE); |     struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE); | ||||||
| @@ -827,7 +841,8 @@ int mympd_put_settings(char *buffer) { | |||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     mpd_send_command(mpd.conn, "replay_gain_status", NULL); |     if (!mpd_send_command(mpd.conn, "replay_gain_status", NULL)) | ||||||
|  |         RETURN_ERROR_AND_RECOVER("replay_gain_status"); | ||||||
|     struct mpd_pair *pair; |     struct mpd_pair *pair; | ||||||
|     while ((pair = mpd_recv_pair(mpd.conn)) != NULL) { |     while ((pair = mpd_recv_pair(mpd.conn)) != NULL) { | ||||||
|         replaygain = strdup(pair->value); |         replaygain = strdup(pair->value); | ||||||
| @@ -862,6 +877,7 @@ int mympd_put_settings(char *buffer) { | |||||||
|         state.b |         state.b | ||||||
|     ); |     ); | ||||||
|     mpd_status_free(status); |     mpd_status_free(status); | ||||||
|  |     free(replaygain); | ||||||
|  |  | ||||||
|     if (len > MAX_SIZE) |     if (len > MAX_SIZE) | ||||||
|         fprintf(stderr, "Buffer truncated\n"); |         fprintf(stderr, "Buffer truncated\n"); | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								src/mympd.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/mympd.c
									
									
									
									
									
								
							| @@ -48,8 +48,9 @@ static void handle_api(struct mg_connection *nc, struct http_message *hm) { | |||||||
|         mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nContent-Type: application/json\r\n\r\n"); |         mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nContent-Type: application/json\r\n\r\n"); | ||||||
|  |  | ||||||
|     char buf[1000] = {0}; |     char buf[1000] = {0}; | ||||||
|     memcpy(buf, hm->body.p,sizeof(buf) - 1 < hm->body.len ? sizeof(buf) - 1 : hm->body.len); |     int len = sizeof(buf) - 1 < hm->body.len ? sizeof(buf) - 1 : hm->body.len; | ||||||
|     struct mg_str d = {buf, strlen(buf)}; |     memcpy(buf, hm->body.p, len); | ||||||
|  |     struct mg_str d = {buf, len}; | ||||||
|     callback_mympd(nc, d); |     callback_mympd(nc, d); | ||||||
|  |  | ||||||
|     if (!is_websocket(nc)) |     if (!is_websocket(nc)) | ||||||
| @@ -107,6 +108,7 @@ static void ev_handler_http(struct mg_connection *nc_http, int ev, void *ev_data | |||||||
|  |  | ||||||
| static int inihandler(void* user, const char* section, const char* name, const char* value) { | static int inihandler(void* user, const char* section, const char* name, const char* value) { | ||||||
|     t_config* p_config = (t_config*)user; |     t_config* p_config = (t_config*)user; | ||||||
|  |     char *crap; | ||||||
|  |  | ||||||
|     #define MATCH(n) strcmp(name, n) == 0 |     #define MATCH(n) strcmp(name, n) == 0 | ||||||
|  |  | ||||||
| @@ -115,7 +117,7 @@ static int inihandler(void* user, const char* section, const char* name, const c | |||||||
|     else if (MATCH("mpdhost")) |     else if (MATCH("mpdhost")) | ||||||
|         p_config->mpdhost = strdup(value); |         p_config->mpdhost = strdup(value); | ||||||
|     else if (MATCH("mpdport")) |     else if (MATCH("mpdport")) | ||||||
|         p_config->mpdport = atoi(value); |         p_config->mpdport = strtol(value, &crap, 10); | ||||||
|     else if (MATCH("mpdhost")) |     else if (MATCH("mpdhost")) | ||||||
|         p_config->mpdhost = strdup(value); |         p_config->mpdhost = strdup(value); | ||||||
|     else if (MATCH("mpdpass")) |     else if (MATCH("mpdpass")) | ||||||
| @@ -134,7 +136,7 @@ static int inihandler(void* user, const char* section, const char* name, const c | |||||||
|     else if (MATCH("user")) |     else if (MATCH("user")) | ||||||
|         p_config->user = strdup(value); |         p_config->user = strdup(value); | ||||||
|     else if (MATCH("streamport")) |     else if (MATCH("streamport")) | ||||||
|         p_config->streamport = atoi(value); |         p_config->streamport = strtol(value, &crap, 10); | ||||||
|     else if (MATCH("coverimage")) |     else if (MATCH("coverimage")) | ||||||
|         p_config->coverimage = strdup(value); |         p_config->coverimage = strdup(value); | ||||||
|     else if (MATCH("statefile")) |     else if (MATCH("statefile")) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jcorporation
					jcorporation