UNPKG

5.04 kBHTMLView Raw
1<html>
2
3<!-- these 4 files always have to be included -->
4<link rel="stylesheet" type="text/css" href="../../lib/css/themes/jquery-ui/redmond/jquery-ui.min.css"/>
5<script type="text/javascript" src="../../lib/js/jquery-1.11.1.min.js"></script>
6<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
7<script type="text/javascript" src="../../lib/js/jquery-ui-1.10.3.full.min.js"></script>
8
9<!-- these two file always have to be included -->
10<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
11<script type="text/javascript" src="../../js/translate.js"></script>
12<script type="text/javascript" src="../../js/adapter-settings.js"></script>
13<script type="text/javascript" src="words.js"></script>
14
15<style>
16 .table_header {
17 background-color: blue;
18 color: white;
19 }
20 .ip {
21 width: 150px;
22 text-align: right;
23 }
24</style>
25<!-- you have to define 2 functions in the global scope: -->
26<script type="text/javascript">
27 var devices = [];
28
29 function setValue(id, value, onChange) {
30 var $value = $('#' + id + '.value');
31 if ($value.attr('type') === 'checkbox') {
32 $value.prop('checked', value).change(function() {
33 onChange();
34 });
35 } else {
36 $value.val(value).on('change', function() {
37 onChange();
38 }).on('keyup', function() {
39 onChange();
40 });
41 }
42 }
43
44 // the function loadSettings has to exist ...
45 function load(settings, onChange) {
46 if (!settings) return;
47
48 devices = settings.devices || [];
49
50 if (settings.maxMemory === undefined) settings.maxMemory = 128;
51 if (settings.projectsEnabled === undefined) settings.projectsEnabled = false;
52
53 for (var key in settings) {
54 if (settings.hasOwnProperty(key)) {
55 setValue(key, settings[key], onChange);
56 }
57 }
58 $('#update').button().click(function () {
59 sendTo(null, 'update', null, function (error) {
60 if (!error) {
61 showMessage(_('Successfully updated'))
62 } else {
63 showMessage(_('Cannot update:') + _(error))
64 }
65 });
66 });
67
68 var $libs = $('#libraries');
69
70 if (common.npmLibs){
71 $libs.val(common.npmLibs.join(', '));
72 }
73
74 $libs.on('change', function () {
75 onChange();
76 }).on('keyup', function () {
77 $(this).trigger('change');
78 });
79
80 getIsAdapterAlive(function (isAlive) {
81 if (!isAlive) $('#update').button('disable');
82 });
83 onChange(false);
84 }
85
86 function save(callback) {
87 var obj = {};
88 $('.value').each(function () {
89 var $this = $(this);
90 if ($this.attr('type') === 'checkbox') {
91 obj[$this.attr('id')] = $this.prop('checked');
92 } else {
93 obj[$this.attr('id')] = $this.val();
94 }
95 });
96
97 var libs = $('#libraries').val().split(',');
98 var common = {npmLibs: []};
99 for (var l = 0; l < libs.length; l++) {
100 common.npmLibs.push(libs[l].trim());
101 }
102
103 callback(obj, {localLink: 'http://%ip%:' + obj.port, npmLibs: common.npmLibs});
104 }
105</script>
106
107<!-- you have to put your config page in a div with id adapter-container -->
108<div id="adapter-container">
109 <table><tr>
110 <td><img src="node-red.png" width="64" height="64"></td>
111 <td style="padding-top: 20px;padding-left: 10px"><h3 class="translate">node-red adapter settings</h3></td>
112 </tr></table>
113
114 <h4 class="translate">node-red settings</h4>
115 <table>
116 <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>
117 <tr>
118 <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>
119 </tr>
120 <tr>
121 <td><label class="translate" for="httpRoot">http root directory:</label></td><td><input id="httpRoot" class="value" style="width: 100%"/></td>
122 </tr>
123 <tr>
124 <td><label class="translate" for="valueConvert">Convert values to string:</label></td><td> <input class="value" id="valueConvert" type="checkbox" /></td>
125 </tr>
126 <tr>
127 <td><label class="translate" for="maxMemory">Max allocated RAM:</label></td><td> <input class="value" id="maxMemory" type="number" min="32"/></td>
128 </tr>
129 <tr>
130 <td><label class="translate" for="projectsEnabled">Enable Projects Feature:</label></td><td> <input class="value" id="projectsEnabled" type="checkbox" /></td>
131 </tr>
132 </table>
133 <h4 class="translate">node-red update select dialog</h4>
134 <button id="update" class="translateB">Update select dialog</button>
135</div>
136</html>