UNPKG

iobroker.daikin

Version:
124 lines (109 loc) 4.51 kB
<html> <!-- these 4 files always have to be included --> <link rel="stylesheet" type="text/css" href="../../lib/css/themes/jquery-ui/redmond/jquery-ui.min.css"/> <script type="text/javascript" src="../../lib/js/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="../../socket.io/socket.io.js"></script> <script type="text/javascript" src="../../lib/js/jquery-ui-1.10.3.full.min.js"></script> <!-- these two file always have to be included --> <link rel="stylesheet" type="text/css" href="../../css/adapter.css"/> <script type="text/javascript" src="../../js/translate.js"></script> <script type="text/javascript" src="../../js/adapter-settings.js"></script> <script type="text/javascript" src="words.js"></script> <!-- you have to define 2 functions in the global scope: --> <script type="text/javascript"> var convertComma = null; function setValue(id, value, onChange) { // example: select elements with id=key and class=value and insert value if ($('#' + id + '.value').attr('type') === 'checkbox') { $('#' + id + '.value').prop('checked', value).change(function () { onChange(); }); } else { $('#' + id + '.value').val(value).change(function() { onChange(); }).keyup(function() { // Check that only numbers entered if ($(this).hasClass('number')) { var val = $(this).val(); if (val) { var newVal = ''; for (var i = 0; i < val.length; i++) { if ((val[i] >= '0' && val[i] <= '9') || val[i] === '-' || val[i] === '+' || val[i] === '.' || val[i] === ',') { if (val[i] === '.' && convertComma === true) val[i] === ','; if (val[i] === ',' && convertComma === false) val[i] === '.'; newVal += val[i]; } } if (val != newVal) $(this).val(newVal); } } $(this).trigger('change'); }); } } function load(settings, onChange) { // works only with newest admin adapter if (typeof systemConfig !== 'undefined') { convertComma = systemConfig.common.isFloatComma; } for (var key in settings) { setValue(key, settings[key], onChange); } onChange(false); } // ... and the function save has to exist. // you have to make sure the callback is called with the settings object as first param! function save(callback) { // example: select elements with class=value and build settings object var settings = {}; $('.value').each(function () { var $this = $(this); var id = $this.attr('id'); if ($this.attr('type') == 'checkbox') { settings[id] = $this.prop('checked'); } else { settings[id] = $this.val(); } }); callback(settings); } </script> <!-- you have to put your config page in a div with id adapter-container --> <div id="adapter-container"> <table><tr> <td><img src="daikin_logo.jpg" height="150"/><br> <h3 class="translate">page_title</h3></td> <td></td> </tr></table> <table> <tr><td colspan="3"><h4 class="translate">heading_GeneralSettings</h4></td></tr> <tr> <td class="translate">field_daikinIp</td> <td> <input id="daikinIp" type="text" size="15" class="value"/> </td> <td> <span class="tooltiptext translate">info_daikinIp</span> </td> </tr> <tr> <td class="translate">field_pollingInterval</td> <td> <input id="pollingInterval" type="text" size="10" class="value number"/> s </td> <td> <span class="tooltiptext translate">info_pollingInterval</span> </td> </tr> <tr> <td class="translate">field_useGetToPost</td> <td> <input id="useGetToPost" type="checkbox" class="value"/> </td> <td> <span class="tooltiptext translate">info_useGetToPost</span> </td> </tr> </table> </div> </html>