mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 05:57:05 +03:00
make buttons work
This commit is contained in:
@@ -24,6 +24,7 @@ var StatusIntervalActive = false;
|
||||
var ConfigIntervalActive = false;
|
||||
var RefreshAPIIntervalActive = false;
|
||||
|
||||
var output = '';
|
||||
//TODO check
|
||||
var to = 0, set_int = 0;
|
||||
|
||||
@@ -65,7 +66,7 @@ function RepeatCheckConfigInterval(){
|
||||
|
||||
function RepeatRefreshAPInterval(){
|
||||
if(RefreshAPIIntervalActive)
|
||||
startRefreshAPInterval()
|
||||
startRefreshAPInterval();
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
@@ -175,16 +176,81 @@ $(document).ready(function(){
|
||||
$( "#wifi" ).slideDown( "fast", function() {})
|
||||
});
|
||||
|
||||
$("#update-command").click(function() {
|
||||
updateAutoexec();
|
||||
$("#autoexec-cb").on("click", function() {
|
||||
autoexec = (this.checked)?1:0;
|
||||
$.ajax({
|
||||
url: '/config.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
headers: { "X-Custom-autoexec": autoexec },
|
||||
data: { 'timestamp': Date.now() }
|
||||
});
|
||||
console.log('sent config JSON with headers:', autoexec);
|
||||
});
|
||||
|
||||
$("#save-autoexec1").on("click", function() {
|
||||
autoexec1 = $("#autoexec1").val();
|
||||
|
||||
$.ajax({
|
||||
url: '/config.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
headers: { "X-Custom-autoexec1": autoexec1 },
|
||||
data: { 'timestamp': Date.now() }
|
||||
});
|
||||
console.log('sent config JSON with headers:', autoexec1);
|
||||
});
|
||||
|
||||
$("#recovery").on("click", function() {
|
||||
$.ajax({
|
||||
url: '/recovery.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
data: { 'timestamp': Date.now()}
|
||||
});
|
||||
});
|
||||
|
||||
$("#reboot").on("click", function() {
|
||||
$.ajax({
|
||||
url: '/reboot.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
data: { 'timestamp': Date.now()}
|
||||
});
|
||||
});
|
||||
|
||||
$("#generate-command").on("click", function() {
|
||||
var commandLine = commandHeader + '-n ' + $("#player").val();
|
||||
|
||||
if (output == 'bt') {
|
||||
commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -Z 192000';
|
||||
} else if (output == 'spdif') {
|
||||
commandLine += ' -o SPDIF -R -Z 192000';
|
||||
} else {
|
||||
commandLine += ' -o I2S';
|
||||
}
|
||||
if ($("#optional").val() != '') {
|
||||
commandLine += ' ' + $("#optional").val();
|
||||
}
|
||||
$("#autoexec1").val(commandLine);
|
||||
});
|
||||
|
||||
$("#generate-command").click(function() {
|
||||
generateCommand();
|
||||
});
|
||||
|
||||
$('[name=audio]').click(function(){
|
||||
selectOutput(this);
|
||||
$('[name=audio]').on("click", function(){
|
||||
console.log(this);
|
||||
if (this.id == 'bt') {
|
||||
$("#btsinkdiv").show(200);
|
||||
output = 'bt';
|
||||
} else if (this.id == 'spdif') {
|
||||
$("#btsinkdiv").hide(200);
|
||||
output = 'spdif';
|
||||
} else {
|
||||
$("#btsinkdiv").hide(200);
|
||||
output = 'i2s';
|
||||
}
|
||||
});
|
||||
|
||||
//first time the page loads: attempt to get the connection status and start the wifi scan
|
||||
@@ -240,8 +306,6 @@ function performConnect(conntype){
|
||||
startRefreshAPInterval();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function rssiToIcon(rssi){
|
||||
if(rssi >= -60){
|
||||
return 'w0';
|
||||
@@ -367,7 +431,6 @@ function getConfig() {
|
||||
} else {
|
||||
console.log('turn off autoexec');
|
||||
$("#autoexec-cb")[0].checked=false;
|
||||
$("#autoexec-command").hide(200);
|
||||
}
|
||||
}
|
||||
if (data.hasOwnProperty('recovery')) {
|
||||
@@ -399,77 +462,8 @@ function getConfig() {
|
||||
});
|
||||
}
|
||||
|
||||
function updateAutoexec(){
|
||||
autoexec = ($("#autoexec-cb")[0].checked)?1:0;
|
||||
autoexec1 = $("#autoexec1").val();
|
||||
|
||||
$.ajax({
|
||||
url: '/config.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
headers: { "X-Custom-autoexec": autoexec, "X-Custom-autoexec1": autoexec1 },
|
||||
data: { 'timestamp': Date.now() }
|
||||
});
|
||||
console.log('sent config JSON with headers:', autoexec, autoexec1);
|
||||
}
|
||||
|
||||
var output = '';
|
||||
function selectOutput(el) {
|
||||
if ($(el).attr('id') == 'bt') {
|
||||
$("#btsinkdiv").show(200);
|
||||
output = 'bt';
|
||||
} else if ($(el).attr('id') == 'spdif') {
|
||||
$("#btsinkdiv").hide(200);
|
||||
output = 'spdif';
|
||||
} else {
|
||||
$("#btsinkdiv").hide(200);
|
||||
output = 'i2s';
|
||||
}
|
||||
}
|
||||
|
||||
function generateCommand() {
|
||||
var commandLine = commandHeader + '-n ' + $("#player").val();
|
||||
|
||||
if (output == 'bt') {
|
||||
commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -Z 192000';
|
||||
} else if (output == 'spdif') {
|
||||
commandLine += ' -o SPDIF -R -Z 192000';
|
||||
} else {
|
||||
commandLine += ' -o I2S';
|
||||
}
|
||||
if ($("#optional").val() != '') {
|
||||
commandLine += ' ' + $("#optional").val();
|
||||
}
|
||||
$("#autoexec1").val(commandLine);
|
||||
}
|
||||
|
||||
function handleClick(item) {
|
||||
console.log(item);
|
||||
if (item.id == 'autoexec-cb') {
|
||||
if (item.checked) {
|
||||
$("#autoexec-command").show(200);
|
||||
} else {
|
||||
$("#autoexec-command").hide(200);
|
||||
}
|
||||
} else if (item.id == 'recovery') {
|
||||
$.ajax({
|
||||
url: '/recovery.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
data: { 'timestamp': Date.now()}
|
||||
});
|
||||
} else if (item.id == 'reboot') {
|
||||
$.ajax({
|
||||
url: '/reboot.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
data: { 'timestamp': Date.now()}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//TODO daduke check
|
||||
function file_change() {
|
||||
|
||||
Reference in New Issue
Block a user