iobroker.uv-protect
Version:
UV-Protect from openUV-API
115 lines (99 loc) • 4.34 kB
HTML
<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) {
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', function () {
showHideSettings();
onChange();
});
} else {
var val = settings[id];
// do not call onChange direct, because onChange could expect some arguments
$key.val(settings[id])
.on('change', () => onChange())
.on('keyup', () => onChange())
;
}
});
showHideSettings();
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 {
var val = $this.val();
var id = $this.attr('id');
obj[id] = val;
//obj[$this.attr('id')] = $this.val();
}
});
callback(obj);
}
function showHideSettings() {
if ($('#systemGeoData').prop('checked')) {
$('.systemData').hide();
} else {
$('.systemData').show();
}
}
</script>
</head>
<body>
<div class="m adapter-container">
<div class="row">
<div class="col s12 m4 l6">
<img src="uv-protect.png" class="logo">
</div>
</div>
<div class="row">
<div class="input-field col s4">
<input class="value" id="apiKey" type="password">
<label for="apiKey" class="translate">API Key</label>
<span><a href="https://www.openuv.io/" target="_blank" class="translate">Get the API key from open.io</a></span>
</div>
</div>
<div class="row">
<div class="col s4 input-field">
<input type="checkbox" class="value" id="systemGeoData" />
<label for="systemGeoData" class="translate">Use astro data from the system settings</label>
</div>
</div>
<div class="row systemData">
<div class="col s4 input-field">
<input type="text" class="value" id="longitude" />
<label for="longitude" class="translate">longitude</label>
</div>
<div class="col s4 input-field">
<input type="text" class="value" id="latitude" />
<label for="latitude" class="translate">latitude</label>
</div>
</div>
</div>
</body>
</html>