mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 12:37:01 +03:00
nvs editor working
This commit is contained in:
@@ -214,7 +214,7 @@ $(document).ready(function(){
|
||||
var id = $(this)[0].id;
|
||||
var pin = $(this).val();
|
||||
if (pin != '') {
|
||||
headers[id] = pin;
|
||||
headers["X-Custom-"+id] = pin;
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
@@ -222,8 +222,41 @@ $(document).ready(function(){
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
headers: JSON.stringify(headers),
|
||||
data: { 'timestamp': Date.now() }
|
||||
headers: headers,
|
||||
data: { 'timestamp': Date.now() },
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr.status);
|
||||
console.log(thrownError);
|
||||
}
|
||||
});
|
||||
console.log('sent config JSON with headers:', JSON.stringify(headers));
|
||||
});
|
||||
|
||||
$("#save-nvs").on("click", function() {
|
||||
var headers = {};
|
||||
$("input.nvs").each(function() {
|
||||
var key = $(this)[0].id;
|
||||
var val = $(this).val();
|
||||
if (key != '') {
|
||||
headers["X-Custom-"+key] = val;
|
||||
}
|
||||
});
|
||||
var key = $("#nvs-new-key").val();
|
||||
var val = $("#nvs-new-value").val();
|
||||
if (key != '') {
|
||||
headers["X-Custom-"+key] = val;
|
||||
}
|
||||
$.ajax({
|
||||
url: '/config.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
headers: headers,
|
||||
data: { 'timestamp': Date.now() },
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr.status);
|
||||
console.log(thrownError);
|
||||
}
|
||||
});
|
||||
console.log('sent config JSON with headers:', JSON.stringify(headers));
|
||||
});
|
||||
@@ -503,7 +536,7 @@ function checkStatus(){
|
||||
$("#otadiv").hide();
|
||||
$('a[href^="#tab-audio"]').show();
|
||||
$('a[href^="#tab-gpio"]').show();
|
||||
//$('a[href^="#tab-nvs"]').hide(); //TODO
|
||||
$('a[href^="#tab-nvs"]').hide();
|
||||
$( "footer.footer" ).removeClass('recovery');
|
||||
$( "footer.footer" ).addClass('sl');
|
||||
enableStatusTimer = false;
|
||||
@@ -549,34 +582,35 @@ function getConfig() {
|
||||
$("#autoexec-cb")[0].checked=false;
|
||||
}
|
||||
} else if (key == 'autoexec1') {
|
||||
$("#autoexec1").val(data["autoexec1"]);
|
||||
$("input#autoexec1").val(data["autoexec1"]);
|
||||
}
|
||||
|
||||
if (recovery) {
|
||||
$("tbody#nvsTable").append(
|
||||
"<tr>"+
|
||||
"<td>"+key+"</td>"+
|
||||
"<td>"+
|
||||
"<input type='text' class='form-control' id='nvs'+key value='"+data[key]+"'>"+
|
||||
"<td class='value'>"+
|
||||
"<input type='text' class='form-control nvs' id='"+key+"'>"+
|
||||
"</td>"+
|
||||
"</tr>"
|
||||
);
|
||||
//TODO append empty line
|
||||
$("input#"+key).val(data[key]);
|
||||
console.log("#"+key, data[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (data.hasOwnProperty('autoexec')) {
|
||||
if (data["autoexec"] === 1) {
|
||||
$("#autoexec-cb")[0].checked=true;
|
||||
} else {
|
||||
$("#autoexec-cb")[0].checked=false;
|
||||
}
|
||||
if (recovery) {
|
||||
$("tbody#nvsTable").append(
|
||||
"<tr>"+
|
||||
"<td>"+
|
||||
"<input type='text' class='form-control' id='nvs-new-key' placeholder='new key'>"+
|
||||
"</td>"+
|
||||
"<td>"+
|
||||
"<input type='text' class='form-control' id='nvs-new-value' placeholder='new value'>"+
|
||||
"</td>"+
|
||||
"</tr>"
|
||||
);
|
||||
}
|
||||
if (data.hasOwnProperty('autoexec')) {
|
||||
$("#autoexec1").val(data["autoexec1"]);
|
||||
}
|
||||
*/
|
||||
})
|
||||
.fail(function() {
|
||||
console.log("failed to fetch config!");
|
||||
|
||||
@@ -204,50 +204,36 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Signal</th>
|
||||
<th scope="col">GPIO pin</th>
|
||||
<th scope="col">I2S pin</th>
|
||||
<th scope="col">SPDIF pin</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="gpioTable">
|
||||
<tr>
|
||||
<td><strong>I2S</strong></td><td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>I2S Bit clock</td>
|
||||
<td>Bit clock</td>
|
||||
<td>
|
||||
<input type="text" class="form-control gpio" id="gpio-i2s-bc" maxlength="2" size="2">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control gpio" id="gpio-spdif-bc" maxlength="2" size="2">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>I2S Word select</td>
|
||||
<td>Word select</td>
|
||||
<td>
|
||||
<input type="text" class="form-control gpio" id="gpio-i2s-ws" maxlength="2" size="2">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control gpio" id="gpio-spdif-ws" maxlength="2" size="2">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>I2S Data</td>
|
||||
<td>Data</td>
|
||||
<td>
|
||||
<input type="text" class="form-control gpio" id="gpio-i2s-data" maxlength="2" size="2">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>SPDIF</strong></td><td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SPDIF Bit clock</td>
|
||||
<td>
|
||||
<input type="text" class="form-control gpio" id="spdif-i2s-bc" maxlength="2" size="2">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SPDIF Word select</td>
|
||||
<td>
|
||||
<input type="text" class="form-control gpio" id="spdif-i2s-ws" maxlength="2" size="2">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SPDIF Data</td>
|
||||
<td>
|
||||
<input type="text" class="form-control gpio" id="spdif-i2s-data" maxlength="2" size="2">
|
||||
<input type="text" class="form-control gpio" id="gpio-spdif-data" maxlength="2" size="2">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -323,3 +323,7 @@ span#flash-status {
|
||||
.recovery {
|
||||
background-color: #3c0505;
|
||||
}
|
||||
|
||||
td.value {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user