UNPKG

iobroker.elero-usb-transmitter

Version:
149 lines (134 loc) 5.5 kB
<html> <head> <!-- Load ioBroker scripts and styles--> <link rel="stylesheet" type="text/css" href="../../css/adapter.css" /> <link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css" /> <script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script> <script type="text/javascript" src="../../socket.io/socket.io.js"></script> <script type="text/javascript" src="../../js/translate.js"></script> <script type="text/javascript" src="../../lib/js/materialize.js"></script> <script type="text/javascript" src="../../js/adapter-settings.js"></script> <!-- Load our own files --> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="words.js"></script> <script type="text/javascript"> // This will be called by the admin adapter when the settings page loads function load(settings, onChange) { // example: select elements with id=key and class=value and insert value if (!settings) return $('.value').each(function () { var $key = $(this) var id = $key.attr('id') if ($key.attr('type') === 'checkbox') { // do not call onChange direct, because onChange could expect some arguments $key.prop('checked', settings[id]).on('change', () => onChange()) } else { // do not call onChange direct, because onChange could expect some arguments $key .val(settings[id]) .on('change', () => onChange()) .on('keyup', () => onChange()) } }) $('.device-row').each((index, element) => { const channel = $(element).find('.device-channel').text() let name = '' let transitTime = 0 if (settings.deviceConfigs) { name = settings.deviceConfigs[channel - 1].name transitTime = settings.deviceConfigs[channel - 1].transitTime } $(element) .find('.device-name') .val(name) .on('change', () => onChange()) $(element) .find('.device-transittime') .val(transitTime) .on('change', () => onChange()) }) onChange(false) // reinitialize all the Materialize labels on the page if you are dynamically adding inputs: if (M) M.updateTextFields() } // This will be called by the admin adapter when the user presses the save button function save(callback) { // example: select elements with class=value and build settings object var obj = {} $('.value').each(function () { var $this = $(this) if ($this.attr('type') === 'checkbox') { obj[$this.attr('id')] = $this.prop('checked') } else { obj[$this.attr('id')] = $this.val() } }) obj.deviceConfigs = new Array() $('.device-row').each((index, element) => { const channel = $(element).find('.device-channel').text() const name = $(element).find('.device-name').val() const transitTime = $(element).find('.device-transittime').val() obj.deviceConfigs[channel - 1] = { channel: channel, name: name, transitTime: transitTime } }) callback(obj) } </script> </head> <body> <div class="m adapter-container"> <div class="row"> <div class="col s12"> <ul class="tabs"> <li class="tab col s2"><a href="#tab-main" class="translate active">Main settings</a></li> <li class="tab col s2"><a href="#tab-devices" class="translate">Device settings</a></li> </ul> </div> <div id="tab-main" class="col s12 page"> <div class="row"> <div class="col s12 m4 l2"> <img src="elero-usb-transmitter.png" class="logo" /> </div> </div> <div class="row"> <div class="col s6 input-field"> <input placeholder="/dev/..." name="usbStickDevicePath" type="text" id="usbStickDevicePath" class="value validate" /> <label for="usbStickDevicePath" class="translate"> usbStickDevicePath </label> </div> </div> <div class="row"> <div class="col s6 input-field"> <input placeholder="5" name="refreshInterval" type="number" id="refreshInterval" class="value validate" /> <label for="refreshInterval" class="translate"> refreshInterval </label> </div> </div> </div> <div id="tab-devices" class="col s12 page"> <table class="table-values centered"> <thead> <tr> <th class="translate">Channel</th> <th class="translate">Name</th> </tr> </thead> <tbody id="devices"> <tr class="device-row"> <td class="device-channel">1</td> <td><input type="text" class="device-name" /></td> </tr> <tr class="device-row"> <td class="device-channel">2</td> <td><input type="text" class="device-name" /></td> </tr> </tbody> </table> </div> </div> </div> </body> </html>