',a+='
",r?$(e).append(a):$("#commands-list").append(a)}})),n.commands.forEach((function(t){$("[cmdname="+t.name+"]:input").val(""),$("[cmdname="+t.name+"]:checkbox").prop("checked",!1),t.argtable&&t.argtable.forEach((function(o){var r="#"+t.name+"-"+o.longopts,e=_n(n,t.name,o.longopts);o.checkbox?$(r)[0].checked=e:(void 0!==e&&$(r).val(e).trigger("change"),0===$(r)[0].value.length&&(o.datatype||"").includes("|")&&($(r)[0].value="--"))}))}))})).fail((function(n,t,o){404==n.status?$(".orec").hide():F(n,0,o),$("#commands-list").empty(),W=!1}))}function Rn(){$.getJSON("/config.json",(function(n){$("#nvsTable tr").remove();var t=n.config?n.config:n;nn=t,Object.keys(t).sort().forEach((function(n){var o=t[n].value;if("autoexec"===n)"0"===t.autoexec.value?$("#disable-squeezelite")[0].checked=!0:$("#disable-squeezelite")[0].checked=!1;else if("autoexec1"===n){var r=/-o\s?(["][^"]*["]|[^-]+)/g.exec(o);r[1].toUpperCase().startsWith("I2S")?P("i2s"):r[1].toUpperCase().startsWith("SPDIF")?P("spdif"):r[1].toUpperCase().startsWith('"BT')&&P("bt")}else"host_name"===n?(o=o.replaceAll('"',""),$("input#dhcp-name1").val(o),$("input#dhcp-name2").val(o),$("#player").val(o),document.title=o,rn=o):"rel_api"===n&&(V=o);$("tbody#nvsTable").append("
"+n+" | |
"),$("input#"+n).val(t[n].value)})),$("tbody#nvsTable").append("
| |
"),n.gpio?($("#pins").show(),$("tbody#gpiotable tr").remove(),n.gpio.forEach((function(n){$("tbody#gpiotable").append("
'+n.group+" | "+n.name+" | "+n.gpio+" | "+(n.fixed?"Fixed":"Configuration")+" |
---|
")}))):$("#pins").hide()})).fail((function(n,t,o){F(n,0,o),W=!1}))}function jn(n,t){On({message:n,type:t},new Date)}function On(n,t){var o="table-success";"MESSAGING_WARNING"===n.type?(o="table-warning","MESSAGING_INFO"===q&&(q="MESSAGING_WARNING")):"MESSAGING_ERROR"===n.type&&("MESSAGING_INFO"!==q&&"MESSAGING_WARNING"!==q||(q="MESSAGING_ERROR"),o="table-danger"),++Z>0&&($("#msgcnt").removeClass("badge-success"),$("#msgcnt").removeClass("badge-warning"),$("#msgcnt").removeClass("badge-danger"),$("#msgcnt").addClass(k[q]),$("#msgcnt").text(Z)),$("#syslogTable").append("
"+t.toLocalShort()+" | "+n.message.encodeHTML()+" |
")}function Cn(n,t,o){return(n-t)*(n-o)<=0}function In(n){return new m.Promise((function(t){return setTimeout(t,n)}))}m.Promise.prototype.delay=function(n){return this.then((function(t){return new m.Promise((function(o){setTimeout((function(){o(t)}),n)}))}),(function(t){return new m.Promise((function(o,r){setTimeout((function(){r(t)}),n)}))}))},window.saveAutoexec1=function(n){J("cfg-audio-tmpl","MESSAGING_INFO","Saving.\n",!1);var t='squeezelite -b 500:2000 -d all=info -C 30 -W -n "'+$("#player").val()+'"';"bt"===on?(t+=' -o "BT" -R -Z 192000',J("cfg-audio-tmpl","MESSAGING_INFO","Remember to configure the Bluetooth audio device name.\n",!0)):t+="spdif"===on?" -o SPDIF -Z 192000":" -o I2S",""!==$("#optional").val()&&(t+=" "+$("#optional").val());var o={timestamp:Date.now()};o.config={autoexec1:{value:t,type:33},autoexec:{value:$("#disable-squeezelite").prop("checked")?"0":"1",type:33}},$.ajax({url:"/config.json",dataType:"text",method:"POST",cache:!1,contentType:"application/json; charset=utf-8",data:JSON.stringify(o),error:F,complete:function(t){t.responseText.result&&"OK"===JSON.parse(t.responseText).result?(J("cfg-audio-tmpl","MESSAGING_INFO","Done.\n",!0),n&&hn(1500,"cfg-audio-tmpl")):t.responseText.result?J("cfg-audio-tmpl","MESSAGING_WARNING",JSON.parse(t.responseText).Result+"\n",!0):J("cfg-audio-tmpl","MESSAGING_ERROR",t.statusText+"\n"),console.log(t.responseText)}}),console.log("sent data:",JSON.stringify(o))},window.handleDisconnect=function(){$.ajax({url:"/connect.json",dataType:"text",method:"DELETE",cache:!1,contentType:"application/json; charset=utf-8",data:JSON.stringify({timestamp:Date.now()})})},window.handleConnect=function(){cn.ssid=$("#manual_ssid").val(),cn.pwd=$("#manual_pwd").val(),cn.dhcpname=$("#dhcp-name2").val(),$("*[class*='connecting']").hide(),$("#ssid-wait").text(cn.ssid),$(".connecting").show(),$.ajax({url:"/connect.json",dataType:"text",method:"POST",cache:!1,contentType:"application/json; charset=utf-8",data:JSON.stringify({timestamp:Date.now(),ssid:cn.ssid,pwd:cn.pwd}),error:F}),fn()},$(document).ready((function(){$("#wifiTable").on("click","tr",(function(){})),$("#fw-url-input").on("input",(function(){$(this).val().length>8&&($(this).val().startsWith("http://")||$(this).val().startsWith("https://"))?$("#start-flash").show():$("#start-flash").hide()})),$(".upSrch").on("input",(function(){var n=this.value;$("#rTable tr").removeClass(this.id+"_hide"),n.length>0&&$("#rTable td:nth-child(".concat($(this).parent().index()+1,")")).filter((function(){return!$(this).text().toUpperCase().includes(n.toUpperCase())})).parent().addClass(this.id+"_hide"),$('[class*="_hide"]').hide(),$("#rTable tr").not('[class*="_hide"]').show()})),setTimeout(wn,1500),$("#otadiv").on("hidden.bs.modal",(function(){R=N.NONE})),$("#WifiConnectDialog").on("shown.bs.modal",(function(){$("*[class*='connecting']").hide(),cn.Action!==gn?($(".connecting-init").show(),$("#manual_ssid").trigger("focus")):$n()})),$("#WifiConnectDialog").on("hidden.bs.modal",(function(){$("#WifiConnectDialog input").val("")})),$("#uCnfrm").on("shown.bs.modal",(function(){$("#selectedFWURL").text($("#fw-url-input").val())})),$("input#show-commands")[0].checked=1===tn,$('a[href^="#tab-commands"]').hide(),$("#load-nvs").on("click",(function(){$("#nvsfilename").trigger("click")})),$("#clear-syslog").on("click",(function(){Z=0,q="MESSAGING_INFO",$("#msgcnt").text(""),$("#syslogTable").html("")})),$("#wifiTable").on("click","tr",(function(){cn.Action=pn,$(this).children("td:eq(1)").text()!=mn.ssid?$(this).is(":last-child")?(cn.Action=bn,cn.ssid="",$("#manual_ssid").val(cn.ssid)):(cn.ssid=$(this).children("td:eq(1)").text(),$("#manual_ssid").val(cn.ssid)):cn.Action=gn})),$("#ok-credits").on("click",(function(){$("#credits").slideUp("fast",(function(){})),$("#app").slideDown("fast",(function(){}))})),$("#acredits").on("click",(function(n){n.preventDefault(),$("#app").slideUp("fast",(function(){})),$("#credits").slideDown("fast",(function(){}))})),$("input#show-commands").on("click",(function(){this.checked=this.checked?1:0,this.checked?($('a[href^="#tab-commands"]').show(),tn=1):(tn=0,$('a[href^="#tab-commands"]').hide())})),$("input#show-nvs").on("click",(function(){this.checked=this.checked?1:0,this.checked?$('*[href*="-nvs"]').show():$('*[href*="-nvs"]').hide()})),$("#save-as-nvs").on("click",(function(){var n=un(!0),t=document.createElement("a");t.href=URL.createObjectURL(new Blob([JSON.stringify(n,null,2)],{type:"text/plain"})),t.setAttribute("download","nvs_config_"+rn+"_"+Date.now()+"json"),document.body.appendChild(t),t.click(),document.body.removeChild(t)})),$("#save-nvs").on("click",(function(){I(un(!1))})),$("#fwUpload").on("click",(function(){var n=document.getElementById("flashfilename").files;0===n.length?alert("No file selected!"):B({event:U.START_OTA,file:n[0]})})),$("[name=output-tmpl]").on("click",(function(){P(this.id)})),$("#chkUpdates").on("click",(function(){$("#rTable").html(""),$.getJSON(V,(function(n){var t=[];n.forEach((function(n){var o=n.name.split("#")[3];t.includes(o)||t.push(o)}));var o="";t.forEach((function(n){o+='
"})),$("#fwbranch").append(o),n.forEach((function(n){var t="";n.assets.forEach((function(n){n.name.match(/\.bin$/)&&(t=n.browser_download_url)}));var o=n.name.split("#"),r=o[0],e=o[2],a=o[3],i=r.substr(r.lastIndexOf("-")+1);i="32"==i||"16"==i?i:"";var l=n.body;l=(l=(l=l.replace(/'/gi,'"')).replace(/[\s\S]+(### Revision Log[\s\S]+)### ESP-IDF Version Used[\s\S]+/,"$1")).replace(/- \(.+?\) /g,"- "),$("#rTable").append("
\n ").concat(r," | ").concat(new Date(n.created_at).toLocalShort(),"\n | ").concat(e," | ").concat(a," | ").concat(i," |
"))})),$("#searchfw").css("display","inline"),xn(dn)||xn(ln),$("#rTable tr.release").on("click",(function(){var n=this.attributes.fwurl.value;Q&&(n=n.replace(/.*\/download\//,Q+"/plugins/SqueezeESP32/firmware/")),$("#fw-url-input").val(n),$("#start-flash").show(),$("#rTable tr.release").removeClass("table-success table-warning"),$(this).addClass("table-success table-warning")}))})).fail((function(){alert("failed to fetch release history!")}))})),$("#fwcheck").on("click",(function(){$("#releaseTable").html(""),$("#fwbranch").empty(),$.getJSON(V,(function(n){var t,o=0,r=[];n.forEach((function(n){var t=n.name.split("#")[3];r.includes(t)||r.push(t)})),r.forEach((function(n){t+='
"})),$("#fwbranch").append(t),n.forEach((function(n){var t="";n.assets.forEach((function(n){n.name.match(/\.bin$/)&&(t=n.browser_download_url)}));var r=n.name.split("#"),e=r[0],a=r[1],i=r[2],l=r[3],d=n.body;d=(d=(d=d.replace(/'/gi,'"')).replace(/[\s\S]+(### Revision Log[\s\S]+)### ESP-IDF Version Used[\s\S]+/,"$1")).replace(/- \(.+?\) /g,"- ");var m=o++>6?" hide":"";$("#releaseTable").append("
"+e+" | "+new Date(n.created_at).toLocalShort()+" | "+i+" | "+a+" | "+l+" | |
")})),o>7&&($("#releaseTable").append("
|
"),$("#showallbutton").on("click",(function(){$("tr.hide").removeClass("hide"),$("tr#showall").addClass("hide")}))),$("#searchfw").css("display","inline")})).fail((function(){alert("failed to fetch release history!")}))})),$("#updateAP").on("click",(function(){wn(),console.log("refresh AP")})),Rn(),Nn(),fn()})),window.setURL=function(n){var t=n.dataset.url;$('[data-url^="http"]').addClass("btn-success").removeClass("btn-danger"),$('[data-url="'+t+'"]').addClass("btn-danger").removeClass("btn-success"),Q&&(t=t.replace(/.*\/download\//,Q+"/plugins/SqueezeESP32/firmware/")),$("#fwurl").val(t)},window.runCommand=function(n,t){var o=n.attributes.cmdname.value;J(n.attributes.cmdname.value,"MESSAGING_INFO","Executing.",!1);var r=document.getElementById("flds-"+o);if(o+=" ",r)for(var e=r.querySelectorAll("select,input"),a=0;a