Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32.git into master-cmake

This commit is contained in:
Sebastien
2020-04-16 20:37:25 -04:00
2 changed files with 29 additions and 20 deletions

View File

@@ -643,16 +643,19 @@ function rssiToIcon(rssi){
function refreshAP(force){ function refreshAP(force){
if (!enableAPTimer && !force) return; if (!enableAPTimer && !force) return;
$.getJSON( "/ap.json", function( data ) { $.getJSON( "/scan.json", async function( data ) {
if(data.length > 0){ await sleep(2000);
//sort by signal strength $.getJSON( "/ap.json", function( data ) {
data.sort(function (a, b) { if(data.length > 0){
var x = a["rssi"]; var y = b["rssi"]; //sort by signal strength
return ((x < y) ? 1 : ((x > y) ? -1 : 0)); data.sort(function (a, b) {
}); var x = a["rssi"]; var y = b["rssi"];
apList = data; return ((x < y) ? 1 : ((x > y) ? -1 : 0));
refreshAPHTML(apList); });
} apList = data;
refreshAPHTML(apList);
}
});
}); });
} }
@@ -667,8 +670,8 @@ function refreshAPHTML(data){
} }
function getMessages() { function getMessages() {
$.getJSON("/messages.json?1", function(data) { $.getJSON("/messages.json?1", async function(data) {
data.forEach(function(msg) { for (const msg of data) {
var msg_age = msg["current_time"] - msg["sent_time"]; var msg_age = msg["current_time"] - msg["sent_time"];
var msg_time = new Date(); var msg_time = new Date();
msg_time.setTime( msg_time.getTime() - msg_age ); msg_time.setTime( msg_time.getTime() - msg_age );
@@ -701,7 +704,7 @@ function getMessages() {
}); });
break; break;
case "MESSAGING_CLASS_SYSTEM": case "MESSAGING_CLASS_SYSTEM":
showMessage(msg["message"], msg["type"],msg_age); var r = await showMessage(msg["message"], msg["type"],msg_age);
$("#syslogTable").append( $("#syslogTable").append(
"<tr class='"+msg["type"]+"'>"+ "<tr class='"+msg["type"]+"'>"+
@@ -713,8 +716,7 @@ function getMessages() {
default: default:
break; break;
} }
}); }
}) })
.fail(function(xhr, ajaxOptions, thrownError) { .fail(function(xhr, ajaxOptions, thrownError) {
console.log(xhr.status); console.log(xhr.status);
@@ -961,16 +963,22 @@ function showMessage(message, severity, age=0) {
} }
$('#message').html(message); $('#message').html(message);
$("#content").fadeTo("slow", 0.3, function() { return new Promise(function(resolve, reject) {
$("#message").show(500).delay(5000).hide(500, function() { $("#content").fadeTo("slow", 0.3, function() {
$("#content").fadeTo("slow", 1.0); $("#message").show(500).delay(5000).hide(500, function() {
$("#content").fadeTo("slow", 1.0, function() {
resolve(true);
});
});
}); });
}); });
} }
function inRange(x, min, max) { function inRange(x, min, max) {
return ((x-min)*(x-max) <= 0); return ((x-min)*(x-max) <= 0);
} }
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

View File

@@ -386,6 +386,7 @@ div#message {
margin-top: -2em; /*set to a negative number 1/2 of your height*/ margin-top: -2em; /*set to a negative number 1/2 of your height*/
border-radius: 8px; border-radius: 8px;
box-shadow: 0px 5px 2px -5px rgba(255, 255, 255, 0.5) inset, 0px 10px 20px -5px rgba(255, 255, 255, 0.1) inset, 0 0px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 3px 1px rgba(0, 0, 0, 0.12), 0 1px 10px 0 rgba(0, 0, 0, 0.3); box-shadow: 0px 5px 2px -5px rgba(255, 255, 255, 0.5) inset, 0px 10px 20px -5px rgba(255, 255, 255, 0.1) inset, 0 0px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 3px 1px rgba(0, 0, 0, 0.12), 0 1px 10px 0 rgba(0, 0, 0, 0.3);
z-index: 20;
} }
tr.hide { tr.hide {