/* clang-format off */

static const char html_sysinfo_script[] PROGMEM = R"=====(
<script>
  function g(i) { return document.getElementById(i) };
  var xhttp, updateTime, reqTime, reqFin;
  function transmit(f) {
    if (!xhttp) { 
      reqTime = 0;
      reqFin = false;
      xhttp = new XMLHttpRequest();
      xhttp.timeout = 1000;
      xhttp.overrideMimeType("application/json");
      xhttp.open('GET', 'sysinfod');
      xhttp.send(f ? (new FormData(f)) : '');
      xhttp.onreadystatechange = function () {
        if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
          var data = JSON.parse(xhttp.responseText);
          if(data.DevName !== undefined) g('DevName').innerHTML = data.DevName;
          if(data.HostName !== undefined) g('HostName').innerHTML = data.HostName;
          if(data.SSID !== undefined) g('SSID').innerHTML = data.SSID;
          if(data.WiFiConf !== undefined) {
            if(data.WiFiConf == 1) g('WiFiConf').innerHTML = 'Default';
            else if(data.WiFiConf == 2) g('WiFiConf').innerHTML = 'Fallback';
            else g('WiFiConf').innerHTML = data.WiFiConf;
            }
          if(data.MAC !== undefined) g('MAC').innerHTML = data.MAC;
          if(data.IP !== undefined) g('IP').innerHTML = data.IP;
          if(data.GW !== undefined) g('GW').innerHTML = data.GW;
          if(data.DNS !== undefined) g('DNS').innerHTML = data.DNS;
          if(data.UpTime !== undefined) g('UpTime').innerHTML = data.UpTime;
          if(data.HeapFree !== undefined) g('HeapFree').innerHTML = data.HeapFree + ' Bytes';
          if(data.HeapFragment !== undefined) g('HeapFragment').innerHTML = data.HeapFragment + ' %';
          if(data.HeapMaxBlock !== undefined) g('HeapMaxBlock').innerHTML = data.HeapMaxBlock + ' Bytes';
          if(data.ResetReason !== undefined) g('ResetReason').innerHTML = data.ResetReason;
          if(data.FWName !== undefined) g('FWName').innerHTML = data.FWName;
          if(data.FWVer !== undefined) g('FWVer').innerHTML = data.FWVer;
          if(data.FWBuilt !== undefined) g('FWBuilt').innerHTML = data.FWBuilt;
          if(data.FWCr !== undefined) g('FWCr').innerHTML = data.FWCr;
          if(data.FWDebug !== undefined) g('FWDebug').innerHTML = data.FWDebug;
          if(data.CoreVersion !== undefined) g('CoreVersion').innerHTML = data.CoreVersion;
          if(data.SDKVersion !== undefined) g('SDKVersion').innerHTML = data.SDKVersion;
          if(data.CPUfreq !== undefined) g('CPUfreq').innerHTML = data.CPUfreq + ' MHz';
          if(data.SketchSize !== undefined) g('SketchSize').innerHTML = data.SketchSize + ' Bytes';
          if(data.FlashSize !== undefined) g('FlashSize').innerHTML = data.FlashSize + ' Bytes';
          if(data.Time !== undefined) g('Time').innerHTML = data.Time;
          if(data.Date !== undefined) g('Date').innerHTML = data.Date;
          if(data.mqtthost !== undefined) g('mqtthost').innerHTML = data.mqtthost;
          if(data.mqttstate !== undefined) g('mqttstate').innerHTML = data.mqttstate;
          if(data.mqttreconn !== undefined) g('mqttreconn').innerHTML = data.mqttreconn;
          if(data.mqttTopIn !== undefined) g('mqttTopIn').innerHTML = data.mqttTopIn;
          if(data.mqttTopLog !== undefined) g('mqttTopLog').innerHTML = data.mqttTopLog;
          if(data.mqttTopOut !== undefined) g('mqttTopOut').innerHTML = data.mqttTopOut;
          xhttp = null;
          updateTime = 0;
          reqFin = true;
          }
        else {
          if(!reqFin && reqTime > 10) {
            xhttp = null;
            reqFin = true;
          }
        }
      }
    }
    return false;
  }
  function init() {
    transmit();
  }
  setInterval(transmit, 2500);
</script>
)====="; // html_sysinfo_script

static const char html_sysinfo_body[] PROGMEM = R"=====(
<p><b>System Information</b></p>

<table style='width:100%'>
<tr><td>Device Name</td><td><span id='DevName'></td></tr>

<tr><td colspan='2'>&nbsp;</td></tr>
<tr><td>Host Name</td><td><span id='HostName'></td></tr>
<tr><td>SSID</td><td><span id='SSID'></td></tr>
<tr><td>WiFi-Conf</td><td><span id='WiFiConf'></td></tr>
<tr><td>MAC</td><td><span id='MAC'></td></tr>
<tr><td>IP</td><td><span id='IP'></td></tr>
<tr><td>Gateway</td><td><span id='GW'></td></tr>
<tr><td>DNS</td><td><span id='DNS'></td></tr>

<tr><td colspan='2'>&nbsp;</td></tr>
<tr><td>MQTT-Server</td><td><span id='mqtthost'></td></tr>
<tr><td>State</td><td><span id='mqttstate'></td></tr>
<tr><td>reconnects</td><td><span id='mqttreconn'></td></tr>
<tr><td>Topic IN</td><td><span id='mqttTopIn'></td></tr>
<tr><td>Topic LOG</td><td><span id='mqttTopLog'></td></tr>
<tr><td>Topic OUT</td><td><span id='mqttTopOut'></td></tr>

<tr><td colspan='2'>&nbsp;</td></tr>
<tr><td colspan='2'>Heap Memory</td></tr>
<tr><td>&nbsp;Free</td><td><span id='HeapFree'></td></tr>
<tr><td>&nbsp;Fragmentation</td><td><span id='HeapFragment'></td></tr>
<tr><td>&nbsp;Max Blocksize</td><td><span id='HeapMaxBlock'></td></tr>
<tr><td>CPU Frequency</td><td><span id='CPUfreq'></td></tr>

<tr><td colspan='2'>&nbsp;</td></tr>
<tr><td colspan='2'>Firmware</td></tr>
<tr><td>Name</td><td><span id='FWName'></td></tr>
<tr><td>Version</td><td><span id='FWVer'></td></tr>
<tr><td>Built Date</td><td><span id='FWBuilt'></td></tr>
<tr><td>Created by</td><td><span id='FWCr'></td></tr>
<tr><td>Debug Version</td><td><span id='FWDebug'></td></tr>
<tr><td>Core Version</td><td><span id='CoreVersion'></td></tr>
<tr><td>SDK Version</td><td><span id='SDKVersion'></td></tr>
<tr><td>Sketch Size</td><td><span id='SketchSize'></td></tr>
<tr><td>Flash Size</td><td><span id='FlashSize'></td></tr>

<tr><td colspan='2'>&nbsp;</td></tr>
<tr><td>Date</td><td><span id='Date'></td></tr>
<tr><td>Time</td><td><span id='Time'></td></tr>
<tr><td>Reset Reason</td><td><span id='ResetReason'></td></tr>
<tr><td>UpTime</td><td><span id='UpTime'></td></tr>
</table>

<table style='width:100%'>
<tr>
<td style='width:100%'><button onclick='location=".";' class='bgrey'>Close</button></td>
</tr></table>
<div></div>
)====="; // html_confweb_body
