133 lines
4.6 KiB
HTML
133 lines
4.6 KiB
HTML
<html>
|
|
|
|
<!-- these 4 files always have to be included -->
|
|
<link rel="stylesheet" type="text/css" href="../../lib/css/themes/jquery-ui/redmond/jquery-ui.min.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>
|
|
<script type="text/javascript" src="../../lib/js/jquery-ui-1.10.3.full.min.js"></script>
|
|
|
|
<!-- these two file always have to be included -->
|
|
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
|
|
<script type="text/javascript" src="../../js/translate.js"></script>
|
|
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
|
|
<script type="text/javascript" src="words.js"></script>
|
|
|
|
<style>
|
|
.table_header {
|
|
background-color: blue;
|
|
color: white;
|
|
}
|
|
.ip {
|
|
width: 150px;
|
|
text-align: right;
|
|
}
|
|
</style>
|
|
<!-- you have to define 2 functions in the global scope: -->
|
|
<script type="text/javascript">
|
|
var devices = [];
|
|
|
|
function setValue(id, value, onChange) {
|
|
var $value = $('#' + id + '.value');
|
|
if ($value.attr('type') === 'checkbox') {
|
|
$value.prop('checked', value).change(function() {
|
|
onChange();
|
|
});
|
|
} else {
|
|
$value.val(value).on('change', function() {
|
|
onChange();
|
|
}).on('keyup', function() {
|
|
onChange();
|
|
});
|
|
}
|
|
}
|
|
|
|
// the function loadSettings has to exist ...
|
|
function load(settings, onChange) {
|
|
if (!settings) return;
|
|
|
|
devices = settings.devices || [];
|
|
|
|
if (settings.maxMemory === undefined) settings.maxMemory = 128;
|
|
|
|
for (var key in settings) {
|
|
if (settings.hasOwnProperty(key)) {
|
|
setValue(key, settings[key], onChange);
|
|
}
|
|
}
|
|
$('#update').button().click(function () {
|
|
sendTo(null, 'update', null, function (error) {
|
|
if (!error) {
|
|
showMessage(_('Successfully updated'))
|
|
} else {
|
|
showMessage(_('Cannot update:') + _(error))
|
|
}
|
|
});
|
|
});
|
|
|
|
var $libs = $('#libraries');
|
|
|
|
if (common.npmLibs){
|
|
$libs.val(common.npmLibs.join(', '));
|
|
}
|
|
|
|
$libs.on('change', function () {
|
|
onChange();
|
|
}).on('keyup', function () {
|
|
$(this).trigger('change');
|
|
});
|
|
|
|
getIsAdapterAlive(function (isAlive) {
|
|
if (!isAlive) $('#update').button('disable');
|
|
});
|
|
onChange(false);
|
|
}
|
|
|
|
function save(callback) {
|
|
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();
|
|
}
|
|
});
|
|
|
|
var libs = $('#libraries').val().split(',');
|
|
var common = {npmLibs: []};
|
|
for (var l = 0; l < libs.length; l++) {
|
|
common.npmLibs.push(libs[l].trim());
|
|
}
|
|
|
|
callback(obj, {localLink: 'http://%ip%:' + obj.port, npmLibs: common.npmLibs});
|
|
}
|
|
</script>
|
|
|
|
<!-- you have to put your config page in a div with id adapter-container -->
|
|
<div id="adapter-container">
|
|
<table><tr>
|
|
<td><img src="node-red.png" width="64" height="64"></td>
|
|
<td style="padding-top: 20px;padding-left: 10px"><h3 class="translate">node-red adapter settings</h3></td>
|
|
</tr></table>
|
|
|
|
<h4 class="translate">node-red settings</h4>
|
|
<table>
|
|
<tr><td><label class="translate" for="port">Web server port:</label></td><td colspan="2"><input class="value" id="port" type="number" min="1" max="65565"/></td></tr>
|
|
<tr>
|
|
<td><label class="translate" for="libraries">Additional npm modules:</label></td><td><input id="libraries" class="value" style="width: 100%"/></td><td class="translate">Divided by comma</td>
|
|
</tr>
|
|
<tr>
|
|
<td><label class="translate" for="httpRoot">http root directory:</label></td><td><input id="httpRoot" class="value" style="width: 100%"/></td>
|
|
</tr>
|
|
<tr>
|
|
<td><label class="translate" for="valueConvert">Convert values to string:</label></td><td> <input class="value" id="valueConvert" type="checkbox" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td><label class="translate" for="maxMemory">Max allocated RAM:</label></td><td> <input class="value" id="maxMemory" type="number" min="32"/></td>
|
|
</tr>
|
|
</table>
|
|
<h4 class="translate">node-red update select dialog</h4>
|
|
<button id="update" class="translateB">Update select dialog</button>
|
|
</div>
|
|
</html>
|