UNPKG

@besterquester/iobroker.fit-bit

Version:
142 lines (123 loc) 4.54 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()) ; } }); 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 if ($this.attr('type') === 'number') { obj[$this.attr('id')] = parseFloat($this.val()); } else { obj[$this.attr('id')] = $this.val(); } }); callback(obj); } </script> </head> <body> <div class="m adapter-container"> <div class="row"> <div class="col s12 m4 l2"> <img src="fit-bit.png" class="logo"> </div> </div> <div class="col s12"> <ul class="tabs"> <li class="tab col s2"><a href="#tab-main" class="translate active">fitbit adapter settings</a></li> <li class="tab col s2"><a href="#tab-services" class="translate">Services</a></li> </ul> </div> <div id="tab-main" class="col s12 page"> <div class="row"> <div class="col s6"> <img src="fitbit.png" alt="logo" class="logo"> </div> </div> <div class="row owntoken no-iframe"> <div class="input-field col s12"> <input class="value" id="token" type="text"> <label for="token" class="translate">token</label> </div> </div> </div> <div id="tab-services" class="col s12 page"> <div class="row"> <div class="col s6 input-field"> <input type="number" class="value" id="refresh" min="1" max="60" /> <label for="refresh" class="translate">refresh</label> </div> </div> <div class="row"> <div class="input-field col s12 m6 14"> <input class="value" id="bodyrecords" type="checkbox"> <span for="bodyrecords" class="translate">bodyrecords</span> </div> </div> <div class="row"> <div class="input-field col s12 m6 l4"> <input class="value" id="activityrecords" type="checkbox"> <span for="activityrecords" class="translate">activityrecords</span> </div> </div> <div class="row"> <div class="input-field col s12 m6 l4"> <input class="value" id="sleeprecords" type="checkbox"> <span for="sleeprecords" class="translate">sleeprecords</span> </div> </div> <div class="row"> <div class="input-field col s12 m6 l4"> <input class="value" id="foodrecords" type="checkbox"> <span for="foodrecords" class="translate">foodrecords</span> </div> </div> <div class="row"> <div class="input-field col s12 m6 l4"> <input class="value" id="devicerecords" type="checkbox"> <span for="devicerecords" class="translate">devicerecords</span> </div> </div> </div> </div> </body> </html>