Initial commit
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<html>
|
||||
<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>
|
||||
<script type="text/javascript" src="words.js"></script>
|
||||
|
||||
<!-- 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);
|
||||
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>
|
||||
|
||||
<!-- you have to put your config page in a div with id adapter-container -->
|
||||
<div class="m adapter-container">
|
||||
|
||||
<div class="row">
|
||||
<div class="col s6"><img src="klf200.png" class="logo"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="input-field col s12 m6">
|
||||
<input class="value" id="host" type="text"/>
|
||||
<label for="host" class="translate">host</label>
|
||||
</div>
|
||||
<div class="input-field col s12 m6">
|
||||
<input class="value" id="password" type="password"/>
|
||||
<label for="password" class="translate">password</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="input-field col s12 m3">
|
||||
<input class="value" id="pollInterval" type="number" min="0"/>
|
||||
<label for="pollInterval" class="translate">pollInterval</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<p class="translate">on save adapter restarts with new config immediately</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user