|
| 1 | +<html> |
| 2 | +<head> |
| 3 | + <!-- Materialze style --> |
| 4 | + <link rel="stylesheet" type="text/css" href="../../css/adapter.css"/> |
| 5 | + <link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css"> |
| 6 | + |
| 7 | + <script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script> |
| 8 | + <script type="text/javascript" src="../../socket.io/socket.io.js"></script> |
| 9 | + |
| 10 | + <script type="text/javascript" src="../../js/translate.js"></script> |
| 11 | + <script type="text/javascript" src="../../lib/js/materialize.js"></script> |
| 12 | + <script type="text/javascript" src="../../js/adapter-settings.js"></script> |
| 13 | + <script type="text/javascript" src="words.js"></script> |
| 14 | + |
| 15 | +<script type="text/javascript"> |
| 16 | + var timeout; |
| 17 | + var count; |
| 18 | + var gOnChange; |
| 19 | + |
| 20 | + function getComPorts(actualValue) { |
| 21 | + count++; |
| 22 | + if (count < 10) { |
| 23 | + timeout = setTimeout(function () { |
| 24 | + getComPorts(actualValue); |
| 25 | + }, 2000); |
| 26 | + } |
| 27 | + |
| 28 | + sendTo(null, 'listUart', null, function (list) { |
| 29 | + if (timeout) { |
| 30 | + clearTimeout(timeout); |
| 31 | + timeout = null; |
| 32 | + } |
| 33 | + if ((!list || !list.length) && count < 10) { |
| 34 | + setTimeout(function () { |
| 35 | + getComPorts(actualValue); |
| 36 | + }, 1000); |
| 37 | + return; |
| 38 | + } |
| 39 | + if (!list || !list.length) { |
| 40 | + $('#_serialport').html('<input id="serialport" type="text" class="value" value="' + actualValue + '" placeholder="' + _('Not ports found') + '"/><label class="translate" for="serialport">Serial port</label>'); |
| 41 | + $('#serialport').change(gOnChange).on('keyup', gOnChange); |
| 42 | + M.updateTextFields(); |
| 43 | + } else { |
| 44 | + var text = '<option value="">' + _('Select port') + '</option>'; |
| 45 | + var $serialport = $('#serialport'); |
| 46 | + |
| 47 | + for (var j = 0; j < list.length; j++) { |
| 48 | + if (list[j].comName === 'Not available') { |
| 49 | + text += '<option value="" selected>' + _('Not available') + '</option>'; |
| 50 | + $serialport.prop('disabled', true); |
| 51 | + break; |
| 52 | + } else { |
| 53 | + text += '<option value="' + list[j].comName + '" ' + ((actualValue === list[j].comName) ? 'selected' : '') + '>' + list[j].comName + '</option>'; |
| 54 | + } |
| 55 | + } |
| 56 | + $serialport.html(text).select(); |
| 57 | + } |
| 58 | + }); |
| 59 | + } |
| 60 | + |
| 61 | + function load(settings, onChange) { |
| 62 | + settings.type = settings.type || 'cul'; |
| 63 | + gOnChange = onChange; |
| 64 | + |
| 65 | + for (var key in settings) { |
| 66 | + if (!settings.hasOwnProperty(key)) continue; |
| 67 | + var $value = $('#' + key + '.value'); |
| 68 | + // example: select elements with id=key and class=value and insert value |
| 69 | + if ($value.attr('type') === 'checkbox') { |
| 70 | + $value.prop('checked', settings[key]).on('change', function () { |
| 71 | + onChange(); |
| 72 | + }); |
| 73 | + } else { |
| 74 | + $value.val(settings[key]).on('change', function () { |
| 75 | + var id = $(this).attr('id'); |
| 76 | + if (id === 'type') { |
| 77 | + if ($(this).val() === 'cul') { |
| 78 | + $('#baudrate').val('9600'); |
| 79 | + } else { |
| 80 | + $('#baudrate').val('38400'); |
| 81 | + } |
| 82 | + } |
| 83 | + onChange(); |
| 84 | + }).on('keyup', onChange); |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + getIsAdapterAlive(function (isAlive) { |
| 89 | + if (isAlive || common.enabled) { |
| 90 | + getComPorts(settings.serialport); |
| 91 | + } else { |
| 92 | + $('#_serialport').html('<input id="serialport" type="text" class="value" value="' + settings.serialport + '"/><label class="translate" for="serialport">Serial port</label>'); |
| 93 | + $('#serialport').change(onChange).on('keyup', onChange); |
| 94 | + M.updateTextFields(); |
| 95 | + } |
| 96 | + }); |
| 97 | + |
| 98 | + // Signal to admin, that no changes yet |
| 99 | + onChange(false); |
| 100 | + } |
| 101 | + |
| 102 | + function save(callback) { |
| 103 | + var obj = {}; |
| 104 | + $('.value').each(function () { |
| 105 | + var $this = $(this); |
| 106 | + if ($this.attr('type') === 'checkbox') { |
| 107 | + obj[$this.attr('id')] = $this.prop('checked'); |
| 108 | + } else { |
| 109 | + obj[$this.attr('id')] = $this.val(); |
| 110 | + } |
| 111 | + }); |
| 112 | + callback(obj); |
| 113 | + } |
| 114 | +</script> |
| 115 | +</head> |
| 116 | +<body> |
| 117 | +<div class="m adapter-container"> |
| 118 | + <div class="row"> |
| 119 | + <div class="row"> |
| 120 | + <div class="col s12 m4 l2"> |
| 121 | + <img src="busware.jpg" alt="logo" class="logo"/> |
| 122 | + </div> |
| 123 | + </div> |
| 124 | + <div class="row"> |
| 125 | + <div class="input-field col s10 m4" id="_serialport"> |
| 126 | + <select id="serialport" class="value"></select> |
| 127 | + <label class="translate" for="serialport">Serial port</label> |
| 128 | + </div> |
| 129 | + <div class="input-field col s10 m2"> |
| 130 | + <select id="baudrate" class="value"> |
| 131 | + <option value="110">110</option> |
| 132 | + <option value="150">150</option> |
| 133 | + <option value="300">300</option> |
| 134 | + <option value="600">600</option> |
| 135 | + <option value="1200">1200</option> |
| 136 | + <option value="2400">2400</option> |
| 137 | + <option value="4800">4800</option> |
| 138 | + <option value="9600">9600</option> |
| 139 | + <option value="19200">19200</option> |
| 140 | + <option value="38400">38400</option> |
| 141 | + <option value="56000">56000</option> |
| 142 | + <option value="57600">57600</option> |
| 143 | + <option value="115200">115200</option> |
| 144 | + </select> |
| 145 | + <label class="translate" for="baudrate">Baud rate</label> |
| 146 | + </div> |
| 147 | + </div> |
| 148 | + <div class="row"> |
| 149 | + <div class="input-field col s10 m4"> |
| 150 | + <select id="mode" class="value"> |
| 151 | + <option value="SlowRF">SlowRF - (FS20, HMS, FHT, EM, ESA, ...)</option> |
| 152 | + <option value="MORITZ">MORITZ - (MAX! devices)</option> |
| 153 | + <option value="AskSin">AskSin - (HomeMatic devices)</option> |
| 154 | + </select> |
| 155 | + <label class="translate" for="mode">Mode</label> |
| 156 | + </div> |
| 157 | + <div class="input-field col s10 m2"> |
| 158 | + <select id="type" class="value"> |
| 159 | + <option value="cul">CUL</option> |
| 160 | + <option value="coc">COC</option> |
| 161 | + <option value="scc">SCC</option> |
| 162 | + <option value="cuno">CUNO</option> |
| 163 | + </select> |
| 164 | + <label class="translate" for="type">Type</label> |
| 165 | + </div> |
| 166 | + </div> |
| 167 | + <div class="row"> |
| 168 | + <div class="input-field col s6 m4"> |
| 169 | + <input id="ip" class="value" value="127.0.0.1" type="text"/> |
| 170 | + <label class="translate" for="ip">IP/Hostname</label> |
| 171 | + </div> |
| 172 | + <div class="input-field col s4 m2"> |
| 173 | + <input id="port" class="value" value="23" type="number" min="1" max="65536"/> |
| 174 | + <label class="translate" for="port">Port</label> |
| 175 | + </div> |
| 176 | + </div> |
| 177 | + <div class="row"> |
| 178 | + <div class="input-field col s10 m4"> |
| 179 | + <input id="experimental" class="value" type="checkbox"/> |
| 180 | + <span class="translate" for="experimental">Experimental</span> |
| 181 | + </div> |
| 182 | + </div> |
| 183 | + </div> |
| 184 | +</div> |
| 185 | +</body> |
| 186 | +</html> |
0 commit comments