iobroker.lgtv11
Version:
ioBroker LG 11 SmartTV Adapter
130 lines (114 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-1.11.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>
<!-- you have to define 2 functions in the global scope: -->
<script type="text/javascript">
// the function loadSettings has to exist ...
function load(settings, onChange) {
var active = false;
// 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();
});
}
});
socket.emit('getState', 'system.adapter.' + adapter + '.' + instance + '.alive', function (err, state) {
active = (state && state.val);
});
var $requestpairingkey = $('#requestpairingkey');
$requestpairingkey.click(function ()
{
if (!active)
{
showMessage('Please enable the adapter first!', 'Information', 'info');
}
else
{
sendTo('lgtv11.' + instance, 'RequestPairingKey_Msg', 5000, function (result) {});
showMessage('Please check the Pairing Key on your TV screen!', 'Information', 'info');
}
});
onChange(false);
}
// ... 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 id="tab-main" class="col s12 page">
<div class="row">
<div class="col s12 m4 l2">
<img src="lgtv2011.png">
</div>
</div>
<div class="row">
<div class="col s12 m8 l5">
<input class="value" id="ip"></input>
<label for="ip" class="translate" for="ip">ip</label>
</div>
<div class="col s12 m4 l1">
<input class="value" id="port" type="number" value="8080"/>
<label for="timeout" class="translate" for="timeout">port</label>
</div>
</div>
<div class="row">
<div class="col s12 m8 15">
<input class="value" id="pairingkey" />
<label for="timeout" class="translate" for="timeout">pairingkey</label>
</div>
<div class="col s12 m4 l1">
<input class="value" id="interval" type="number" min="15000" value="60000"/>
<label for="interval" class="translate" for="interval">interval</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<a class="waves-effect waves-light btn" id="requestpairingkey"><span class="translate">request_pairingkey</span></a>
</div>
</div>
<div class="row">
<span class="translate">help_tip</span>
</div>
</div>
</div>
</div>
</body>
</html>