/* clang-format off */

//static const char html_confbas_script[] PROGMEM = R"=====(
//<script>
//  function g(i) { return document.getElementById(i) };
//  function sp(i){g(i).type=(g(i).type==='text'?'password':'text');}
//  var xhttp, reqTime, reqFin;
//  function setCbx(el, da) {
//    if(da == '1') {
//      el.checked = true;
//      el.style.visibility = 'visible';
//    }
//    else {
//      el.checked = false;
//      el.style.visibility = 'visible';
//    }
//  }
//  function updCbxVal(el) {
//    if (el.checked) el.value = '1';
//    else {
//      el.checked = true;
//    el.value = '0';
//      el.style.visibility = 'hidden';
//    }
//  }

static const char html_confHeatc_script[] PROGMEM = R"=====(
  function transmit(f) {
    if (!xhttp) {   
    reqTime = 0;
    reqFin = false;
    updCbxVal(g('heatUseHC'));
    updCbxVal(g('heatForceHC'));
    //updCbxVal(g('saveToMqttRet'));
    //updCbxVal(g('PIRenDispPs0'));
    //updCbxVal(g('togTHdisp'));
    xhttp = new XMLHttpRequest();
    xhttp.timeout = 1000;
    xhttp.overrideMimeType('application/json');
    xhttp.open('POST', 'confDataHeatc');
    xhttp.send(f ? (new FormData(f)) : '');
    xhttp.onreadystatechange = function () {
      if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
        var data = JSON.parse(xhttp.responseText);
        g('heatcm20').value = data.heatcm20;
        g('heatcm15').value = data.heatcm15;
        g('heatcm10').value = data.heatcm10;
        g('heatcm5').value = data.heatcm5;
        g('heatc0').value = data.heatc0;
        g('heatc5').value = data.heatc5;
        g('heatc10').value = data.heatc10;
        g('heatc15').value = data.heatc15;
        g('heatc20').value = data.heatc20;
        g('heatlm20').value = data.heatlm20;
        g('heatlm15').value = data.heatlm15;
        g('heatlm10').value = data.heatlm10;
        g('heatlm5').value = data.heatlm5;
        g('heatl0').value = data.heatl0;
        g('heatl5').value = data.heatl5;
        g('heatl10').value = data.heatl10;
        g('heatl15').value = data.heatl15;
        g('heatl20').value = data.heatl20;
        setCbx(g('heatUseHC'), data.heatUseHC);
        setCbx(g('heatForceHC'), data.heatForceHC);
        g('pumpnl').value = data.pumpnl;
        //setCbx(g('autoSaveMode'), data.autoSaveMode);
        //setCbx(g('saveToMqttRet'), data.saveToMqttRet);
        //setCbx(g('PIRenDispPs0'), data.PIRenDispPs0);
        //setCbx(g('togTHdisp'), data.togTHdisp);
        //g('tempDec').value = data.tempDec;
        //g('hyst').value = data.hyst;
        //g('minOffTime').value = data.minOffTime;
        //g('offMsg').value = data.offMsg;
        //g('iTempLab').value = data.iTempLab;
        //g('oTempLab').value = data.oTempLab;
        //g('modeName1').value = data.modeName1;
        //g('modeName0').value = data.modeName0;
        //g('psetName0').value = data.psetName0;
        //g('psetName1').value = data.psetName1;
        //g('psetName2').value = data.psetName2;
        //g('pauseTout').value = data.pauseTout;
        xhttp = null;
        reqFin = true;
       }
       else {
         if(!reqFin && reqTime > 10) {
           xhttp = null;
           reqFin = true;
         }
       }
     }
   }
    return false;
  }
  //transmit();
  function saveConf() {
    updCbxVal(g('heatUseHC'));
    updCbxVal(g('heatForceHC'));
    //updCbxVal(g('saveToMqttRet'));
    //updCbxVal(g('PIRenDispPs0'));
    //updCbxVal(g('togTHdisp'));
    g('frmConf').submit();
  }
  function init() {
    transmit();
  }
)====="; // html_confTherm_script
//  setInterval(function () { ++reqTime; }, 1000);
//</script>
//)====="; // html_confTherm_script

static const char html_confHeatc_body[] PROGMEM = R"=====(
<b>Configuration - Heat Control</b>
<div class='config'>
<form id='frmConf' action='setConfHeatc' method='POST'>
<br>
<fieldset>
<legend>Heat Curve</legend>
<table>
<tr><th>Outside</th><th>Feed [°C]</th></tr>
<tr><td><b>-20°C</b></td><td><input type='number' min='10' max='90' name='heatcm20' id='heatcm20'></td></tr>
<tr><td><b>-15°C</b></td><td><input type='number' min='10' max='90' name='heatcm15' id='heatcm15'></td></tr>
<tr><td><b>-10°C</b></td><td><input type='number' min='10' max='90' name='heatcm10' id='heatcm10'></td></tr>
<tr><td><b>-5°C</b></td><td><input type='number' min='10' max='90' name='heatcm5' id='heatcm5'></td></tr>
<tr><td><b>0°C</b></td><td><input type='number' min='10' max='90' name='heatc0' id='heatc0'></td></tr>
<tr><td><b>5°C</b></td><td><input type='number' min='10' max='90' name='heatc5' id='heatc5'></td></tr>
<tr><td><b>10°C</b></td><td><input type='number' min='10' max='90' name='heatc10' id='heatc10'></td></tr>
<tr><td><b>15°C</b></td><td><input type='number' min='10' max='90' name='heatc15' id='heatc15'></td></tr>
<tr><td><b>20°C</b></td><td><input type='number' min='10' max='90' name='heatc20' id='heatc20'></td></tr>
</table>
<p><b>Use Heat Curve</b>&nbsp;<input type='checkbox' name='heatUseHC' id='heatUseHC'/></p>
<p><b>Force Heat Curve</b>&nbsp;<input type='checkbox' name='heatForceHC' id='heatForceHC'/></p>
</fieldset>
<div></div><br>
<fieldset>
<legend>Heating - Lock Time</legend>
<table>
<tr><th>Outside</th><th>Lock Time [min]</th></tr>
<tr><td><b>-20°C</b></td><td><input type='number' min='0' max='60' name='heatlm20' id='heatlm20'></td></tr>
<tr><td><b>-15°C</b></td><td><input type='number' min='0' max='60' name='heatlm15' id='heatlm15'></td></tr>
<tr><td><b>-10°C</b></td><td><input type='number' min='0' max='60' name='heatlm10' id='heatlm10'></td></tr>
<tr><td><b>-5°C</b></td><td><input type='number' min='0' max='60' name='heatlm5' id='heatlm5'></td></tr>
<tr><td><b>0°C</b></td><td><input type='number' min='0' max='60' name='heatl0' id='heatl0'></td></tr>
<tr><td><b>5°C</b></td><td><input type='number' min='0' max='60' name='heatl5' id='heatl5'></td></tr>
<tr><td><b>10°C</b></td><td><input type='number' min='0' max='60' name='heatl10' id='heatl10'></td></tr>
<tr><td><b>15°C</b></td><td><input type='number' min='0' max='60' name='heatl15' id='heatl15'></td></tr>
<tr><td><b>20°C</b></td><td><input type='number' min='0' max='60' name='heatl20' id='heatl20'></td></tr>
</table>
</fieldset>

<div></div><br>
<fieldset>
<legend>Pump</legend>
<p><b>Backlash [min]</b><br><input type='text' name='pumpnl' id='pumpnl'></p><br>
</fieldset>
<div></div><br>

</form>
<div></div>
<table style='width:100%'>
<td style='width:50%'><button onclick='location="conf";' class='bgrey'>Cancel</button></td>
<td style='width:50%'><button onclick='return saveConf()' class='bred'>Save</button></td>
</tr></table>
</div>
)====="; // html_confHeatc_body
