www/js/global.js

Fri, 19 Apr 2024 11:31:46 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 19 Apr 2024 11:31:46 +0200
changeset 687
f5d05b420732
parent 686
372b2442a30f
child 697
685f20ad87ed
permissions
-rw-r--r--

Devices edit popup layout ready.

686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
1
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
2 var DeviceTypeData = [
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
3 { id: 0, mno: 'NA', en: 'Unknown' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
4 { id: 1, mno: 'W1', en: 'One-wire' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
5 { id: 2, mno: 'GPIO', en: 'GPIO' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
6 { id: 3, mno: 'RC433', en: 'RC-433' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
7 { id: 4, mno: 'DHT', en: 'DHT11' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
8 { id: 5, mno: 'I2C', en: 'I2C bus' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
9 { id: 6, mno: 'SPI', en: 'SPI bus' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
10 { id: 7, mno: 'SIM', en: 'Simulator' }
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
11 ],
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
12 DeviceTypeSource = {
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
13 localdata: DeviceTypeData,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
14 datatype: 'array',
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
15 datafields: [{ name: 'id' }, { name: 'mno' }, { name: 'en' }]
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
16 },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
17 DeviceTypeAdapter = new $.jqx.dataAdapter(DeviceTypeSource),
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
18
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
19 DevicePresentData = [
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
20 { id: 0, mno: 'UNDEF', en: 'Unknown' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
21 { id: 1, mno: 'NO', en: 'No' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
22 { id: 2, mno: 'YES', en: 'Yes' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
23 { id: 3, mno: 'ERROR', en: 'Error' }
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
24 ],
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
25 DevicePresentSource = {
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
26 localdata: DevicePresentData,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
27 datatype: 'array',
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
28 datafields: [{ name: 'id' }, { name: 'mno' }, { name: 'en' }]
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
29 },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
30 DevicePresentAdapter = new $.jqx.dataAdapter(DevicePresentSource),
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
31
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
32 DeviceDirectionData = [
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
33 { id: 0, mno: 'UNDEF', en: 'Unknown' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
34 { id: 1, mno: 'IN_BIN', en: 'Binary input' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
35 { id: 2, mno: 'OUT_BIN', en: 'Binary output' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
36 { id: 3, mno: 'IN_ANALOG', en: 'Analog input' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
37 { id: 4, mno: 'OUT_ANALOG', en: 'Analog output' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
38 { id: 5, mno: 'OUT_PWM', en: 'PWM output' },
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
39 { id: 6, mno: 'INTERN', en: 'Intern' }
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
40 ],
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
41 DeviceDirectionSource = {
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
42 localdata: DeviceDirectionData,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
43 datatype: 'array',
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
44 datafields: [{ name: 'id' }, { name: 'mno' }, { name: 'en' }]
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 675
diff changeset
45 },
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
46 DeviceDirectionAdapter = new $.jqx.dataAdapter(DeviceDirectionSource),
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
47
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
48 // options for editors
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
49
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
50 Show0dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 0 },
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
51 Spin0dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 0, spinButtons: true },
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
52 SubInt = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 63, decimalDigits: 0, spinButtons: true },
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
53 GPIOInt = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: -1, max:31, decimalDigits: 0, spinButtons: true };
675
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 /* Websocket interface. Place "websocket.onmessage = function(evt) {}" in the user script. */
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 var websocket = new ReconnectingWebSocket('ws://'+location.hostname+'/ws');
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 websocket.onerror = function(event) {
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 console.log('Websocket error: ' + event.data);
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 }
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 $(document).ready(function() {
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 $('#jqxMenu').jqxMenu({
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 width: 1280,
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 height: '30px',
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 autoOpen: false,
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 clickToOpen: true,
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 theme: theme
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 });
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 $('#jqxWidget').css('visibility', 'visible');
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 });
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76
825210ba2707 Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77

mercurial