Merge remote-tracking branch 'origin/Over_The_Air_Update' into nvs_parameters

This commit is contained in:
Sebastien
2019-10-04 06:57:23 -04:00

View File

@@ -19,6 +19,7 @@ var commandHeader = 'squeezelite -b 500:2000 -d all=info ';
var pname, ver, otapct, otadsc; var pname, ver, otapct, otadsc;
var blockAjax = false; var blockAjax = false;
var blockFlashButton = false; var blockFlashButton = false;
var lastMsg = '';
var apList = null; var apList = null;
var selectedSSID = ""; var selectedSSID = "";
@@ -173,7 +174,7 @@ $(document).ready(function(){
$( "#wifi" ).slideDown( "fast", function() {}) $( "#wifi" ).slideDown( "fast", function() {})
}); });
$("#autoexec-cb").on("click", function() { $("input#autoexec-cb").on("click", function() {
autoexec = (this.checked)?1:0; autoexec = (this.checked)?1:0;
$.ajax({ $.ajax({
url: '/config.json', url: '/config.json',
@@ -181,7 +182,12 @@ $(document).ready(function(){
method: 'POST', method: 'POST',
cache: false, cache: false,
headers: { "X-Custom-autoexec": autoexec }, headers: { "X-Custom-autoexec": autoexec },
data: { 'timestamp': Date.now() } data: { 'timestamp': Date.now() },
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
if (thrownError != '') showMessage(thrownError);
}
}); });
console.log('sent config JSON with headers:', autoexec); console.log('sent config JSON with headers:', autoexec);
console.log('now triggering reboot'); console.log('now triggering reboot');
@@ -190,11 +196,16 @@ $(document).ready(function(){
dataType: 'json', dataType: 'json',
method: 'POST', method: 'POST',
cache: false, cache: false,
data: { 'timestamp': Date.now()} data: { 'timestamp': Date.now()},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
if (thrownError != '') showMessage(thrownError);
}
}); });
}); });
$("#save-autoexec1").on("click", function() { $("input#save-autoexec1").on("click", function() {
autoexec1 = $("#autoexec1").val(); autoexec1 = $("#autoexec1").val();
$.ajax({ $.ajax({
@@ -203,12 +214,17 @@ $(document).ready(function(){
method: 'POST', method: 'POST',
cache: false, cache: false,
headers: { "X-Custom-autoexec1": autoexec1 }, headers: { "X-Custom-autoexec1": autoexec1 },
data: { 'timestamp': Date.now() } data: { 'timestamp': Date.now() },
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
if (thrownError != '') showMessage(thrownError);
}
}); });
console.log('sent config JSON with headers:', autoexec1); console.log('sent config JSON with headers:', autoexec1);
}); });
$("#save-gpio").on("click", function() { $("input#save-gpio").on("click", function() {
var headers = {}; var headers = {};
$("input.gpio").each(function() { $("input.gpio").each(function() {
var id = $(this)[0].id; var id = $(this)[0].id;
@@ -227,6 +243,7 @@ $(document).ready(function(){
error: function (xhr, ajaxOptions, thrownError) { error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status); console.log(xhr.status);
console.log(thrownError); console.log(thrownError);
if (thrownError != '') showMessage(thrownError);
} }
}); });
console.log('sent config JSON with headers:', JSON.stringify(headers)); console.log('sent config JSON with headers:', JSON.stringify(headers));
@@ -256,6 +273,7 @@ $(document).ready(function(){
error: function (xhr, ajaxOptions, thrownError) { error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status); console.log(xhr.status);
console.log(thrownError); console.log(thrownError);
if (thrownError != '') showMessage(thrownError);
} }
}); });
console.log('sent config JSON with headers:', JSON.stringify(headers)); console.log('sent config JSON with headers:', JSON.stringify(headers));
@@ -271,7 +289,12 @@ $(document).ready(function(){
method: 'POST', method: 'POST',
cache: false, cache: false,
headers: { "X-Custom-fwurl": url }, headers: { "X-Custom-fwurl": url },
data: { 'timestamp': Date.now() } data: { 'timestamp': Date.now() },
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
if (thrownError != '') showMessage(thrownError);
}
}); });
enableStatusTimer = true; enableStatusTimer = true;
}); });
@@ -429,7 +452,12 @@ function performConnect(conntype){
method: 'POST', method: 'POST',
cache: false, cache: false,
headers: { 'X-Custom-ssid': selectedSSID, 'X-Custom-pwd': pwd }, headers: { 'X-Custom-ssid': selectedSSID, 'X-Custom-pwd': pwd },
data: { 'timestamp': Date.now()} data: { 'timestamp': Date.now()},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
if (thrownError != '') showMessage(thrownError);
}
}); });
//now we can re-set the intervals regardless of result //now we can re-set the intervals regardless of result
@@ -604,12 +632,11 @@ function checkStatus(){
$("span#flash-status").html(''); $("span#flash-status").html('');
} }
if (data.hasOwnProperty('message') && data['message'] != ''){ if (data.hasOwnProperty('message') && data['message'] != ''){
$('#message').html(data['message']); var msg = data['message'];
$("#content").fadeTo("slow", 0.3, function() { if (msg != lastMsg) {
$("#message").show(500).delay(5000).hide(500, function() { showMessage(msg);
$("#content").fadeTo("slow", 1.0); lastMsg = msg;
}); }
});
} }
blockAjax = false; blockAjax = false;
}) })
@@ -658,3 +685,12 @@ function getConfig() {
console.log("failed to fetch config!"); console.log("failed to fetch config!");
}); });
} }
function showMessage(message) {
$('#message').html(message);
$("#content").fadeTo("slow", 0.3, function() {
$("#message").show(500).delay(5000).hide(500, function() {
$("#content").fadeTo("slow", 1.0);
});
});
}