123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <html><head><body>
- <h3>Extended configuration</h3>
- <a href='/'>Home</a><br><br>
- <input type='button' value='reload' onclick='return transmit()'/><br>
- <form id='form1' onsubmit='return transmit(this)'>
- <h4>Domoticz</h4>
- Domoticz Idx 1: <input type='number' name='domIdx1' id='domIdx1'/><br>
- Domoticz Idx 2: <input type='number' name='domIdx2' id='domIdx2'/><br>
- Domoticz Idx 3: <input type='number' name='domIdx3' id='domIdx3'/><br>
- <h4>Button MQTT-Out</h4>
- Retain *: <input type='checkbox' name='btnRet' id='btnRet'/><br><br>
- 1:<br>
- Topic: <input type='text' name='top1' id='top1'/> Payload: <input type='text' name='pld1' id='pld1'/><br>
- Hold:<br>
- Control relais: <select name='hld1ToRel' id='hld1ToRel'><option value='0'>-</option><option>1</option><option>2</option><option>3</option></select><br>
- Topic: <input type='text' name='topHld1' id='topHld1'/> Payload: <input type='text' name='pldHld1' id='pldHld1'/><br><br>
- 2:<br>
- Topic: <input type='text' name='top2' id='top2'/> Payload: <input type='text' name='pld2' id='pld2'/><br>
- Hold:<br>
- Control relais: <select name='hld2ToRel' id='hld2ToRel'><option value='0'>-</option><option>1</option><option>2</option><option>3</option></select><br>
- Topic: <input type='text' name='topHld2' id='topHld2'/> Payload: <input type='text' name='pldHld2' id='pldHld2'/><br><br>
- 3:<br>
- Topic: <input type='text' name='top3' id='top3'/> Payload: <input type='text' name='pld3' id='pld3'/><br>
- Hold:<br>
- Control relais: <select name='hld3ToRel' id='hld3ToRel'><option value='0'>-</option><option>1</option><option>2</option><option>3</option></select><br>
- Topic: <input type='text' name='topHld3' id='topHld3'/> Payload: <input type='text' name='pldHld3' id='pldHld3'/><br>
- <br>
- <input type='submit' value='Save'/>
- </form>
- <form id='rebootForm' onsubmit='return res()'>
- <input type='submit' value='Restart'/>
- </form>
- <script>
- function g(i) { return document.getElementById(i) };
- var xhttp, reqTime, reqFin, rxhttp;
-
- function res() {
- rxhttp = new XMLHttpRequest();
- rxhttp.timeout = 1000;
- rxhttp.open('POST', 'restart');
- rxhttp.send('');
- rxhttp = null;
- return false;
- }
- function setCheckbox(ele, dat) {
- if(dat == 1) {
- ele.checked = true;
- ele.style.visibility = 'visible';
- }
- else {
- ele.checked = false;
- ele.style.visibility = 'visible';
- }
- }
- function updateCheckboxValue(ele) {
- if (ele.checked) ele.value ='1';
- else {
- ele.value = '0';
- ele.checked = true;
- ele.style.visibility = 'hidden';
- }
- }
- function transmit(f) {
- if (!xhttp) {
- updateCheckboxValue(g('btnRet'));
- xhttp = new XMLHttpRequest();
- xhttp.timeout = 2000;
- xhttp.open('POST', 'confdata2');
- xhttp.send(f ? (new FormData(f)) : '');
- xhttp.onreadystatechange = function () {
- if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
- var data = JSON.parse(xhttp.responseText);
- setCheckbox(g('btnRet'), data.btnRet);
- g('top1').value = data.top1;
- g('top2').value = data.top2;
- g('top3').value = data.top3;
- g('topHld1').value = data.topHld1;
- g('topHld2').value = data.topHld2;
- g('topHld3').value = data.topHld3;
- g('pld1').value = data.pld1;
- g('pld2').value = data.pld2;
- g('pld3').value = data.pld3;
- g('pldHld1').value = data.pldHld1;
- g('pldHld2').value = data.pldHld2;
- g('pldHld3').value = data.pldHld3;
- g('hld1ToRel').value = data.hld1ToRel;
- g('hld2ToRel').value = data.hld2ToRel;
- g('hld3ToRel').value = data.hld3ToRel;
- g('domIdx1').value = data.domIdx1;
- g('domIdx2').value = data.domIdx2;
- g('domIdx3').value = data.domIdx3;
-
- xhttp = null;
- reqFin = false;
- }
- else {
- if(!reqFin && reqTime > 10) {
- xhttp = null;
- reqFin = true;
- }
- }
- }
- }
- return false;
- }
- transmit();
- setInterval(function () { ++reqTime; }, 1000);
- </script>
- </body></html>
|