UNPKG

iobroker.vis

Version:

Graphical user interface for iobroker.

120 lines (108 loc) 4.55 kB
<html> <head> <link rel="stylesheet" type="text/css" href="../../lib/css/themes/jquery-ui/redmond/jquery-ui.min.css"/> <link rel="stylesheet" type="text/css" href="../../lib/css/jquery.multiselect-1.13.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> <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> <style> .success { color: forestgreen; font-weight: bold; } .error { color: #ab0000; } </style> <script type="text/javascript"> function setValue(id, value, onChange) { var $value = $('#' + id + '.value'); if ($value.attr('type') === 'checkbox') { $value.prop('checked', value).change(function() { onChange(); }); } else { $value.val(value).change(function() { if ($(this).attr('id') === 'license') { if ($(this).val()) { $('#check').button('enable'); } else { $('#check').button('disable'); } $('#checkResult').html(); } onChange(); }).keyup(function() { $(this).trigger('change'); }); } } function load(settings, onChange) { if (!settings) return; if (settings.license === undefined) settings.license = ''; for (var key in settings) { if (settings.hasOwnProperty(key)) setValue(key, settings[key], onChange); } $('#check').button({ icons: {primary: 'ui-icon-folder-collapsed'}, label: _('Check license') }).click(function () { $('#check').button('disable'); $('#checkResult').html('...'); $.ajax({ type: 'POST', url: 'https://iobroker.net/cert/', data: $('#license').val(), contentType: 'text/plain', xhrFields: { withCredentials: false }, headers: {}, success: function(data, status, request) { $('#check').button('enable'); $('#checkResult').html(data ? data.result : 'error').removeClass('error').addClass(data.result === 'OK' ? 'success': ''); }, error: function (res, error) { $('#check').button('enable'); $('#checkResult').html(_('Service is offline. Please try later.')).addClass('error').removeClass('success'); } }); }); if (!settings.license) { $('#check').button('disable'); } onChange(false); } function save(callback) { 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(); } }); callback(obj); } </script> </head> <body> <div id="adapter-container"> <table><tr> <td><img src="vis.png"></td> <td style="padding-top: 20px; padding-left: 10px;"><h3 class="translate">vis adapter settings</h3></td> </tr></table> <table style="width: 100%; padding: 10px"> <tr><td style="width: 50px"><label class="translate" for="license">License:</label></td><td class="admin-icon"></td><td><textarea class="value number" id="license" style="width: 100%; height: 100px; resize: none"></textarea></td></tr> <tr><td></td><td class="admin-icon"></td><td><button id="check" style="display: inline-block"></button><div id="checkResult" style="padding-left: 10px; display: inline-block"></div></td></tr> <tr><td colspan="3">&nbsp;</td></tr> <tr><td></td><td></td><td class="translate" style="font-size: 16px;">instruction</td></tr> </table> </div> </body> </html>