iobroker.hilink
Version:
ioBroker hilink Adapter
109 lines (102 loc) • 4.6 kB
HTML
<html>
<head>
<!-- these 4 files always have to be included -->
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css">
<link rel="stylesheet" type="text/css" href="../../css/adapter.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>
<!-- these files always have to be included -->
<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>
<script type="text/javascript" src="words.js"></script>
<style>
.m .col .select-wrapper+label {
top: -26px;
}
</style>
<!-- you have to define 2 functions in the global scope: -->
<script type="text/javascript">
// the function loadSettings has to exist ...
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]).change(function() {
onChange();
});
} else {
// do not call onChange direct, because onChange could expect some arguments
$key.val(settings[id]).change(function() {
onChange();
}).keyup(function() {
onChange();
});
}
});
onChange(false);
if (M) M.updateTextFields();
}
// ... 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 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>
<!-- you have to put your config page in a div with id adapter-container -->
<div class="m adapter-container">
<div class="row">
<div class="row">
<div class="col s6">
<img src="hilink.png" class="logo">
</div>
</div>
<div class="row">
<div class="input-field col s12 m6 l3">
<input class="value" id="getip" maxlength="15" type="text" placeholder="192.168.8.1" />
<label class="translate" for="getip">IP адрес</label>
<span class="translate help-block">getip</span>
</div>
<div class="input-field col s12 m6 l3">
<select id="model" class="value">
<option value="3372s">3372s</option>
<option value="3372h">3372h</option>
</select>
<label class="translate" for="model">Модель</label>
</div>
</div>
<div class="row">
<div class="input-field col s12 m6 l3">
<select id="trafficInfo" class="value">
<option value="auto">auto</option>
<option value="def">def</option>
</select>
<label for="trafficInfo">Информация о трафике</label>
<span class="translate">trafficInfo</span>
</div>
<div class="input-field col s12 m6 l3">
<input id="settime" min="10000" step="1000" type="text" placeholder="60000 = 60sec" class="value">
<label for="settime">Интервал</label>
<span class="translate">settime</span>
</div>
</div>
</div>
</div>
</body>
</html>