From a639264819e5aa74294bbf09f48a8d16060c3444 Mon Sep 17 00:00:00 2001 From: Daniel Wegener Date: Fri, 17 Jun 2016 20:07:10 +0200 Subject: [PATCH] Let PushStream use Ssl/wss if site is accessed via https. --- assets/js/runeui.js | 6 ++++++ assets/js/runeui.min.js | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/assets/js/runeui.js b/assets/js/runeui.js index 31724a66..043eb6b0 100755 --- a/assets/js/runeui.js +++ b/assets/js/runeui.js @@ -1443,6 +1443,7 @@ function nicsDetails(text) { // open the Playback UI refresh channel function playbackChannel(){ var pushstream = new PushStream({ + useSSL: window.location.protocol === "https:", host: window.location.hostname, port: window.location.port, modes: GUI.mode, @@ -1473,6 +1474,7 @@ function playbackChannel(){ // open the playing queue channel function queueChannel(){ var pushstream = new PushStream({ + useSSL: window.location.protocol === "https:", host: window.location.hostname, port: window.location.port, modes: GUI.mode @@ -1489,6 +1491,7 @@ function queueChannel(){ // open the library channel function libraryChannel(){ var pushstream = new PushStream({ + useSSL: window.location.protocol === "https:", host: window.location.hostname, port: window.location.port, modes: GUI.mode @@ -1501,6 +1504,7 @@ function libraryChannel(){ // open the notify messages channel function notifyChannel(){ var pushstream = new PushStream({ + useSSL: window.location.protocol === "https:", host: window.location.hostname, port: window.location.port, modes: GUI.mode @@ -1513,6 +1517,7 @@ function notifyChannel(){ // open the in range Wi-Fi networks list channel function wlansChannel(){ var pushstream = new PushStream({ + useSSL: window.location.protocol === "https:", host: window.location.hostname, port: window.location.port, modes: GUI.mode @@ -1526,6 +1531,7 @@ function wlansChannel(){ // open the NIC details channel function nicsChannel(){ var pushstream = new PushStream({ + useSSL: window.location.protocol === "https:", host: window.location.hostname, port: window.location.port, modes: GUI.mode diff --git a/assets/js/runeui.min.js b/assets/js/runeui.min.js index 3818ed3c..dc0b6e45 100644 --- a/assets/js/runeui.min.js +++ b/assets/js/runeui.min.js @@ -1,2 +1,2 @@ -function sendCmd(a){var b=new XMLHttpRequest;b.open("GET","/command/?cmd="+a,!0),b.onreadystatechange=function(){4===this.readyState&&this.status>=200&&this.status<400},b.send(),b=null}function checkWebSocket(){return window.WebSocket?"websocket":"longpolling"}function checkWorkers(){return window.Worker&&window.Blob||Modernizr.webworkers&&Modernizr.blobconstructor?!0:!1}function parsePath(a){var b=a&&a.length?a.lastIndexOf("/"):0,c="";return b&&-1!==b&&(c=a.slice(0,b)),c}function refreshTimer(a,b,c){var d=$("#countdown-display");d.countdown("destroy"),d.countdown({since:"stop"!==c||void 0!==c?-a:0,compact:!0,format:"MS"}),"play"!==c&&d.countdown("pause")}function refreshKnob(){window.clearInterval(GUI.currentKnob);var a=10*parseInt(GUI.json.song_percent),b=parseInt(GUI.json.time),c=parseInt(1e3/b),d=$("#time");d.val(a,!1).trigger("update"),"play"===GUI.state&&(GUI.currentKnob=setInterval(function(){a+="visible"!==GUI.visibility?c:1,d.val(a,!1).trigger("update")},b))}function timeConvert(a){var b=Math.floor(a/60);a-=60*b;var c=10>b?"0"+b:b,d=10>a?"0"+a:a;return c+":"+d}function timeConvert2(a){var b=Math.floor(a/3600),c=Math.floor((a-3600*b)/60);return a=Math.floor(a-3600*b-60*c),b>0?(10>b&&(b="0"+b),b+=":"):b="",10>c&&(c="0"+c),10>a&&(a="0"+a),b+c+":"+a}function countdownRestart(a){var b=$("#countdown-display").countdown("destroy");b.countdown({since:-a,compact:!0,format:"MS"})}function setvol(a){$("#volume").val(a,!1).trigger("update"),GUI.volume=a,$("#volumemute").removeClass("btn-primary"),sendCmd("setvol "+a)}function volumeStepCalc(a){var b=0;GUI.volume=parseInt($("#volume").val());var c=function(){b++,"up"===a?GUI.stepVolumeDelta=parseInt(GUI.volume)+b:"dn"===a&&(GUI.stepVolumeDelta=parseInt(GUI.volume)-b),$("#volume").val(GUI.stepVolumeDelta).trigger("change")};c(),GUI.stepVolumeInt=window.setInterval(function(){c()},200)}function volumeStepSet(){window.clearInterval(GUI.stepVolumeInt),setvol(GUI.stepVolumeDelta)}function customScroll(a,b,c){"undefined"==typeof c&&(c=500);var d=49,e=parseInt($(window).height()/2),f=$(window).scrollTop(),g=0,h=0;"db"===a?(g=parseInt(b*d-e),h=g):"pl"===a&&(g=parseInt((b+2)*d-e),h=Math.abs(g-f),h=(g>f?"+":"-")+"="+h+"px",$("#playlist-entries").find("li").eq(b).addClass("active")),$.scrollTo(g>0?h:0,c)}function randomScrollPL(){var a=$(".playlist li").size(),b=1+Math.floor(Math.random()*a);customScroll("pl",b)}function randomScrollDB(){var a=$(".database li").size(),b=1+Math.floor(Math.random()*a);customScroll("db",b)}function toggleLoader(a){"close"===a?$("#loader").addClass("hide"):$("#section-dev").length?($("#loader").addClass("hide"),new PNotify({title:"Warning",text:"The loading layer (spinning arrows) points to a socket error",icon:"fa fa-exclamation-circle"})):$("#loader").removeClass("hide")}function customNotify(a){"kernelswitch"===a.custom&&(void 0!==GUI.noticeUI.kernelswitch&&GUI.noticeUI.kernelswitch.remove(),GUI.noticeUI.kernelswitch=new PNotify({title:"title"in a?a.title:"[missing title]",text:"text"in a?a.text:"[missing text]",icon:"fa fa-refresh",hide:!1,confirm:{confirm:!0,buttons:[{text:a.btntext,addClass:"btn-default btn-block uppercase",click:function(){$.post("/settings/",{syscmd:"reboot"}),toggleLoader()}},{text:"Cancel",addClass:"hide"}]},buttons:{closer:!1,sticker:!1}}))}function renderMSG(a){var b=a[0];if("custom"in b&&null!==b.custom)return void customNotify(b);var c={title:"title"in b?b.title:"[missing title]",text:"text"in b?b.text:"[missing text]",icon:void 0===b.icon?"fa fa-check":b.icon,opacity:void 0===b.opacity?.9:b.opacity,hide:void 0===b.hide&&void 0===b.permanotice,buttons:{closer:void 0===b.permanotice,sticker:void 0===b.permanotice},delay:void 0===b.delay?8e3:b.delay,mouse_reset:!1};"permanotice"in b?void 0===GUI.noticeUI[b.permanotice]?GUI.noticeUI[b.permanotice]=new PNotify(c):"permaremove"in b?(GUI.noticeUI[b.permanotice].remove(),GUI.noticeUI[b.permanotice]=void 0):GUI.noticeUI[b.permanotice].open():new PNotify(c)}function sortOrder(a){var b=$("#"+a).index();a=parseInt(a.replace("pl-","")),sendCmd("moveid "+a+" "+b)}function loadingSpinner(a,b){"hide"===b?("db"===a&&$("#spinner-db").addClass("hide"),"pl"===a&&$("#spinner-pl").addClass("hide")):("db"===a&&$("#spinner-db").removeClass("hide"),"pl"===a&&$("#spinner-pl").removeClass("hide"))}function setPlaybackSource(){var a=GUI.libraryhome.ActivePlayer;$("#overlay-playsource-open button").text(a),$("#overlay-playsource a").addClass("inactive");var b=a.toLowerCase();$("#playsource-"+b).removeClass("inactive"),"Spotify"===a||"Airplay"===a?($("#volume").trigger("configure",{readOnly:!0,fgColor:"#1A242F"}).css({color:"#1A242F"}),$(".volume button").prop("disabled",!0),$("#single").addClass("disabled")):($("#volume").trigger("configure",{readOnly:!1,fgColor:"#0095D8"}).css({color:"#0095D8"}),$(".volume button").prop("disabled",!1),$("#single").removeClass("disabled")),$("#playlist-entries").removeClass(function(a,b){return(b.match(/(^|\s)playlist-\S+/g)||[]).join(" ")}).addClass("playlist-"+b),$("#pl-manage").removeClass(function(a,b){return(b.match(/(^|\s)pl-manage-\S+/g)||[]).join(" ")}).addClass("pl-manage-"+b)}function chkKey(a){return void 0!==a&&""!==a}function renderLibraryHome(){loadingSpinner("db"),$("#database-entries").addClass("hide"),$("#db-level-up").addClass("hide"),$("#db-homeSetup").removeClass("hide").removeClass("btn-primary").addClass("btn-default"),$("#home-blocks").removeClass("hide");var a=GUI.libraryhome,b=0,c="",d='
',e="
",f="",g="",h="Spotify"===a.ActivePlayer||"Airplay"===a.ActivePlayer;for(c='

Browse your library

',setPlaybackSource(),h&&(f=" inactive"),b=0;bookmark=a.bookmarks[b];b+=1)c+=d+'

'+bookmark.name+"

bookmark
"+e;chkKey(a.networkMounts)&&(c+=0===a.networkMounts?h?d+'

Network mounts (0)

network attached storages
'+e:d+'

Network mounts (0)

click to add some
'+e:d+'

Network mounts ('+a.networkMounts+")

network attached storages
"+e),chkKey(a.localStorages)&&(c+=0===a.localStorages?"":d+'

LocalStorage ('+a.localStorages+")

locally stored music
"+e),chkKey(a.USBMounts)&&(c+=0===a.USBMounts?h?d+'

USB storage (0)

no USB storage plugged
'+e:d+'

USB storage (0)

no USB storage plugged
'+e:d+'

USB storage ('+a.USBMounts+")

USB attached drives
"+e),chkKey(a.webradio)&&(c+=0===a.webradio?h?d+'

My Webradios (0)

webradio local playlists
'+e:d+'

My Webradios (0)

click to add some
'+e:d+'

My Webradios ('+a.webradio+")

webradio local playlists
"+e),chkKey(a.Spotify)&&(c+="0"===a.Spotify?d+'

Spotify

click to configure
'+e:"Spotify"!==a.ActivePlayer?d+'

Spotify

click to switch renderer
'+e:d+'

Spotify

music for everyone
'+e),chkKey(a.Dirble)&&(c+=d+'

Dirble ('+a.Dirble+")

radio stations open directory
"+e),c+=d+'

Jamendo

world\'s largest platform for free music
'+e,c+=d+'

Albums

browse MPD database by album
'+e,c+=d+'

Artists

browse MPD database by artist
'+e,c+=d+'

Genres

browse MPD database by genre
'+e,c+="",document.getElementById("home-blocks").innerHTML=c,loadingSpinner("db","hide"),$("span","#db-currentpath").html("")}function refreshState(){var a=GUI.state;if("play"===a?($("#play").addClass("btn-primary"),$("i","#play").removeClass("fa fa-pause").addClass("fa fa-play"),$("#stop").removeClass("btn-primary")):"pause"===a?($("#playlist-position span").html("Not playing"),$("#play").addClass("btn-primary"),$("i","#play").removeClass("fa fa-play").addClass("fa fa-pause"),$("#stop").removeClass("btn-primary")):"stop"===a&&($("#play").removeClass("btn-primary"),$("i","#play").removeClass("fa fa-pause").addClass("fa fa-play"),$("#stop").addClass("btn-primary"),$("#section-index").length&&$("#countdown-display").countdown("destroy"),$("#total").html("radio"===GUI.stream?"":"00:00"),$("#time").val(0,!1).trigger("update"),$("#format-bitrate").html(" "),$("li","#playlist-entries").removeClass("active")),"stop"!==a){$("#total").html("radio"===GUI.stream?"":void 0!==GUI.json.time?timeConvert(GUI.json.time):"00:00");var b=GUI.json.audio_channels&&GUI.json.audio_sample_depth&&GUI.json.audio_sample_rate?GUI.json.audio_channels+", "+GUI.json.audio_sample_depth+" bit, "+GUI.json.audio_sample_rate+" kHz, "+GUI.json.bitrate+" kbps":" ";$("#format-bitrate").html(b),$("li","#playlist-entries").removeClass("active");var c=parseInt(GUI.json.song);$("#playlist-entries").find("li").eq(c).addClass("active")}$("#playlist-position span").html(GUI.json.playlistlength&&"0"!==GUI.json.playlistlength?GUI.json.song?"Playlist position "+(parseInt(GUI.json.song)+1)+"/"+GUI.json.playlistlength:"Playlist position 1/"+GUI.json.playlistlength:"Empty queue, add some music!"),$("a","#open-panel-sx").html(void 0!==GUI.json.updating_db?' Updating':' Library')}function updateGUI(){var a=GUI.json.volume,b=GUI.json.radioname,c=GUI.json.currentartist,d=GUI.json.currentsong,e=GUI.json.currentalbum;if(GUI.stream=null!==b&&void 0!==b&&""!==b?"radio":"",refreshState(),$("#section-index").length){if(GUI.currentsong!==GUI.json.currentsong&&(countdownRestart(0),$("#panel-dx").hasClass("active"))){var f=parseInt(GUI.json.song);customScroll("pl",f)}$("#volume").val("-1"===a?100:a,!1).trigger("update"),"radio"!==GUI.stream?($("#currentartist").html(null===c||void 0===c||""===c?'[no artist]':c),$("#currentsong").html(null===d||void 0===d||""===d?'[no title]':d),$("#currentalbum").html(null===e||void 0===e||""===e?'[no album]':e)):($("#currentartist").html(null===c||void 0===c||""===c?b:c),$("#currentsong").html(null===d||void 0===d||""===d?b:d),$("#currentalbum").html('streaming')),"1"===GUI.json.repeat?$("#repeat").addClass("btn-primary"):$("#repeat").removeClass("btn-primary"),"1"===GUI.json.random?$("#random").addClass("btn-primary"):$("#random").removeClass("btn-primary"),"1"===GUI.json.consume?$("#consume").addClass("btn-primary"):$("#consume").removeClass("btn-primary"),"1"===GUI.json.single?$("#single").addClass("btn-primary"):$("#single").removeClass("btn-primary"),GUI.currentsong=d;var g=c+" - "+e;if(GUI.currentalbum!==g)if(null===b||void 0===b||""===b){var h=Math.floor(1001*Math.random());$("#cover-art").css("background-image","url(/coverart/?v="+h+")")}else $("#cover-art").css("background-image","url(assets/img/cover-radio.jpg");GUI.currentalbum=g}}function getPlaylistPlain(a){var b,c,d=parseInt(GUI.json.song)+1,e=GUI.json.state,f="",g="",h="",i="",j="",k="",l="",m="",n="",o="",p="",q="",r=0,s=a.split("\n"),t=[];for(b=0;c=s[b];b+=1)t=c.split(": "),"Time"===t[0]?g=parseInt(t[1]):"Artist"===t[0]?h=t[1]:"Title"===t[0]?j=t[1]:"Name"===t[0]?k=t[1]:"Album"===t[0]?i=t[1]:"file"===t[0]?l=t[1]:"Id"===t[0]&&(o=t[1],""===j||""===i?(n=parsePath(l),m=l.split("/").pop(),j=m,p=""===h?"path: "+n:h):p=h+" - "+i,""!==k?(j=''+k,p=l,q=""):q=""+timeConvert2(g)+"",r++,f+='
  • '+j+q+''+p+"
  • ",g="",h="",i="",j="",k="");$(".playlist").addClass("hide"),$("#playlist-entries").removeClass("hide");var u=document.getElementById("playlist-entries");u&&(u.innerHTML=f),$("#pl-filter-results").addClass("hide").html(""),$("#pl-filter").val(""),$("#pl-manage").removeClass("hide"),$("#pl-count").removeClass("hide").html(r+(1!==r?" entries":" entry"))}function getPlaylistCmd(){loadingSpinner("pl"),$.ajax({url:"/db/?cmd=playlist",success:function(a){if(a.length>4){$(".playlist").addClass("hide"),$("#playlist-entries").removeClass("hide"),getPlaylistPlain(a);var b=parseInt(GUI.json.song);$("#panel-dx").hasClass("active")&&GUI.currentsong!==GUI.json.currentsong&&customScroll("pl",b,200)}else $(".playlist").addClass("hide"),$("#playlist-warning").removeClass("hide"),$("#pl-filter-results").addClass("hide").html(""),$("#pl-count").removeClass("hide").html("0 entries");loadingSpinner("pl","hide")}})}function getPlaylist(a){if(data=a[0],data.length>4){$(".playlist").addClass("hide"),$("#playlist-entries").removeClass("hide"),getPlaylistPlain(data);var b=parseInt(GUI.json.song);$("#panel-dx").hasClass("active")&&GUI.currentsong!==GUI.json.currentsong&&customScroll("pl",b,200)}else $(".playlist").addClass("hide"),$("#playlist-warning").removeClass("hide"),$("#pl-filter-results").addClass("hide").html(""),$("#pl-count").removeClass("hide").html("0 entries");loadingSpinner("pl","hide")}function renderUI(a){if(toggleLoader("close"),GUI.json=a[0],GUI.state=GUI.json.state,updateGUI(),$("#section-index").length){var b=""!==GUI.json.elapsed&&void 0!==GUI.json.elapsed?GUI.json.elapsed:0,c=""!==GUI.json.time&&void 0!==GUI.json.time&&null!==GUI.json.time?GUI.json.time:0;refreshTimer(parseInt(b),parseInt(c),GUI.json.state),"radio"!==GUI.stream?refreshKnob():$("#time").val(0,!1).trigger("update"),GUI.json.playlist!==GUI.playlist&&(getPlaylistCmd(),GUI.playlist=GUI.json.playlist)}}function renderPlaylists(a){var b,c,d="",e="",f=a.split("\n"),g=[];for(b=0;c=f[b];b+=1)g=c.split(": "),"playlist"===g[0]&&(e=g[1],d+='
  • '+e+"
  • ",e="");document.getElementById("playlist-entries").innerHTML="",$(".playlist").addClass("hide"),$("#pl-manage").addClass("hide"),$("#pl-count").addClass("hide"),$("#pl-filter-results").removeClass("hide").addClass("back-to-queue").html(' to queue'),$("#pl-currentpath").removeClass("hide"),$("#pl-editor").removeClass("hide"),document.getElementById("pl-editor").innerHTML=d,loadingSpinner("pl","hide")}function getPlaylists(){loadingSpinner("pl"),$.ajax({url:"/command/?cmd=listplaylists",success:function(a){renderPlaylists(a)}})}function parseResponse(a){var b=a.inputArr||"",c=a.respType||"",d=a.i||0,e=a.inpath||"",f=a.querytype||"",g="";switch(c){case"playlist":break;case"db":"file"===GUI.browsemode?(""===e&&void 0!==b.file&&(e=parsePath(b.file)),void 0!==b.file||"Webradio"===e?(g='
  • ',g+=b.Title+" "+timeConvert(b.Time)+"",g+=' ',g+=b.Artist,g+=" - ",g+=b.Album):"Webradio"!==e?(g+=b.file,g+='">',g+=b.file.replace(e+"/","")+" "+timeConvert(b.Time)+"",g+='',g+=" path: ",g+=e):(g+=b.playlist,g+='">',g+=''+b.playlist.replace(e+"/","").replace("."+b.fileext,""),g+='webradio'),g+="
  • "):void 0!==b.playlist?"cue"===b.fileext&&(g='
  • ',g+=b.playlist.replace(e+"/","")+" [CUE file]",g+='',g+=" path: ",g+=e,g+="
  • "):(g='
  • ':'">',g+=b.directory.replace(e+"/",""),g+="
  • ")):"album"===GUI.browsemode||"albumfilter"===GUI.browsemode?void 0!==b.file?(g='
  • ',g+=b.Title+" "+timeConvert(b.Time)+"",g+=' ',g+=b.Artist,g+=" - ",g+=b.Album,g+="
  • "):""!==b.album&&(g='
  • "):"artist"===GUI.browsemode?void 0!==b.album?(g='
  • ',g+=""!==b.album?b.album:"Unknown album",g+="
  • "):""!==b.artist&&(g='
  • ',g+=b.artist,g+="
  • "):"genre"===GUI.browsemode&&(void 0!==b.artist?(g='
  • ',g+=""!==b.artist?b.artist:"Unknown artist",g+="
  • "):""!==b.genre&&(g='
  • ',g+=b.genre,g+="
  • "));break;case"Spotify":""===f?(g='
  • ',g+=""!==b.name?b.name:"Favorites",g+=" (",g+=b.tracks,g+=")
  • "):"tracks"===f&&(g='
  • ',g+=b.title+" "+timeConvert(b.duration/1e3)+"",g+=' ',g+=b.artist,g+=" - ",g+=b.album,g+="
  • ");break;case"Dirble":""===f?(g='
  • ',g+=b.name,g+="
  • "):"stations"===f&&(g='
  • "+b.bitrate+"",g+='',g+=b.website,g+="
  • ");break;case"Jamendo":g='
  • ',g+=b.dispname+"
  • "}return g}function populateDB(a){var b=a.data||"",c=a.path||"",d=a.uplevel||0,e=a.keyword||"",f=a.plugin||"",g=a.querytype||"",h=a.args||"",i="",j=0,k=[];if(""!==f){if("Spotify"===f){for($("#database-entries").removeClass("hide"),$("#db-level-up").removeClass("hide"),$("#home-blocks").addClass("hide"),c&&(GUI.currentpath=c),document.getElementById("database-entries").innerHTML="",b="tracks"===g?b.tracks:b.playlists,j=0;k=b[j];j+=1)i+=parseResponse({inputArr:k,respType:"Spotify",i:j,querytype:g,inpath:h});document.getElementById("database-entries").innerHTML=i}if("Dirble"===f){for($("#database-entries").removeClass("hide"),$("#db-level-up").removeClass("hide"),$("#home-blocks").addClass("hide"),c&&(GUI.currentpath=c),document.getElementById("database-entries").innerHTML="",j=0;k=b[j];j+=1)i+=parseResponse({inputArr:k,respType:"Dirble",i:j,querytype:g});document.getElementById("database-entries").innerHTML=i}if("Jamendo"===f){for($("#database-entries").removeClass("hide"),$("#db-level-up").removeClass("hide"),$("#home-blocks").addClass("hide"),c&&(GUI.currentpath=c),document.getElementById("database-entries").innerHTML="",j=0;k=b[j];j+=1)i+=parseResponse({inputArr:k,respType:"Jamendo",i:j,querytype:g});document.getElementById("database-entries").innerHTML=i}}else{if(""===c&&""===e)return void renderLibraryHome();if($("#database-entries").removeClass("hide"),$("#db-level-up").removeClass("hide"),$("#home-blocks").addClass("hide"),c&&(GUI.currentpath=c),document.getElementById("database-entries").innerHTML="",""!==e){var l=b.length?b.length:"0",m=1===b.length?"":"s";$("#db-level-up").addClass("hide"),$("#db-search-results").removeClass("hide").html('back')}for(j=0;k=b[j];j+=1)i+=parseResponse({inputArr:k,respType:"db",i:j,inpath:c});"Webradio"===c&&(i+='
  • add newadd a webradio to your library
  • '),document.getElementById("database-entries").innerHTML=i}var n=$("span","#db-currentpath");if(n.html("album"===GUI.browsemode?"Albums"===c?c:"Albums/"+c:"artist"===GUI.browsemode?"Artists"===c?c:"Artists/"+c:"genre"===GUI.browsemode?"Genres"===c?c:"Genres/"+c:c),$("#db-homeSetup").addClass("hide"),d){var o=GUI.currentDBpos[GUI.currentDBpos[10]];$("#db-"+o).addClass("active"),customScroll("db",o,0)}else customScroll("db",0,0);loadingSpinner("db","hide")}function getDB(a){var b=a.cmd||"browse",c=a.path||"",d=a.browsemode||"file",e=a.uplevel||"",f=a.plugin||"",g=a.querytype||"",h=a.args||"";if(loadingSpinner("db"),GUI.browsemode=d,""!==f)"Spotify"===f?$.post("/db/?cmd=spotify",{plid:h},function(a){populateDB({data:a,path:c,plugin:f,querytype:g,uplevel:e,args:h})},"json"):"Dirble"===f?$.post("/db/?cmd=dirble",{querytype:""===g?"categories":g,args:h},function(a){populateDB({data:a,path:c,plugin:f,querytype:g,uplevel:e})},"json"):"Jamendo"===f&&$.post("/db/?cmd=jamendo",{querytype:""===g?"radio":g,args:h},function(a){populateDB({data:a.results,path:c,plugin:f,querytype:g})},"json");else if("search"===b){var i=$("#db-search-keyword").val();$.post("/db/?querytype="+GUI.browsemode+"&cmd=search",{query:i},function(a){populateDB({data:a,path:c,uplevel:e,keyword:i})},"json")}else"browse"===b?$.post("/db/?cmd=browse",{path:c,browsemode:GUI.browsemode},function(a){populateDB({data:a,path:c,uplevel:e})},"json"):(loadingSpinner("db","hide"),$.post("/db/?cmd="+b,{path:c,querytype:g},function(){},"json"))}function onreleaseKnob(a){if("stop"!==GUI.state&&""!==GUI.state)if("radio"!==GUI.stream){window.clearInterval(GUI.currentKnob);var b=Math.floor(a*parseInt(GUI.json.time)/1e3);sendCmd("seek "+GUI.json.song+" "+b),$("#time").val(a),$("#countdown-display").countdown("destroy"),$("#countdown-display").countdown({since:-b,compact:!0,format:"MS"})}else $("#time").val(0).trigger("change")}function commandButton(a){var b,c=a.data("cmd");if("stop"===c)a.addClass("btn-primary"),$("#play").removeClass("btn-primary"),$("#section-index").length&&(refreshTimer(0,0,"stop"),window.clearInterval(GUI.currentKnob),$(".playlist").find("li").removeClass("active"),$("#total").html("00:00"));else{if("play"===c){var d=GUI.state;return"play"===d?(b="pause",$("#section-index").length&&$("#countdown-display").countdown("pause")):"pause"===d?(b="play",$("#section-index").length&&$("#countdown-display").countdown("resume")):"stop"===d&&(b="play",$("#section-index").length&&$("#countdown-display").countdown({since:0,compact:!0,format:"MS"})),window.clearInterval(GUI.currentKnob),void sendCmd(b)}if("previous"===c||"next"===c)$("#section-index").length&&($("#countdown-display").countdown("pause"),window.clearInterval(GUI.currentKnob));else if(a.hasClass("btn-volume")){var e,f=parseInt($("#volume").val());return null===GUI.volume&&(GUI.volume=f),"volumedn"===c&&parseInt(GUI.volume)>0?(e=parseInt(GUI.volume)-1,GUI.volume=e,$("#volumemute").removeClass("btn-primary")):"volumeup"===c&&parseInt(GUI.volume)<100?(e=parseInt(GUI.volume)+1,GUI.volume=e,$("#volumemute").removeClass("btn-primary")):"volumemute"===c&&(0!==f?(GUI.volume=f,a.addClass("btn-primary"),e=0):(a.removeClass("btn-primary"),setvol(GUI.volume))),void(e>=0&&100>=e&&sendCmd("setvol "+e))}}a.hasClass("btn-toggle")?(b=c+(a.hasClass("btn-primary")?" 0":" 1"),a.toggleClass("btn-primary")):b=c,sendCmd(b)}function libraryHome(a){GUI.libraryhome=a[0],renderLibraryHome()}function listWLANs(a){var b="",c="",d="",e=a[0];$.each(e,function(a){b+='

    ',0!==e[a].connected&&(b+=''),1===e[a].storedprofile&&"on"===e[a].encryption?b+='':"on"===e[a].encryption?b+='':1!==e[a].storedprofile&&(b+=''),b+=""+e[a].ESSID+"

    ",1===e[a].storedprofile?d+=b:c+=b,b=""}),""===c&&(c='

    scanning for networks...

    '),document.getElementById("wifiNetworks").innerHTML=c,document.getElementById("wifiStored").innerHTML=d,$.ajax({url:"/command/?cmd=wifiscan"})}function nicsDetails(a){var b="",c=a[0];$.each(c,function(a){a===$("#nic-details").data("name")&&(b+="Name:"+a+"",b+="Type:wireless","off/any"===c[a].currentssid?b+='Status:no network connected':(b+='Status:connected',b+="Associated SSID:"+c[a].currentssid+""),b+="Assigned IP:"+(null!==c[a].ip?""+c[a].ip+"":"none")+"",b+="Speed:"+(null!==c[a].speed?c[a].speed:"unknown")+"")}),$("#nic-details tbody").html(b)}function playbackChannel(){var a=new PushStream({host:window.location.hostname,port:window.location.port,modes:GUI.mode,reconnectOnChannelUnavailableInterval:5e3});a.onmessage=renderUI,a.onstatuschange=function(a){2===a?($("#loader").addClass("hide"),sendCmd("renderui")):0===a&&toggleLoader()},a.addChannel("playback"),a.connect()}function queueChannel(){var a=new PushStream({host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=getPlaylist,a.addChannel("queue"),a.connect()}function libraryChannel(){var a=new PushStream({host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=libraryHome,a.addChannel("library"),a.connect()}function notifyChannel(){var a=new PushStream({host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=renderMSG,a.addChannel("notify"),a.connect()}function wlansChannel(){var a=new PushStream({host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=listWLANs,a.addChannel("wlans"),a.connect(),$.ajax({url:"/command/?cmd=wifiscan"})}function nicsChannel(){var a=new PushStream({host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=nicsDetails,a.addChannel("nics"),a.connect()}function overlayTrigger(a){function b(){if(c.hasClass("open")){c.removeClass("open"),c.addClass("closed")}else if(c.hasClass("closed")&&(c.addClass("open"),"#overlay-social"===a)){var b="https://twitter.com/home?status=Listening+to+"+GUI.json.currentsong.replace(/\s+/g,"+")+"+by+"+GUI.json.currentartist.replace(/\s+/g,"+")+"+on+%40RuneAudio+http%3A%2F%2Fwww.runeaudio.com%2F+%23nowplaying",d="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.runeaudio.com%2F&display=popup",e="https://plus.google.com/share?url=http%3A%2F%2Fwww.runeaudio.com%2F";$("#urlTwitter").attr("href",b),$("#urlFacebook").attr("href",d),$("#urlGooglePlus").attr("href",e)}}var c=$(a),d=$(a+"-open"),e=$(a+"-close");transEndEventNames={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"},d.click(function(){b()}),e.click(function(){b()})}function getHiddenProp(){var a=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var b=0;bback')):(a("#pl-count").removeClass("hide"),a("#pl-filter-results").addClass("hide").html(""))}),a("#pl-filter-results").click(function(){a(this).addClass("hide"),a("#pl-count").removeClass("hide"),a(this).hasClass("back-to-queue")?(a(".playlist").addClass("hide"),getPlaylistCmd(),a("#pl-currentpath").addClass("hide"),a("#pl-manage").removeClass("hide")):(a("li","#playlist-entries").each(function(){var b=a(this);b.show()}),a("#pl-currentpath").removeClass("hide"),a("#pl-filter").val("")),customScroll("pl",parseInt(GUI.json.song),500)}),a("#pl-manage-list").click(function(){getPlaylists()}),a("#modal-pl-save-btn").click(function(){var b=a("#pl-save-name").val();sendCmd('save "'+b+'"')}),a("#pl-editor").on("click",".pl-action",function(b){b.preventDefault();var c=a(this).parent().attr("data-path");GUI.DBentry[0]=c}),a("#pl-rename-button").click(function(){var b=a("#pl-rename-oldname").text(),c=a("#pl-rename-name").val();sendCmd('rename "'+b+'" "'+c+'"'),getPlaylists()});var e=document.getElementById("playlist-entries");new Sortable(e,{ghostClass:"sortable-ghost",onUpdate:function(a){sortOrder(a.item.getAttribute("id"))}}),a("a","#open-panel-sx").click(function(){a("#open-panel-sx").hasClass("active")&&customScroll("pl",parseInt(GUI.json.song),500)}).on("shown.bs.tab",function(){customScroll("db",GUI.currentDBpos[GUI.currentDBpos[10]],0)}),a("#home-blocks").on("click",".home-block",function(b){if(a(this).hasClass("inactive"))a("#overlay-playsource-open").trigger("click");else if(a(this).is("#home-spotify-switch"))a("#overlay-playsource-open").trigger("click");else if(a(b.target).is("span.block-remove")){var c=a(this).attr("id");c=c.replace("home-bookmark-","");var d=a(this).find("h3").text();a.post("/db/?cmd=bookmark",{id:c,name:d})}else++GUI.currentDBpos[10],getDB({browsemode:a(this).data("browsemode"),path:a(this).data("path"),uplevel:0,plugin:a(this).data("plugin")})}),a("#db-homeSetup").click(function(){var b=a(this);b.hasClass("btn-primary")?(b.removeClass("btn-primary").addClass("btn-default"),a(".home-block-remove").remove()):(b.removeClass("btn-default").addClass("btn-primary"),a(".home-block.home-bookmark").append('
    ×
    '))});var f=a("#database-entries");f.on("click","li",function(b){var c="",d="",e=a(this);if(a(b.target).hasClass("db-action"))b.preventDefault(),c="spotify-track"===e.data("type")?e.data("plid")+"-"+e.data("path"):e.data("path"),GUI.DBentry[0]=c;else if(a("li.active","#database-entries").removeClass("active"),e.addClass("active"),e.hasClass("db-folder")){c=e.data("path"),e.hasClass("db-album")?""!==c?getDB({path:c,uplevel:0,browsemode:"album"}):(c=GUI.currentDBpath[GUI.currentDBpos[10]-1],getDB({path:c,uplevel:0,browsemode:"albumfilter"})):e.hasClass("db-artist")?getDB({path:c,uplevel:0,browsemode:"artist"}):e.hasClass("db-genre")?getDB({path:c,uplevel:0,browsemode:"genre"}):e.hasClass("db-spotify")?(c=GUI.currentpath+"/"+e.find("span").text(),getDB({path:c,plugin:"Spotify",args:e.data("path").toString(),querytype:"tracks"}),GUI.plugin="Spotify"):e.hasClass("db-dirble")?(c=GUI.currentpath+"/"+e.find("span").text(),getDB({path:c,plugin:"Dirble",querytype:"stations",args:e.data("path")}),GUI.plugin="Dirble"):e.hasClass("db-jamendo")||(d=e.data("browsemode"),getDB({path:c,uplevel:0,browsemode:d}));var f=e.attr("id");f=f.replace("db-",""),GUI.currentDBpos[GUI.currentDBpos[10]]=f,GUI.currentDBpath[GUI.currentDBpos[10]]=c,++GUI.currentDBpos[10]}else e.hasClass("db-webradio-add")&&a("#modal-webradio-add").modal()}),f.on("dblclick","li",function(b){var c=a(this);if(!a(b.target).hasClass("db-action")){a("li.active","#database-entries").removeClass("active"),c.addClass("active");var d=c.data("path");c.hasClass("db-spotify")?(d=c.attr("data-plid")+"-"+c.attr("data-path"),getDB({cmd:"spaddplay",path:d,querytype:"spotify-track"})):(d=c.hasClass("db-dirble")?d.split(" | ")[1]:d,getDB({cmd:"addplay",path:d}))}}),a("#db-level-up").click(function(){--GUI.currentDBpos[10];var a=GUI.currentpath;if(0===GUI.currentDBpos[10])a="";else if("file"===GUI.browsemode){var b=a.lastIndexOf("/");a=-1!==b?a.slice(0,b):""}else"album"===GUI.browsemode?(a=GUI.currentDBpath[GUI.currentDBpos[10]-1],""===a?a="Albums":GUI.browsemode="artist"):"artist"===GUI.browsemode?(a=GUI.currentDBpath[GUI.currentDBpos[10]-1],""===a?a="Artists":GUI.browsemode="genre"):"genre"===GUI.browsemode?a="Genres":"albumfilter"===GUI.browsemode&&(GUI.browsemode="artist",a=GUI.currentDBpath[GUI.currentDBpos[10]-1]);getDB({browsemode:GUI.browsemode,path:a,plugin:GUI.plugin,uplevel:1}),GUI.plugin=""}),a("#db-search-results").click(function(){a(this).addClass("hide"),a("#db-level-up").removeClass("hide"),getDB({path:GUI.currentpath})}),a("a",".context-menu").click(function(){var b=a(this).data("cmd"),c=a(this).data("type"),d=GUI.DBentry[0];switch(GUI.DBentry[0]="",b){case"pl-add":sendCmd('load "'+d+'"');break;case"pl-replace":sendCmd("clear"),sendCmd('load "'+d+'"');break;case"pl-rename":a("#modal-pl-rename").modal(),a("#pl-rename-oldname").text(d);break;case"pl-rm":a.ajax({url:"/command/?cmd=rm%20%22"+d+"%22",success:function(a){getPlaylists(a)}});break;case"wradd":d=d.split(" | ")[1],getDB({cmd:"add",path:d});break;case"wraddplay":d=d.split(" | ")[1],getDB({cmd:"addplay",path:d});break;case"wraddreplaceplay":d=d.split(" | ")[1],getDB({cmd:"addreplaceplay",path:d});break;case"wredit":a("#modal-webradio-edit").modal(),a.post("/db/?cmd=readradio",{filename:d},function(b){var c=a("#webradio-edit-name");c.val(b.name),c.data("file-name",b.name),a("#webradio-edit-url").val(b.url)},"json");break;case"wrdelete":a("#modal-webradio-delete").modal(),a("#webradio-delete-name").text(d.replace("Webradio/",""));break;case"wrsave":var e=d.split(" | ");a.post("/db/?cmd=addradio",{"radio[label]":e[0],"radio[url]":e[1]});break;default:getDB({cmd:b,path:d,browsemode:GUI.browsemode,querytype:c})}}),a("#webradio-add-button").click(function(){var b=a("#webradio-add-name").val(),c=a("#webradio-add-url").val();""===b||""===c?renderMSG([{title:"Missing fields",text:"Please fill both fields to continue",icon:"fa fa-warning"}]):(a.post("/db/?cmd=addradio",{"radio[label]":b,"radio[url]":c},function(){},"json"),a("#modal-webradio-add").modal("hide"),a("#webradio-add-name").val(""),a("#webradio-add-url").val(""))}),a("#webradio-edit-button").click(function(){var b=a("#webradio-edit-name");a.post("/db/?cmd=editradio",{"radio[newlabel]":b.val(),"radio[label]":b.data("file-name"),"radio[url]":a("#webradio-edit-url").val()},function(){},"json")}),a("#webradio-delete-button").click(function(){var b=a("#webradio-delete-name").text();a.post("/db/?cmd=deleteradio",{"radio[label]":b},function(){},"json")}),a("#db-firstPage").click(function(){a.scrollTo(0,500)}),a("#db-prevPage").click(function(){var b="-="+a(window).height()+"px";a.scrollTo(b,500)}),a("#db-nextPage").click(function(){var b="+="+a(window).height()+"px";a.scrollTo(b,500)}),a("#db-lastPage").click(function(){a.scrollTo("100%",500)}),a("#pl-firstPage").click(function(){a.scrollTo(0,500)}),a("#pl-prevPage").click(function(){var b=a(window).scrollTop(),c=b-a(window).height();a.scrollTo(c,500)}),a("#pl-nextPage").click(function(){var b=a(window).scrollTop(),c=b+a(window).height();a.scrollTo(c,500)}),a("#pl-lastPage").click(function(){a.scrollTo("100%",500)});var g=document.location.toString();g.match("#")&&a('#menu-bottom a[href="/#'+g.split("#")[1]+'"]').tab("show"),a("#menu-bottom a").on("shown",function(a){history.pushState?history.pushState(null,null,a.target.hash):window.location.hash=a.target.hash}).on("click",function(){a("#overlay-social").hasClass("open")&&a(".overlay-close").trigger("click")}),a(".ttip").length&&a(".ttip").tooltip(),FastClick.attach(document.body),a("#syscmd-poweroff").click(function(){a.post("/settings/",{syscmd:"poweroff"}),toggleLoader()}),a("#syscmd-reboot").click(function(){a.post("/settings/",{syscmd:"reboot"}),toggleLoader()}),overlayTrigger("#overlay-social"),overlayTrigger("#overlay-playsource"),a("#playsource-mpd").click(function(){a(this).hasClass("inactive")&&(a.ajax({url:"/command/?switchplayer=MPD"}),a("#overlay-playsource-close").trigger("click"))}),a("#playsource-spotify").click(function(){a(this).hasClass("inactive")&&("1"===GUI.libraryhome.Spotify?(a.ajax({url:"/command/?switchplayer=Spotify"}),a("#overlay-playsource-close").trigger("click")):new PNotify({title:"Spotify not enabled",text:"Enable and configure it under the Settings screen",icon:"fa fa-exclamation-circle"}))})}:function(a){"use strict";if(GUI.mode=checkWebSocket(),playbackChannel(),PNotify.prototype.options.styling="fontawesome",PNotify.prototype.options.stack.dir1="up",PNotify.prototype.options.stack.dir2="left",PNotify.prototype.options.stack.firstpos1=90,PNotify.prototype.options.stack.firstpos2=50,PNotify.prototype.options.stack.spacing1=10,PNotify.prototype.options.stack.spacing2=10,notifyChannel(),a(".btn-cmd").click(function(){var b=a(this);commandButton(b)}),a("#syscmd-poweroff").click(function(){a.post("/settings/",{syscmd:"poweroff"}),toggleLoader()}),a("#syscmd-reboot").click(function(){a.post("/settings/",{syscmd:"reboot"}),toggleLoader()}),a(".selectpicker").selectpicker(),a("#section-sources").length&&("nfs"===a("#mount-type").val()&&a("#mount-cifs").addClass("disabled").children(".disabler").removeClass("hide"),a("#mount-type").change(function(){"cifs"===a(this).val()||"osx"===a(this).val()?a("#mount-cifs").removeClass("disabled").children(".disabler").addClass("hide"):a("#mount-cifs").addClass("disabled").children(".disabler").removeClass("hide")}),a("#nas-guest").change(function(){a(this).prop("checked")?a("#mount-auth").addClass("disabled").children(".disabler").removeClass("hide"):a("#mount-auth").removeClass("disabled").children(".disabler").addClass("hide")}),a("#nas-advanced").change(function(){a(this).prop("checked")?a("#mount-advanced-config").removeClass("hide"):a("#mount-advanced-config").addClass("hide")}),a("#show-mount-advanced-config").click(function(b){b.preventDefault(),a(this).hasClass("active")?(a("#mount-advanced-config").toggleClass("hide"),a(this).removeClass("active"),a(this).find("i").removeClass("fa fa-minus-circle").addClass("fa fa-plus-circle"),a(this).find("span").html("show advanced options")):(a("#mount-advanced-config").toggleClass("hide"),a(this).addClass("active"),a(this).find("i").removeClass("fa fa-plus-circle").addClass("fa fa-minus-circle"),a(this).find("span").html("hide advanced options"))}),a("#usb-mount-list a").click(function(){var b=a(this).data("mount");a("#usb-umount-name").html(b),a("#usb-umount").val(b)})),a("#section-settings").length&&(a("#airplay").change(function(){a(this).prop("checked")?(a("#airplayName").removeClass("hide"),a("#airplayBox").addClass("boxed-group")):(a("#airplayName").addClass("hide"),a("#airplayBox").removeClass("boxed-group"))}),a("#scrobbling-lastfm").change(function(){a(this).prop("checked")?(a("#lastfmAuth").removeClass("hide"),a("#lastfmBox").addClass("boxed-group")):(a("#lastfmAuth").addClass("hide"),a("#lastfmBox").removeClass("boxed-group"))}),a("#proxy").change(function(){a(this).prop("checked")?(a("#proxyAuth").removeClass("hide"),a("#proxyBox").addClass("boxed-group")):(a("#proxyAuth").addClass("hide"),a("#proxyBox").removeClass("boxed-group"))}),a("#dlna").change(function(){a(this).prop("checked")?(a("#dlnaName").removeClass("hide"),a("#dlnaBox").addClass("boxed-group")):(a("#dlnaName").addClass("hide"),a("#dlnaBox").removeClass("boxed-group"))}),a("#spotify").change(function(){a(this).prop("checked")?(a("#spotifyAuth").removeClass("hide"),a("#spotifyBox").addClass("boxed-group")):(a("#spotifyAuth").addClass("hide"),a("#spotifyBox").removeClass("boxed-group"))})),a("#section-network").length){var b=a("#network-manual-config");"0"===a("#dhcp").val()&&b.removeClass("hide"),a("#dhcp").change(function(){"0"===a(this).val()?b.removeClass("hide"):b.addClass("hide")});var c=a("#wifi-security-key");"open"!==a("#wifi-security").val()&&c.removeClass("hide"),a("#wifi-security").change(function(){"open"!==a(this).val()?c.removeClass("hide"):c.addClass("hide")}),a("#wifiNetworks").length&&(wlansChannel(),nicsChannel()),a("#wifiProfiles").change(function(){a(this).prop("checked")?a("#wifiProfilesBox").addClass("hide"):a("#wifiProfilesBox").removeClass("hide")})}if(a("#section-mpd").length&&(a("#audio-output-interface").change(function(){renderMSG([{title:"Switching audio output",text:"Please wait for the config update...",icon:"fa fa-cog fa-spin",delay:5e3}]);var b=a(this).val();a.ajax({type:"POST",url:"/mpd/",data:{ao:b}})}),a(".manual-edit-confirm").find(".btn-primary").click(function(){a("#mpdconf_editor").removeClass("hide"),a("#manual-edit-warning").addClass("hide")})),a("#section-debug").length){ZeroClipboard.config({swfPath:"/assets/js/vendor/ZeroClipboard.swf"});var d=new ZeroClipboard(document.getElementById("copy-to-clipboard"));d.on("ready",function(){d.on("aftercopy",function(){new PNotify({title:"Copied to clipboard",text:"The debug output was copied successfully in your clipboard.",icon:"fa fa-check"})})})}}); \ No newline at end of file +function sendCmd(a){var b=new XMLHttpRequest;b.open("GET","/command/?cmd="+a,!0),b.onreadystatechange=function(){4===this.readyState&&this.status>=200&&this.status<400},b.send(),b=null}function checkWebSocket(){return window.WebSocket?"websocket":"longpolling"}function checkWorkers(){return!!(window.Worker&&window.Blob||Modernizr.webworkers&&Modernizr.blobconstructor)}function parsePath(a){var b=a&&a.length?a.lastIndexOf("/"):0,c="";return b&&-1!==b&&(c=a.slice(0,b)),c}function refreshTimer(a,b,c){var d=$("#countdown-display");d.countdown("destroy"),d.countdown({since:"stop"!==c||void 0!==c?-a:0,compact:!0,format:"MS"}),"play"!==c&&d.countdown("pause")}function refreshKnob(){window.clearInterval(GUI.currentKnob);var a=10*parseInt(GUI.json.song_percent),b=parseInt(GUI.json.time),c=parseInt(1e3/b),d=$("#time");d.val(a,!1).trigger("update"),"play"===GUI.state&&(GUI.currentKnob=setInterval(function(){a+="visible"!==GUI.visibility?c:1,d.val(a,!1).trigger("update")},b))}function timeConvert(a){var b=Math.floor(a/60);a-=60*b;var c=10>b?"0"+b:b,d=10>a?"0"+a:a;return c+":"+d}function timeConvert2(a){var b=Math.floor(a/3600),c=Math.floor((a-3600*b)/60);return a=Math.floor(a-3600*b-60*c),b>0?(10>b&&(b="0"+b),b+=":"):b="",10>c&&(c="0"+c),10>a&&(a="0"+a),b+c+":"+a}function countdownRestart(a){var b=$("#countdown-display").countdown("destroy");b.countdown({since:-a,compact:!0,format:"MS"})}function setvol(a){$("#volume").val(a,!1).trigger("update"),GUI.volume=a,$("#volumemute").removeClass("btn-primary"),sendCmd("setvol "+a)}function volumeStepCalc(a){var b=0;GUI.volume=parseInt($("#volume").val());var c=function(c){b++,"up"===a?GUI.stepVolumeDelta=parseInt(GUI.volume)+b:"dn"===a&&(GUI.stepVolumeDelta=parseInt(GUI.volume)-b),$("#volume").val(GUI.stepVolumeDelta).trigger("change")};c(),GUI.stepVolumeInt=window.setInterval(function(){c()},200)}function volumeStepSet(){window.clearInterval(GUI.stepVolumeInt),setvol(GUI.stepVolumeDelta)}function customScroll(a,b,c){"undefined"==typeof c&&(c=500);var d=49,e=parseInt($(window).height()/2),f=$(window).scrollTop(),g=0,h=0;"db"===a?(g=parseInt(b*d-e),h=g):"pl"===a&&(g=parseInt((b+2)*d-e),h=Math.abs(g-f),h=(g>f?"+":"-")+"="+h+"px",$("#playlist-entries").find("li").eq(b).addClass("active")),$.scrollTo(g>0?h:0,c)}function randomScrollPL(){var a=$(".playlist li").size(),b=1+Math.floor(Math.random()*a);customScroll("pl",b)}function randomScrollDB(){var a=$(".database li").size(),b=1+Math.floor(Math.random()*a);customScroll("db",b)}function toggleLoader(a){"close"===a?$("#loader").addClass("hide"):$("#section-dev").length?($("#loader").addClass("hide"),new PNotify({title:"Warning",text:"The loading layer (spinning arrows) points to a socket error",icon:"fa fa-exclamation-circle"})):$("#loader").removeClass("hide")}function customNotify(a){"kernelswitch"===a.custom&&(void 0!==GUI.noticeUI.kernelswitch&&GUI.noticeUI.kernelswitch.remove(),GUI.noticeUI.kernelswitch=new PNotify({title:"title"in a?a.title:"[missing title]",text:"text"in a?a.text:"[missing text]",icon:"fa fa-refresh",hide:!1,confirm:{confirm:!0,buttons:[{text:a.btntext,addClass:"btn-default btn-block uppercase",click:function(){$.post("/settings/",{syscmd:"reboot"}),toggleLoader()}},{text:"Cancel",addClass:"hide"}]},buttons:{closer:!1,sticker:!1}}))}function renderMSG(a){var b=a[0];if("custom"in b&&null!==b.custom)return void customNotify(b);var c={title:"title"in b?b.title:"[missing title]",text:"text"in b?b.text:"[missing text]",icon:void 0===b.icon?"fa fa-check":b.icon,opacity:void 0===b.opacity?.9:b.opacity,hide:void 0===b.hide&&void 0===b.permanotice,buttons:{closer:void 0===b.permanotice,sticker:void 0===b.permanotice},delay:void 0===b.delay?8e3:b.delay,mouse_reset:!1};"permanotice"in b?void 0===GUI.noticeUI[b.permanotice]?GUI.noticeUI[b.permanotice]=new PNotify(c):"permaremove"in b?(GUI.noticeUI[b.permanotice].remove(),GUI.noticeUI[b.permanotice]=void 0):GUI.noticeUI[b.permanotice].open():new PNotify(c)}function sortOrder(a){var b=$("#"+a).index();a=parseInt(a.replace("pl-","")),sendCmd("moveid "+a+" "+b)}function loadingSpinner(a,b){"hide"===b?("db"===a&&$("#spinner-db").addClass("hide"),"pl"===a&&$("#spinner-pl").addClass("hide")):("db"===a&&$("#spinner-db").removeClass("hide"),"pl"===a&&$("#spinner-pl").removeClass("hide"))}function setPlaybackSource(){var a=GUI.libraryhome.ActivePlayer;$("#overlay-playsource-open button").text(a),$("#overlay-playsource a").addClass("inactive");var b=a.toLowerCase();$("#playsource-"+b).removeClass("inactive"),"Spotify"===a||"Airplay"===a?($("#volume").trigger("configure",{readOnly:!0,fgColor:"#1A242F"}).css({color:"#1A242F"}),$(".volume button").prop("disabled",!0),$("#single").addClass("disabled")):($("#volume").trigger("configure",{readOnly:!1,fgColor:"#0095D8"}).css({color:"#0095D8"}),$(".volume button").prop("disabled",!1),$("#single").removeClass("disabled")),$("#playlist-entries").removeClass(function(a,b){return(b.match(/(^|\s)playlist-\S+/g)||[]).join(" ")}).addClass("playlist-"+b),$("#pl-manage").removeClass(function(a,b){return(b.match(/(^|\s)pl-manage-\S+/g)||[]).join(" ")}).addClass("pl-manage-"+b)}function chkKey(a){return void 0!==a&&""!==a}function renderLibraryHome(){loadingSpinner("db"),$("#database-entries").addClass("hide"),$("#db-level-up").addClass("hide"),$("#db-homeSetup").removeClass("hide").removeClass("btn-primary").addClass("btn-default"),$("#home-blocks").removeClass("hide");var a=GUI.libraryhome,b=0,c="",d='
    ',e="
    ",f="",g="",h="Spotify"===a.ActivePlayer||"Airplay"===a.ActivePlayer;for(c='

    Browse your library

    ',setPlaybackSource(),h&&(f=" inactive"),b=0;bookmark=a.bookmarks[b];b+=1)c+=d+'

    '+bookmark.name+"

    bookmark
    "+e;chkKey(a.networkMounts)&&(c+=0===a.networkMounts?h?d+'

    Network mounts (0)

    network attached storages
    '+e:d+'

    Network mounts (0)

    click to add some
    '+e:d+'

    Network mounts ('+a.networkMounts+")

    network attached storages
    "+e),chkKey(a.localStorages)&&(c+=0===a.localStorages?"":d+'

    LocalStorage ('+a.localStorages+")

    locally stored music
    "+e),chkKey(a.USBMounts)&&(c+=0===a.USBMounts?h?d+'

    USB storage (0)

    no USB storage plugged
    '+e:d+'

    USB storage (0)

    no USB storage plugged
    '+e:d+'

    USB storage ('+a.USBMounts+")

    USB attached drives
    "+e),chkKey(a.webradio)&&(c+=0===a.webradio?h?d+'

    My Webradios (0)

    webradio local playlists
    '+e:d+'

    My Webradios (0)

    click to add some
    '+e:d+'

    My Webradios ('+a.webradio+")

    webradio local playlists
    "+e),chkKey(a.Spotify)&&(c+="0"===a.Spotify?d+'

    Spotify

    click to configure
    '+e:"Spotify"!==a.ActivePlayer?d+'

    Spotify

    click to switch renderer
    '+e:d+'

    Spotify

    music for everyone
    '+e),chkKey(a.Dirble)&&(c+=d+'

    Dirble ('+a.Dirble+")

    radio stations open directory
    "+e),c+=d+'

    Jamendo

    world\'s largest platform for free music
    '+e,c+=d+'

    Albums

    browse MPD database by album
    '+e,c+=d+'

    Artists

    browse MPD database by artist
    '+e,c+=d+'

    Genres

    browse MPD database by genre
    '+e,c+="",document.getElementById("home-blocks").innerHTML=c,loadingSpinner("db","hide"),$("span","#db-currentpath").html("")}function refreshState(){var a=GUI.state;if("play"===a?($("#play").addClass("btn-primary"),$("i","#play").removeClass("fa fa-pause").addClass("fa fa-play"),$("#stop").removeClass("btn-primary")):"pause"===a?($("#playlist-position span").html("Not playing"),$("#play").addClass("btn-primary"),$("i","#play").removeClass("fa fa-play").addClass("fa fa-pause"),$("#stop").removeClass("btn-primary")):"stop"===a&&($("#play").removeClass("btn-primary"),$("i","#play").removeClass("fa fa-pause").addClass("fa fa-play"),$("#stop").addClass("btn-primary"),$("#section-index").length&&$("#countdown-display").countdown("destroy"),"radio"===GUI.stream?$("#total").html(""):$("#total").html("00:00"),$("#time").val(0,!1).trigger("update"),$("#format-bitrate").html(" "),$("li","#playlist-entries").removeClass("active")),"stop"!==a){"radio"===GUI.stream?$("#total").html(""):$("#total").html(void 0!==GUI.json.time?timeConvert(GUI.json.time):"00:00");var b=GUI.json.audio_channels&&GUI.json.audio_sample_depth&&GUI.json.audio_sample_rate?GUI.json.audio_channels+", "+GUI.json.audio_sample_depth+" bit, "+GUI.json.audio_sample_rate+" kHz, "+GUI.json.bitrate+" kbps":" ";$("#format-bitrate").html(b),$("li","#playlist-entries").removeClass("active");var c=parseInt(GUI.json.song);$("#playlist-entries").find("li").eq(c).addClass("active")}GUI.json.playlistlength&&"0"!==GUI.json.playlistlength?GUI.json.song?$("#playlist-position span").html("Playlist position "+(parseInt(GUI.json.song)+1)+"/"+GUI.json.playlistlength):$("#playlist-position span").html("Playlist position 1/"+GUI.json.playlistlength):$("#playlist-position span").html("Empty queue, add some music!"),void 0!==GUI.json.updating_db?$("a","#open-panel-sx").html(' Updating'):$("a","#open-panel-sx").html(' Library')}function updateGUI(){var a=GUI.json.volume,b=GUI.json.radioname,c=GUI.json.currentartist,d=GUI.json.currentsong,e=GUI.json.currentalbum;if(GUI.stream=null!==b&&void 0!==b&&""!==b?"radio":"",refreshState(),$("#section-index").length){if(GUI.currentsong!==GUI.json.currentsong&&(countdownRestart(0),$("#panel-dx").hasClass("active"))){var f=parseInt(GUI.json.song);customScroll("pl",f)}$("#volume").val("-1"===a?100:a,!1).trigger("update"),"radio"!==GUI.stream?($("#currentartist").html(null===c||void 0===c||""===c?'[no artist]':c),$("#currentsong").html(null===d||void 0===d||""===d?'[no title]':d),$("#currentalbum").html(null===e||void 0===e||""===e?'[no album]':e)):($("#currentartist").html(null===c||void 0===c||""===c?b:c),$("#currentsong").html(null===d||void 0===d||""===d?b:d),$("#currentalbum").html('streaming')),"1"===GUI.json.repeat?$("#repeat").addClass("btn-primary"):$("#repeat").removeClass("btn-primary"),"1"===GUI.json.random?$("#random").addClass("btn-primary"):$("#random").removeClass("btn-primary"),"1"===GUI.json.consume?$("#consume").addClass("btn-primary"):$("#consume").removeClass("btn-primary"),"1"===GUI.json.single?$("#single").addClass("btn-primary"):$("#single").removeClass("btn-primary"),GUI.currentsong=d;var g=c+" - "+e;if(GUI.currentalbum!==g)if(null===b||void 0===b||""===b){var h=Math.floor(1001*Math.random());$("#cover-art").css("background-image",'url("/coverart/?v='+h+'")')}else $("#cover-art").css("background-image",'url("assets/img/cover-radio.jpg")');GUI.currentalbum=g}}function getPlaylistPlain(a){var b,c,d=parseInt(GUI.json.song)+1,e=GUI.json.state,f="",g="",h="",i="",j="",k="",l="",m="",n="",o="",p="",q="",r=0,s=a.split("\n"),t=[];for(b=0;c=s[b];b+=1)t=c.split(": "),"Time"===t[0]?g=parseInt(t[1]):"Artist"===t[0]?h=t[1]:"Title"===t[0]?j=t[1]:"Name"===t[0]?k=t[1]:"Album"===t[0]?i=t[1]:"file"===t[0]?l=t[1]:"Id"===t[0]&&(o=t[1],""===j||""===i?(n=parsePath(l),m=l.split("/").pop(),j=m,p=""===h?"path: "+n:h):p=h+" - "+i,""!==k?(j=''+k,p=l,q=""):q=""+timeConvert2(g)+"",r++,f+='
  • '+j+q+''+p+"
  • ",g="",h="",i="",j="",k="");$(".playlist").addClass("hide"),$("#playlist-entries").removeClass("hide");var u=document.getElementById("playlist-entries");u&&(u.innerHTML=f),$("#pl-filter-results").addClass("hide").html(""),$("#pl-filter").val(""),$("#pl-manage").removeClass("hide"),$("#pl-count").removeClass("hide").html(r+(1!==r?" entries":" entry"))}function getPlaylistCmd(){loadingSpinner("pl"),$.ajax({url:"/db/?cmd=playlist",success:function(a){if(a.length>4){$(".playlist").addClass("hide"),$("#playlist-entries").removeClass("hide"),getPlaylistPlain(a);var b=parseInt(GUI.json.song);$("#panel-dx").hasClass("active")&&GUI.currentsong!==GUI.json.currentsong&&customScroll("pl",b,200)}else $(".playlist").addClass("hide"),$("#playlist-warning").removeClass("hide"),$("#pl-filter-results").addClass("hide").html(""),$("#pl-count").removeClass("hide").html("0 entries");loadingSpinner("pl","hide")}})}function getPlaylist(a){if(data=a[0],data.length>4){$(".playlist").addClass("hide"),$("#playlist-entries").removeClass("hide"),getPlaylistPlain(data);var b=parseInt(GUI.json.song);$("#panel-dx").hasClass("active")&&GUI.currentsong!==GUI.json.currentsong&&customScroll("pl",b,200)}else $(".playlist").addClass("hide"),$("#playlist-warning").removeClass("hide"),$("#pl-filter-results").addClass("hide").html(""),$("#pl-count").removeClass("hide").html("0 entries");loadingSpinner("pl","hide")}function renderUI(a){if(toggleLoader("close"),GUI.json=a[0],GUI.state=GUI.json.state,updateGUI(),$("#section-index").length){var b=""!==GUI.json.elapsed&&void 0!==GUI.json.elapsed?GUI.json.elapsed:0,c=""!==GUI.json.time&&void 0!==GUI.json.time&&null!==GUI.json.time?GUI.json.time:0;refreshTimer(parseInt(b),parseInt(c),GUI.json.state),"radio"!==GUI.stream?refreshKnob():$("#time").val(0,!1).trigger("update"),GUI.json.playlist!==GUI.playlist&&(getPlaylistCmd(),GUI.playlist=GUI.json.playlist)}}function renderPlaylists(a){var b,c,d="",e="",f=a.split("\n"),g=[];for(b=0;c=f[b];b+=1)g=c.split(": "),"playlist"===g[0]&&(e=g[1],d+='
  • '+e+"
  • ",e="");document.getElementById("playlist-entries").innerHTML="",$(".playlist").addClass("hide"),$("#pl-manage").addClass("hide"),$("#pl-count").addClass("hide"),$("#pl-filter-results").removeClass("hide").addClass("back-to-queue").html(' to queue'),$("#pl-currentpath").removeClass("hide"),$("#pl-editor").removeClass("hide"),document.getElementById("pl-editor").innerHTML=d,loadingSpinner("pl","hide")}function getPlaylists(){loadingSpinner("pl"),$.ajax({url:"/command/?cmd=listplaylists",success:function(a){renderPlaylists(a)}})}function parseResponse(a){var b=a.inputArr||"",c=a.respType||"",d=a.i||0,e=a.inpath||"",f=a.querytype||"",g="";switch(c){case"playlist":break;case"db":"file"===GUI.browsemode?(""===e&&void 0!==b.file&&(e=parsePath(b.file)),void 0!==b.file||"Webradio"===e?(g='
  • ',g+=b.Title+" "+timeConvert(b.Time)+"",g+=' ',g+=b.Artist,g+=" - ",g+=b.Album):"Webradio"!==e?(g+=b.file,g+='">',g+=b.file.replace(e+"/","")+" "+timeConvert(b.Time)+"",g+='',g+=" path: ",g+=e):(g+=b.playlist,g+='">',g+=''+b.playlist.replace(e+"/","").replace("."+b.fileext,""),g+='webradio'),g+="
  • "):void 0!==b.playlist?"cue"===b.fileext&&(g='
  • ',g+=b.playlist.replace(e+"/","")+" [CUE file]",g+='',g+=" path: ",g+=e,g+="
  • "):(g='
  • ':'">',g+=b.directory.replace(e+"/",""),g+="
  • ")):"album"===GUI.browsemode||"albumfilter"===GUI.browsemode?void 0!==b.file?(g='
  • ',g+=b.Title+" "+timeConvert(b.Time)+"",g+=' ',g+=b.Artist,g+=" - ",g+=b.Album,g+="
  • "):""!==b.album&&(g='
  • "):"artist"===GUI.browsemode?void 0!==b.album?(g='
  • ',g+=""!==b.album?b.album:"Unknown album",g+="
  • "):""!==b.artist&&(g='
  • ',g+=b.artist,g+="
  • "):"genre"===GUI.browsemode&&(void 0!==b.artist?(g='
  • ',g+=""!==b.artist?b.artist:"Unknown artist",g+="
  • "):""!==b.genre&&(g='
  • ',g+=b.genre,g+="
  • "));break;case"Spotify":""===f?(g='
  • ',g+=""!==b.name?b.name:"Favorites",g+=" (",g+=b.tracks,g+=")
  • "):"tracks"===f&&(g='
  • ',g+=b.title+" "+timeConvert(b.duration/1e3)+"",g+=' ',g+=b.artist,g+=" - ",g+=b.album,g+="
  • ");break;case"Dirble":""===f?(g='
  • ',g+=b.name,g+="
  • "):"stations"===f&&(g='
  • "+b.bitrate+"",g+='',g+=b.website,g+="
  • ");break;case"Jamendo":g='
  • ',g+=b.dispname+"
  • "}return g}function populateDB(a){var b=a.data||"",c=a.path||"",d=a.uplevel||0,e=a.keyword||"",f=a.plugin||"",g=a.querytype||"",h=a.args||"",i="",j=0,k=[];if(""!==f){if("Spotify"===f){for($("#database-entries").removeClass("hide"),$("#db-level-up").removeClass("hide"),$("#home-blocks").addClass("hide"),c&&(GUI.currentpath=c),document.getElementById("database-entries").innerHTML="",b="tracks"===g?b.tracks:b.playlists,j=0;k=b[j];j+=1)i+=parseResponse({inputArr:k,respType:"Spotify",i:j,querytype:g,inpath:h});document.getElementById("database-entries").innerHTML=i}if("Dirble"===f){for($("#database-entries").removeClass("hide"),$("#db-level-up").removeClass("hide"),$("#home-blocks").addClass("hide"),c&&(GUI.currentpath=c),document.getElementById("database-entries").innerHTML="",j=0;k=b[j];j+=1)i+=parseResponse({inputArr:k,respType:"Dirble",i:j,querytype:g});document.getElementById("database-entries").innerHTML=i}if("Jamendo"===f){for($("#database-entries").removeClass("hide"),$("#db-level-up").removeClass("hide"),$("#home-blocks").addClass("hide"),c&&(GUI.currentpath=c),document.getElementById("database-entries").innerHTML="",j=0;k=b[j];j+=1)i+=parseResponse({inputArr:k,respType:"Jamendo",i:j,querytype:g});document.getElementById("database-entries").innerHTML=i}}else{if(""===c&&""===e)return void renderLibraryHome();if($("#database-entries").removeClass("hide"),$("#db-level-up").removeClass("hide"),$("#home-blocks").addClass("hide"),c&&(GUI.currentpath=c),document.getElementById("database-entries").innerHTML="",""!==e){var l=b.length?b.length:"0",m=1===b.length?"":"s";$("#db-level-up").addClass("hide"),$("#db-search-results").removeClass("hide").html('back')}for(j=0;k=b[j];j+=1)i+=parseResponse({inputArr:k,respType:"db",i:j,inpath:c});"Webradio"===c&&(i+='
  • add newadd a webradio to your library
  • '),document.getElementById("database-entries").innerHTML=i}var n=$("span","#db-currentpath");if("album"===GUI.browsemode?"Albums"===c?n.html(c):n.html("Albums/"+c):"artist"===GUI.browsemode?"Artists"===c?n.html(c):n.html("Artists/"+c):"genre"===GUI.browsemode?"Genres"===c?n.html(c):n.html("Genres/"+c):n.html(c),$("#db-homeSetup").addClass("hide"),d){var o=GUI.currentDBpos[GUI.currentDBpos[10]];$("#db-"+o).addClass("active"),customScroll("db",o,0)}else customScroll("db",0,0);loadingSpinner("db","hide")}function getDB(a){var b=a.cmd||"browse",c=a.path||"",d=a.browsemode||"file",e=a.uplevel||"",f=a.plugin||"",g=a.querytype||"",h=a.args||"";if(loadingSpinner("db"),GUI.browsemode=d,""!==f)"Spotify"===f?$.post("/db/?cmd=spotify",{plid:h},function(a){populateDB({data:a,path:c,plugin:f,querytype:g,uplevel:e,args:h})},"json"):"Dirble"===f?$.post("/db/?cmd=dirble",{querytype:""===g?"categories":g,args:h},function(a){populateDB({data:a,path:c,plugin:f,querytype:g,uplevel:e})},"json"):"Jamendo"===f&&$.post("/db/?cmd=jamendo",{querytype:""===g?"radio":g,args:h},function(a){populateDB({data:a.results,path:c,plugin:f,querytype:g})},"json");else if("search"===b){var i=$("#db-search-keyword").val();$.post("/db/?querytype="+GUI.browsemode+"&cmd=search",{query:i},function(a){populateDB({data:a,path:c,uplevel:e,keyword:i})},"json")}else"browse"===b?$.post("/db/?cmd=browse",{path:c,browsemode:GUI.browsemode},function(a){populateDB({data:a,path:c,uplevel:e})},"json"):(loadingSpinner("db","hide"),$.post("/db/?cmd="+b,{path:c,querytype:g},function(a){},"json"))}function onreleaseKnob(a){if("stop"!==GUI.state&&""!==GUI.state)if("radio"!==GUI.stream){window.clearInterval(GUI.currentKnob);var b=Math.floor(a*parseInt(GUI.json.time)/1e3);sendCmd("seek "+GUI.json.song+" "+b),$("#time").val(a),$("#countdown-display").countdown("destroy"),$("#countdown-display").countdown({since:-b,compact:!0,format:"MS"})}else $("#time").val(0).trigger("change")}function commandButton(a){var b,c=a.data("cmd");if("stop"===c)a.addClass("btn-primary"),$("#play").removeClass("btn-primary"),$("#section-index").length&&(refreshTimer(0,0,"stop"),window.clearInterval(GUI.currentKnob),$(".playlist").find("li").removeClass("active"),$("#total").html("00:00"));else{if("play"===c){var d=GUI.state;return"play"===d?(b="pause",$("#section-index").length&&$("#countdown-display").countdown("pause")):"pause"===d?(b="play",$("#section-index").length&&$("#countdown-display").countdown("resume")):"stop"===d&&(b="play",$("#section-index").length&&$("#countdown-display").countdown({since:0,compact:!0,format:"MS"})),window.clearInterval(GUI.currentKnob),void sendCmd(b)}if("previous"===c||"next"===c)$("#section-index").length&&($("#countdown-display").countdown("pause"),window.clearInterval(GUI.currentKnob));else if(a.hasClass("btn-volume")){var e,f=parseInt($("#volume").val());return null===GUI.volume&&(GUI.volume=f),"volumedn"===c&&parseInt(GUI.volume)>0?(e=parseInt(GUI.volume)-1,GUI.volume=e,$("#volumemute").removeClass("btn-primary")):"volumeup"===c&&parseInt(GUI.volume)<100?(e=parseInt(GUI.volume)+1,GUI.volume=e,$("#volumemute").removeClass("btn-primary")):"volumemute"===c&&(0!==f?(GUI.volume=f,a.addClass("btn-primary"),e=0):(a.removeClass("btn-primary"),setvol(GUI.volume))),void(e>=0&&100>=e&&sendCmd("setvol "+e))}}a.hasClass("btn-toggle")?(b=c+(a.hasClass("btn-primary")?" 0":" 1"),a.toggleClass("btn-primary")):b=c,sendCmd(b)}function libraryHome(a){GUI.libraryhome=a[0],renderLibraryHome()}function listWLANs(a){var b="",c="",d="",e=a[0];$.each(e,function(a){b+='

    ',0!==e[a].connected&&(b+=''),1===e[a].storedprofile&&"on"===e[a].encryption?b+='':"on"===e[a].encryption?b+='':1!==e[a].storedprofile&&(b+=''),b+=""+e[a].ESSID+"

    ",1===e[a].storedprofile?d+=b:c+=b,b=""}),""===c&&(c='

    scanning for networks...

    '),document.getElementById("wifiNetworks").innerHTML=c,document.getElementById("wifiStored").innerHTML=d,$.ajax({url:"/command/?cmd=wifiscan"})}function nicsDetails(a){var b="",c=a[0];$.each(c,function(a){a===$("#nic-details").data("name")&&(b+="Name:"+a+"",b+="Type:wireless","off/any"===c[a].currentssid?b+='Status:no network connected':(b+='Status:connected',b+="Associated SSID:"+c[a].currentssid+""),b+="Assigned IP:"+(null!==c[a].ip?""+c[a].ip+"":"none")+"",b+="Speed:"+(null!==c[a].speed?c[a].speed:"unknown")+"")}),$("#nic-details tbody").html(b)}function playbackChannel(){var a=new PushStream({useSSL:"https:"===window.location.protocol,host:window.location.hostname,port:window.location.port,modes:GUI.mode,reconnectOnChannelUnavailableInterval:5e3});a.onmessage=renderUI,a.onstatuschange=function(a){2===a?($("#loader").addClass("hide"),sendCmd("renderui")):0===a&&toggleLoader()},a.addChannel("playback"),a.connect()}function queueChannel(){var a=new PushStream({useSSL:"https:"===window.location.protocol,host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=getPlaylist,a.addChannel("queue"),a.connect()}function libraryChannel(){var a=new PushStream({useSSL:"https:"===window.location.protocol,host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=libraryHome,a.addChannel("library"),a.connect()}function notifyChannel(){var a=new PushStream({useSSL:"https:"===window.location.protocol,host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=renderMSG,a.addChannel("notify"),a.connect()}function wlansChannel(){var a=new PushStream({useSSL:"https:"===window.location.protocol,host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=listWLANs,a.addChannel("wlans"),a.connect(),$.ajax({url:"/command/?cmd=wifiscan"})}function nicsChannel(){var a=new PushStream({useSSL:"https:"===window.location.protocol,host:window.location.hostname,port:window.location.port,modes:GUI.mode});a.onmessage=nicsDetails,a.addChannel("nics"),a.connect()}function overlayTrigger(a){function b(){if(c.hasClass("open")){c.removeClass("open"),c.addClass("closed")}else if(c.hasClass("closed")&&(c.addClass("open"),"#overlay-social"===a)){var b="https://twitter.com/home?status=Listening+to+"+GUI.json.currentsong.replace(/\s+/g,"+")+"+by+"+GUI.json.currentartist.replace(/\s+/g,"+")+"+on+%40RuneAudio+http%3A%2F%2Fwww.runeaudio.com%2F+%23nowplaying",d="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.runeaudio.com%2F&display=popup",e="https://plus.google.com/share?url=http%3A%2F%2Fwww.runeaudio.com%2F";$("#urlTwitter").attr("href",b),$("#urlFacebook").attr("href",d),$("#urlGooglePlus").attr("href",e)}}var c=$(a),d=$(a+"-open"),e=$(a+"-close");transEndEventNames={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"},d.click(function(){b()}),e.click(function(){b()})}function getHiddenProp(){var a=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var b=0;bback')):(a("#pl-count").removeClass("hide"),a("#pl-filter-results").addClass("hide").html(""))}),a("#pl-filter-results").click(function(){a(this).addClass("hide"),a("#pl-count").removeClass("hide"),a(this).hasClass("back-to-queue")?(a(".playlist").addClass("hide"),getPlaylistCmd(),a("#pl-currentpath").addClass("hide"),a("#pl-manage").removeClass("hide")):(a("li","#playlist-entries").each(function(){var b=a(this);b.show()}),a("#pl-currentpath").removeClass("hide"),a("#pl-filter").val("")),customScroll("pl",parseInt(GUI.json.song),500)}),a("#pl-manage-list").click(function(){getPlaylists()}),a("#modal-pl-save-btn").click(function(){var b=a("#pl-save-name").val();sendCmd('save "'+b+'"')}),a("#pl-editor").on("click",".pl-action",function(b){b.preventDefault();var c=a(this).parent().attr("data-path");GUI.DBentry[0]=c}),a("#pl-rename-button").click(function(){var b=a("#pl-rename-oldname").text(),c=a("#pl-rename-name").val();sendCmd('rename "'+b+'" "'+c+'"'),getPlaylists()});var e=document.getElementById("playlist-entries");new Sortable(e,{ghostClass:"sortable-ghost",onUpdate:function(a){sortOrder(a.item.getAttribute("id"))}}),a("a","#open-panel-sx").click(function(){a("#open-panel-sx").hasClass("active")&&customScroll("pl",parseInt(GUI.json.song),500)}).on("shown.bs.tab",function(a){customScroll("db",GUI.currentDBpos[GUI.currentDBpos[10]],0)}),a("#home-blocks").on("click",".home-block",function(b){if(a(this).hasClass("inactive"))a("#overlay-playsource-open").trigger("click");else if(a(this).is("#home-spotify-switch"))a("#overlay-playsource-open").trigger("click");else if(a(b.target).is("span.block-remove")){var c=a(this).attr("id");c=c.replace("home-bookmark-","");var d=a(this).find("h3").text();a.post("/db/?cmd=bookmark",{id:c,name:d})}else++GUI.currentDBpos[10],getDB({browsemode:a(this).data("browsemode"),path:a(this).data("path"),uplevel:0,plugin:a(this).data("plugin")})}),a("#db-homeSetup").click(function(){var b=a(this);b.hasClass("btn-primary")?(b.removeClass("btn-primary").addClass("btn-default"),a(".home-block-remove").remove()):(b.removeClass("btn-default").addClass("btn-primary"),a(".home-block.home-bookmark").append('
    ×
    '))});var f=a("#database-entries");f.on("click","li",function(b){var c="",d="",e=a(this);if(a(b.target).hasClass("db-action"))b.preventDefault(),c="spotify-track"===e.data("type")?e.data("plid")+"-"+e.data("path"):e.data("path"),GUI.DBentry[0]=c;else if(a("li.active","#database-entries").removeClass("active"),e.addClass("active"),e.hasClass("db-folder")){c=e.data("path"),e.hasClass("db-album")?""!==c?getDB({path:c,uplevel:0,browsemode:"album"}):(c=GUI.currentDBpath[GUI.currentDBpos[10]-1],getDB({path:c,uplevel:0,browsemode:"albumfilter"})):e.hasClass("db-artist")?getDB({path:c,uplevel:0,browsemode:"artist"}):e.hasClass("db-genre")?getDB({path:c,uplevel:0,browsemode:"genre"}):e.hasClass("db-spotify")?(c=GUI.currentpath+"/"+e.find("span").text(),getDB({path:c,plugin:"Spotify",args:e.data("path").toString(),querytype:"tracks"}),GUI.plugin="Spotify"):e.hasClass("db-dirble")?(c=GUI.currentpath+"/"+e.find("span").text(),getDB({path:c,plugin:"Dirble",querytype:"stations",args:e.data("path")}),GUI.plugin="Dirble"):e.hasClass("db-jamendo")||(d=e.data("browsemode"),getDB({path:c,uplevel:0,browsemode:d}));var f=e.attr("id");f=f.replace("db-",""),GUI.currentDBpos[GUI.currentDBpos[10]]=f,GUI.currentDBpath[GUI.currentDBpos[10]]=c,++GUI.currentDBpos[10]}else e.hasClass("db-webradio-add")&&a("#modal-webradio-add").modal()}),f.on("dblclick","li",function(b){var c=a(this);if(!a(b.target).hasClass("db-action")){a("li.active","#database-entries").removeClass("active"),c.addClass("active");var d=c.data("path");c.hasClass("db-spotify")?(d=c.attr("data-plid")+"-"+c.attr("data-path"),getDB({cmd:"spaddplay",path:d,querytype:"spotify-track"})):(d=c.hasClass("db-dirble")?d.split(" | ")[1]:d,getDB({cmd:"addplay",path:d}))}}),a("#db-level-up").click(function(){--GUI.currentDBpos[10];var a=GUI.currentpath;if(0===GUI.currentDBpos[10])a="";else if("file"===GUI.browsemode){var b=a.lastIndexOf("/");a=-1!==b?a.slice(0,b):""}else"album"===GUI.browsemode?(a=GUI.currentDBpath[GUI.currentDBpos[10]-1],""===a?a="Albums":GUI.browsemode="artist"):"artist"===GUI.browsemode?(a=GUI.currentDBpath[GUI.currentDBpos[10]-1],""===a?a="Artists":GUI.browsemode="genre"):"genre"===GUI.browsemode?a="Genres":"albumfilter"===GUI.browsemode&&(GUI.browsemode="artist",a=GUI.currentDBpath[GUI.currentDBpos[10]-1]);getDB({browsemode:GUI.browsemode,path:a,plugin:GUI.plugin,uplevel:1}),GUI.plugin=""}),a("#db-search-results").click(function(){a(this).addClass("hide"),a("#db-level-up").removeClass("hide"),getDB({path:GUI.currentpath})}),a("a",".context-menu").click(function(){var b=a(this).data("cmd"),c=a(this).data("type"),d=GUI.DBentry[0];switch(GUI.DBentry[0]="",b){case"pl-add":sendCmd('load "'+d+'"');break;case"pl-replace":sendCmd("clear"),sendCmd('load "'+d+'"');break;case"pl-rename":a("#modal-pl-rename").modal(),a("#pl-rename-oldname").text(d);break;case"pl-rm":a.ajax({url:"/command/?cmd=rm%20%22"+d+"%22",success:function(a){getPlaylists(a)}});break;case"wradd":d=d.split(" | ")[1],getDB({cmd:"add",path:d});break;case"wraddplay":d=d.split(" | ")[1],getDB({cmd:"addplay",path:d});break;case"wraddreplaceplay":d=d.split(" | ")[1],getDB({cmd:"addreplaceplay",path:d});break;case"wredit":a("#modal-webradio-edit").modal(),a.post("/db/?cmd=readradio",{filename:d},function(b){var c=a("#webradio-edit-name");c.val(b.name),c.data("file-name",b.name),a("#webradio-edit-url").val(b.url)},"json");break;case"wrdelete":a("#modal-webradio-delete").modal(),a("#webradio-delete-name").text(d.replace("Webradio/",""));break;case"wrsave":var e=d.split(" | ");a.post("/db/?cmd=addradio",{"radio[label]":e[0],"radio[url]":e[1]});break;default:getDB({cmd:b,path:d,browsemode:GUI.browsemode,querytype:c})}}),a("#webradio-add-button").click(function(){var b=a("#webradio-add-name").val(),c=a("#webradio-add-url").val();""===b||""===c?renderMSG([{title:"Missing fields",text:"Please fill both fields to continue",icon:"fa fa-warning"}]):(a.post("/db/?cmd=addradio",{"radio[label]":b,"radio[url]":c},function(a){},"json"),a("#modal-webradio-add").modal("hide"),a("#webradio-add-name").val(""),a("#webradio-add-url").val(""))}),a("#webradio-edit-button").click(function(){var b=a("#webradio-edit-name");a.post("/db/?cmd=editradio",{"radio[newlabel]":b.val(),"radio[label]":b.data("file-name"),"radio[url]":a("#webradio-edit-url").val()},function(a){},"json")}),a("#webradio-delete-button").click(function(){var b=a("#webradio-delete-name").text();a.post("/db/?cmd=deleteradio",{"radio[label]":b},function(a){},"json")}),a("#db-firstPage").click(function(){a.scrollTo(0,500)}),a("#db-prevPage").click(function(){var b="-="+a(window).height()+"px";a.scrollTo(b,500)}),a("#db-nextPage").click(function(){var b="+="+a(window).height()+"px";a.scrollTo(b,500)}),a("#db-lastPage").click(function(){a.scrollTo("100%",500)}),a("#pl-firstPage").click(function(){a.scrollTo(0,500)}),a("#pl-prevPage").click(function(){var b=a(window).scrollTop(),c=b-a(window).height();a.scrollTo(c,500)}),a("#pl-nextPage").click(function(){var b=a(window).scrollTop(),c=b+a(window).height();a.scrollTo(c,500)}),a("#pl-lastPage").click(function(){a.scrollTo("100%",500)});var g=document.location.toString();g.match("#")&&a('#menu-bottom a[href="/#'+g.split("#")[1]+'"]').tab("show"),a("#menu-bottom a").on("shown",function(a){history.pushState?history.pushState(null,null,a.target.hash):window.location.hash=a.target.hash}).on("click",function(){a("#overlay-social").hasClass("open")&&a(".overlay-close").trigger("click")}),a(".ttip").length&&a(".ttip").tooltip(),FastClick.attach(document.body),a("#syscmd-poweroff").click(function(){a.post("/settings/",{syscmd:"poweroff"}),toggleLoader()}),a("#syscmd-reboot").click(function(){a.post("/settings/",{syscmd:"reboot"}),toggleLoader()}),overlayTrigger("#overlay-social"),overlayTrigger("#overlay-playsource"),a("#playsource-mpd").click(function(){a(this).hasClass("inactive")&&(a.ajax({url:"/command/?switchplayer=MPD"}),a("#overlay-playsource-close").trigger("click"))}),a("#playsource-spotify").click(function(){a(this).hasClass("inactive")&&("1"===GUI.libraryhome.Spotify?(a.ajax({url:"/command/?switchplayer=Spotify"}),a("#overlay-playsource-close").trigger("click")):new PNotify({title:"Spotify not enabled",text:"Enable and configure it under the Settings screen",icon:"fa fa-exclamation-circle"}))})}):jQuery(document).ready(function(a){"use strict";if(GUI.mode=checkWebSocket(),playbackChannel(),PNotify.prototype.options.styling="fontawesome",PNotify.prototype.options.stack.dir1="up",PNotify.prototype.options.stack.dir2="left",PNotify.prototype.options.stack.firstpos1=90,PNotify.prototype.options.stack.firstpos2=50,PNotify.prototype.options.stack.spacing1=10,PNotify.prototype.options.stack.spacing2=10,notifyChannel(),a(".btn-cmd").click(function(){var b=a(this);commandButton(b)}),a("#syscmd-poweroff").click(function(){a.post("/settings/",{syscmd:"poweroff"}),toggleLoader()}),a("#syscmd-reboot").click(function(){a.post("/settings/",{syscmd:"reboot"}),toggleLoader()}),a(".selectpicker").selectpicker(),a("#section-sources").length&&("nfs"===a("#mount-type").val()&&a("#mount-cifs").addClass("disabled").children(".disabler").removeClass("hide"),a("#mount-type").change(function(){"cifs"===a(this).val()||"osx"===a(this).val()?a("#mount-cifs").removeClass("disabled").children(".disabler").addClass("hide"):a("#mount-cifs").addClass("disabled").children(".disabler").removeClass("hide")}),a("#nas-guest").change(function(){a(this).prop("checked")?a("#mount-auth").addClass("disabled").children(".disabler").removeClass("hide"):a("#mount-auth").removeClass("disabled").children(".disabler").addClass("hide")}),a("#nas-advanced").change(function(){a(this).prop("checked")?a("#mount-advanced-config").removeClass("hide"):a("#mount-advanced-config").addClass("hide")}),a("#show-mount-advanced-config").click(function(b){b.preventDefault(),a(this).hasClass("active")?(a("#mount-advanced-config").toggleClass("hide"),a(this).removeClass("active"),a(this).find("i").removeClass("fa fa-minus-circle").addClass("fa fa-plus-circle"),a(this).find("span").html("show advanced options")):(a("#mount-advanced-config").toggleClass("hide"),a(this).addClass("active"),a(this).find("i").removeClass("fa fa-plus-circle").addClass("fa fa-minus-circle"),a(this).find("span").html("hide advanced options"))}),a("#usb-mount-list a").click(function(){var b=a(this).data("mount");a("#usb-umount-name").html(b),a("#usb-umount").val(b)})),a("#section-settings").length&&(a("#airplay").change(function(){a(this).prop("checked")?(a("#airplayName").removeClass("hide"),a("#airplayBox").addClass("boxed-group")):(a("#airplayName").addClass("hide"),a("#airplayBox").removeClass("boxed-group"))}),a("#scrobbling-lastfm").change(function(){a(this).prop("checked")?(a("#lastfmAuth").removeClass("hide"),a("#lastfmBox").addClass("boxed-group")):(a("#lastfmAuth").addClass("hide"),a("#lastfmBox").removeClass("boxed-group"))}),a("#proxy").change(function(){a(this).prop("checked")?(a("#proxyAuth").removeClass("hide"),a("#proxyBox").addClass("boxed-group")):(a("#proxyAuth").addClass("hide"),a("#proxyBox").removeClass("boxed-group"))}),a("#dlna").change(function(){a(this).prop("checked")?(a("#dlnaName").removeClass("hide"),a("#dlnaBox").addClass("boxed-group")):(a("#dlnaName").addClass("hide"),a("#dlnaBox").removeClass("boxed-group"))}),a("#spotify").change(function(){a(this).prop("checked")?(a("#spotifyAuth").removeClass("hide"),a("#spotifyBox").addClass("boxed-group")):(a("#spotifyAuth").addClass("hide"),a("#spotifyBox").removeClass("boxed-group"))})),a("#section-network").length){var b=a("#network-manual-config");"0"===a("#dhcp").val()&&b.removeClass("hide"),a("#dhcp").change(function(){"0"===a(this).val()?b.removeClass("hide"):b.addClass("hide")});var c=a("#wifi-security-key");"open"!==a("#wifi-security").val()&&c.removeClass("hide"),a("#wifi-security").change(function(){"open"!==a(this).val()?c.removeClass("hide"):c.addClass("hide")}),a("#wifiNetworks").length&&(wlansChannel(),nicsChannel()),a("#wifiProfiles").change(function(){a(this).prop("checked")?a("#wifiProfilesBox").addClass("hide"):a("#wifiProfilesBox").removeClass("hide")})}if(a("#section-mpd").length&&(a("#audio-output-interface").change(function(){renderMSG([{title:"Switching audio output",text:"Please wait for the config update...",icon:"fa fa-cog fa-spin",delay:5e3}]);var b=a(this).val();a.ajax({type:"POST",url:"/mpd/",data:{ao:b}})}),a(".manual-edit-confirm").find(".btn-primary").click(function(){a("#mpdconf_editor").removeClass("hide"),a("#manual-edit-warning").addClass("hide")})),a("#section-debug").length){ZeroClipboard.config({swfPath:"/assets/js/vendor/ZeroClipboard.swf"});var d=new ZeroClipboard(document.getElementById("copy-to-clipboard"));d.on("ready",function(a){d.on("aftercopy",function(a){new PNotify({title:"Copied to clipboard",text:"The debug output was copied successfully in your clipboard.",icon:"fa fa-check"})})})}}); \ No newline at end of file