make changelog halfway readable

This commit is contained in:
Christian Herzog
2019-09-29 21:45:55 +02:00
parent 4c839c041a
commit 2edd11a92c

View File

@@ -279,263 +279,264 @@ $(document).ready(function(){
} }
}); });
var [ver, idf, cfg, branch] = release.name.split('#'); var [ver, idf, cfg, branch] = release.name.split('#');
var body = release.body.replace(/\\n/ig, "<br />").replace(/\'/ig, "\""); var body = release.body;
var [date, time] = release.created_at.split('T'); body = body.replace(/\'/ig, "\"");
$("#releaseTable").append( body = body.replace(/[\s\S]+(### Revision Log[\s\S]+)### ESP-IDF Version Used[\s\S]+/, "$1");
"<tr>"+ body = body.replace(/- \(.+?\) /g, "- ");
"<td data-toggle='tooltip' title='"+body+"'>"+ver+"</td>"+ var [date, time] = release.created_at.split('T');
"<td>"+idf+"</td>"+ $("#releaseTable").append(
"<td>"+date+"</td>"+ "<tr>"+
"<td>"+cfg+"</td>"+ "<td data-toggle='tooltip' title='"+body+"'>"+ver+"</td>"+
"<td>"+branch+"</td>"+ "<td>"+idf+"</td>"+
"<td><input id='generate-command' type='button' class='btn btn-success' value='Select' data-url='"+url+"' onclick='setURL(this);' /></td>"+ "<td>"+date+"</td>"+
"</tr>" "<td>"+cfg+"</td>"+
); "<td>"+branch+"</td>"+
"<td><input id='generate-command' type='button' class='btn btn-success' value='Select' data-url='"+url+"' onclick='setURL(this);' /></td>"+
"</tr>"
);
}); });
}) })
.fail(function() { .fail(function() {
alert("failed to fetch release history!"); alert("failed to fetch release history!");
}); });
}); });
//first time the page loads: attempt to get the connection status and start the wifi scan //first time the page loads: attempt to get the connection status and start the wifi scan
refreshAP(); refreshAP();
getConfig(); getConfig();
//start timers //start timers
startCheckStatusInterval(); startCheckStatusInterval();
startRefreshAPInterval(); startRefreshAPInterval();
$('[data-toggle="tooltip"]').tooltip({ $('[data-toggle="tooltip"]').tooltip({
html: true, html: true,
placement : 'right', placement : 'right',
}); });
}); });
function setURL(button) { function setURL(button) {
var url = button.dataset.url; var url = button.dataset.url;
$("#fwurl").val(url); $("#fwurl").val(url);
$('[data-url^="http"]').addClass("btn-success").removeClass("btn-danger"); $('[data-url^="http"]').addClass("btn-success").removeClass("btn-danger");
$('[data-url="'+url+'"]').addClass("btn-danger").removeClass("btn-success"); $('[data-url="'+url+'"]').addClass("btn-danger").removeClass("btn-success");
}
function performConnect(conntype){
//stop the status refresh. This prevents a race condition where a status
//request would be refreshed with wrong ip info from a previous connection
//and the request would automatically shows as succesful.
stopCheckStatusInterval();
//stop refreshing wifi list
stopRefreshAPInterval();
var pwd;
if (conntype == 'manual') {
//Grab the manual SSID and PWD
selectedSSID=$('#manual_ssid').val();
pwd = $("#manual_pwd").val();
}else{
pwd = $("#pwd").val();
} }
//reset connection
$( "#loading" ).show();
$( "#connect-success" ).hide();
$( "#connect-fail" ).hide();
function performConnect(conntype){ $( "#ok-connect" ).prop("disabled",true);
//stop the status refresh. This prevents a race condition where a status $( "#ssid-wait" ).text(selectedSSID);
//request would be refreshed with wrong ip info from a previous connection $( "#connect" ).slideUp( "fast", function() {});
//and the request would automatically shows as succesful. $( "#connect_manual" ).slideUp( "fast", function() {});
stopCheckStatusInterval(); $( "#connect-wait" ).slideDown( "fast", function() {});
//stop refreshing wifi list $.ajax({
stopRefreshAPInterval(); url: '/connect.json',
dataType: 'json',
method: 'POST',
cache: false,
headers: { 'X-Custom-ssid': selectedSSID, 'X-Custom-pwd': pwd },
data: { 'timestamp': Date.now()}
});
var pwd; //now we can re-set the intervals regardless of result
if (conntype == 'manual') { startCheckStatusInterval();
//Grab the manual SSID and PWD startRefreshAPInterval();
selectedSSID=$('#manual_ssid').val(); }
pwd = $("#manual_pwd").val();
}else{
pwd = $("#pwd").val();
}
//reset connection
$( "#loading" ).show();
$( "#connect-success" ).hide();
$( "#connect-fail" ).hide();
$( "#ok-connect" ).prop("disabled",true); function rssiToIcon(rssi){
$( "#ssid-wait" ).text(selectedSSID); if(rssi >= -60){
$( "#connect" ).slideUp( "fast", function() {}); return 'w0';
$( "#connect_manual" ).slideUp( "fast", function() {});
$( "#connect-wait" ).slideDown( "fast", function() {});
$.ajax({
url: '/connect.json',
dataType: 'json',
method: 'POST',
cache: false,
headers: { 'X-Custom-ssid': selectedSSID, 'X-Custom-pwd': pwd },
data: { 'timestamp': Date.now()}
});
//now we can re-set the intervals regardless of result
startCheckStatusInterval();
startRefreshAPInterval();
} }
else if(rssi >= -67){
function rssiToIcon(rssi){ return 'w1';
if(rssi >= -60){
return 'w0';
}
else if(rssi >= -67){
return 'w1';
}
else if(rssi >= -75){
return 'w2';
}
else{
return 'w3';
}
} }
else if(rssi >= -75){
function refreshAP(){ return 'w2';
if (!enableAPTimer) return;
$.getJSON( "/ap.json", function( data ) {
if(data.length > 0){
//sort by signal strength
data.sort(function (a, b) {
var x = a["rssi"]; var y = b["rssi"];
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
});
apList = data;
refreshAPHTML(apList);
}
});
} }
else{
function refreshAPHTML(data){ return 'w3';
var h = "";
data.forEach(function(e, idx, array) {
h += '<div class="ape{0}"><div class="{1}"><div class="{2}">{3}</div></div></div>'.format(idx === array.length - 1?'':' brdb', rssiToIcon(e.rssi), e.auth==0?'':'pw',e.ssid);
h += "\n";
});
$( "#wifi-list" ).html(h)
} }
}
function checkStatus(){ function refreshAP(){
RepeatCheckStatusInterval(); if (!enableAPTimer) return;
if (!enableStatusTimer) return; $.getJSON( "/ap.json", function( data ) {
if (blockAjax) return; if(data.length > 0){
blockAjax = true; //sort by signal strength
$.getJSON( "/status.json", function( data ) { data.sort(function (a, b) {
if(data.hasOwnProperty('ssid') && data['ssid'] != ""){ var x = a["rssi"]; var y = b["rssi"];
if(data["ssid"] === selectedSSID){ return ((x < y) ? 1 : ((x > y) ? -1 : 0));
//that's a connection attempt });
if(data["urc"] === 0){ apList = data;
//got connection refreshAPHTML(apList);
$("#connected-to span").text(data["ssid"]); }
$("#connect-details h1").text(data["ssid"]); });
$("#ip").text(data["ip"]); }
$("#netmask").text(data["netmask"]);
$("#gw").text(data["gw"]);
$("#wifi-status").slideDown( "fast", function() {});
$("span#foot-wifi").html(", SSID: <strong>"+data["ssid"]+"</strong>, IP: <strong>"+data["ip"]+"</strong>");
//unlock the wait screen if needed function refreshAPHTML(data){
$( "#ok-connect" ).prop("disabled",false); var h = "";
data.forEach(function(e, idx, array) {
h += '<div class="ape{0}"><div class="{1}"><div class="{2}">{3}</div></div></div>'.format(idx === array.length - 1?'':' brdb', rssiToIcon(e.rssi), e.auth==0?'':'pw',e.ssid);
h += "\n";
});
//update wait screen $( "#wifi-list" ).html(h)
$( "#loading" ).hide(); }
$( "#connect-success" ).append("<p>Your IP address now is: " + text(data["ip"]) + "</p>");
$( "#connect-success" ).show();
$( "#connect-fail" ).hide();
enableAPTimer = false; function checkStatus(){
if (!recovery) enableStatusTimer = false; RepeatCheckStatusInterval();
} if (!enableStatusTimer) return;
else if(data["urc"] === 1){ if (blockAjax) return;
//failed attempt blockAjax = true;
$("#connected-to span").text(''); $.getJSON( "/status.json", function( data ) {
$("#connect-details h1").text(''); if(data.hasOwnProperty('ssid') && data['ssid'] != ""){
$("#ip").text('0.0.0.0'); if(data["ssid"] === selectedSSID){
$("#netmask").text('0.0.0.0'); //that's a connection attempt
$("#gw").text('0.0.0.0'); if(data["urc"] === 0){
$("span#foot-wifi").html(""); //got connection
$("#connected-to span").text(data["ssid"]);
$("#connect-details h1").text(data["ssid"]);
$("#ip").text(data["ip"]);
$("#netmask").text(data["netmask"]);
$("#gw").text(data["gw"]);
$("#wifi-status").slideDown( "fast", function() {});
$("span#foot-wifi").html(", SSID: <strong>"+data["ssid"]+"</strong>, IP: <strong>"+data["ip"]+"</strong>");
//don't show any connection //unlock the wait screen if needed
$("#wifi-status").slideUp( "fast", function() {}); $( "#ok-connect" ).prop("disabled",false);
//unlock the wait screen //update wait screen
$( "#ok-connect" ).prop("disabled",false); $( "#loading" ).hide();
$( "#connect-success" ).append("<p>Your IP address now is: " + text(data["ip"]) + "</p>");
$( "#connect-success" ).show();
$( "#connect-fail" ).hide();
//update wait screen
$( "#loading" ).hide();
$( "#connect-fail" ).show();
$( "#connect-success" ).hide();
enableAPTimer = true;
enableStatusTimer = true;
}
}
else if(data.hasOwnProperty('urc') && data['urc'] === 0){
//ESP32 is already connected to a wifi without having the user do anything
if( !($("#wifi-status").is(":visible")) ){
$("#connected-to span").text(data["ssid"]);
$("#connect-details h1").text(data["ssid"]);
$("#ip").text(data["ip"]);
$("#netmask").text(data["netmask"]);
$("#gw").text(data["gw"]);
$("#wifi-status").slideDown( "fast", function() {});
$("span#foot-wifi").html(", SSID: <strong>"+data["ssid"]+"</strong>, IP: <strong>"+data["ip"]+"</strong>");
}
enableAPTimer = false; enableAPTimer = false;
if (!recovery) enableStatusTimer = false; if (!recovery) enableStatusTimer = false;
} }
} else if(data["urc"] === 1){
else if(data.hasOwnProperty('urc') && data['urc'] === 2){ //failed attempt
//that's a manual disconnect $("#connected-to span").text('');
if($("#wifi-status").is(":visible")){ $("#connect-details h1").text('');
$("#wifi-status").slideUp( "fast", function() {}); $("#ip").text('0.0.0.0');
$("#netmask").text('0.0.0.0');
$("#gw").text('0.0.0.0');
$("span#foot-wifi").html(""); $("span#foot-wifi").html("");
}
enableAPTimer = true;
enableStatusTimer = true;
}
if (data.hasOwnProperty('recovery')) {
if (data["recovery"] === 1) {
recovery = true;
$("#otadiv").show();
enableStatusTimer = true;
} else {
recovery = false;
$("#otadiv").hide();
enableStatusTimer = false;
}
}
if(data.hasOwnProperty('project_name') && data['project_name'] != ''){
pname = data['project_name'];
}
if(data.hasOwnProperty('version') && data['version'] != ''){
ver = data['version'];
$("span#foot-fw").html("fw: <strong>"+ver+"</strong>, mode: <strong>"+pname+"</strong>");
}
if(data.hasOwnProperty('ota_pct') && data['ota_pct'] != 0){
otapct = data['ota_pct'];
$('.progress-bar').css('width', otapct+'%').attr('aria-valuenow', otapct);
$('.progress-bar').html(otapct+'%');
}
blockAjax = false;
})
.fail(function() {
//don't do anything, the server might be down while esp32 recalibrates radio
});
}
function getConfig() { //don't show any connection
$.getJSON("/config.json", function(data) { $("#wifi-status").slideUp( "fast", function() {});
if (data.hasOwnProperty('autoexec')) {
if (data["autoexec"] === 1) { //unlock the wait screen
console.log('turn on autoexec'); $( "#ok-connect" ).prop("disabled",false);
$("#autoexec-cb")[0].checked=true;
} else { //update wait screen
console.log('turn off autoexec'); $( "#loading" ).hide();
$("#autoexec-cb")[0].checked=false; $( "#connect-fail" ).show();
$( "#connect-success" ).hide();
enableAPTimer = true;
enableStatusTimer = true;
} }
} }
if (data.hasOwnProperty('list')) { else if(data.hasOwnProperty('urc') && data['urc'] === 0){
data.list.forEach(function(line) { //ESP32 is already connected to a wifi without having the user do anything
let key = Object.keys(line)[0]; if( !($("#wifi-status").is(":visible")) ){
let val = Object.values(line)[0]; $("#connected-to span").text(data["ssid"]);
console.log(key, val); $("#connect-details h1").text(data["ssid"]);
if (key == 'autoexec1') { $("#ip").text(data["ip"]);
$("#autoexec1").val(val); $("#netmask").text(data["netmask"]);
} $("#gw").text(data["gw"]);
}); $("#wifi-status").slideDown( "fast", function() {});
$("span#foot-wifi").html(", SSID: <strong>"+data["ssid"]+"</strong>, IP: <strong>"+data["ip"]+"</strong>");
}
enableAPTimer = false;
if (!recovery) enableStatusTimer = false;
} }
}) }
.fail(function() { else if(data.hasOwnProperty('urc') && data['urc'] === 2){
console.log("failed to fetch config!"); //that's a manual disconnect
}); if($("#wifi-status").is(":visible")){
} $("#wifi-status").slideUp( "fast", function() {});
$("span#foot-wifi").html("");
}
enableAPTimer = true;
enableStatusTimer = true;
}
if (data.hasOwnProperty('recovery')) {
if (data["recovery"] === 1) {
recovery = true;
$("#otadiv").show();
enableStatusTimer = true;
} else {
recovery = false;
$("#otadiv").hide();
enableStatusTimer = false;
}
}
if(data.hasOwnProperty('project_name') && data['project_name'] != ''){
pname = data['project_name'];
}
if(data.hasOwnProperty('version') && data['version'] != ''){
ver = data['version'];
$("span#foot-fw").html("fw: <strong>"+ver+"</strong>, mode: <strong>"+pname+"</strong>");
}
if(data.hasOwnProperty('ota_pct') && data['ota_pct'] != 0){
otapct = data['ota_pct'];
$('.progress-bar').css('width', otapct+'%').attr('aria-valuenow', otapct);
$('.progress-bar').html(otapct+'%');
}
blockAjax = false;
})
.fail(function() {
//don't do anything, the server might be down while esp32 recalibrates radio
});
}
function getConfig() {
$.getJSON("/config.json", function(data) {
if (data.hasOwnProperty('autoexec')) {
if (data["autoexec"] === 1) {
console.log('turn on autoexec');
$("#autoexec-cb")[0].checked=true;
} else {
console.log('turn off autoexec');
$("#autoexec-cb")[0].checked=false;
}
}
if (data.hasOwnProperty('list')) {
data.list.forEach(function(line) {
let key = Object.keys(line)[0];
let val = Object.values(line)[0];
console.log(key, val);
if (key == 'autoexec1') {
$("#autoexec1").val(val);
}
});
}
})
.fail(function() {
console.log("failed to fetch config!");
});
}