www/js/global.js

Thu, 25 Apr 2024 14:26:47 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 25 Apr 2024 14:26:47 +0200
changeset 708
13555c27b592
parent 703
344470c6bb1c
child 714
24749c296a50
permissions
-rw-r--r--

Version 0.9.19a6. Fixes after a short trial on the production controller. Fixed json for alternate beer termperature sensor. Fixed division by 1000 for the room temperature and humidity values. The dropdown list for devices shows the address instead of description in the list.


var DeviceTypeData = [
 { id: 0, mno: 'NA', en: 'Unknown' },
 { id: 1, mno: 'W1', en: 'One-wire' },
 { id: 2, mno: 'GPIO', en: 'GPIO' },
 { id: 3, mno: 'RC433', en: 'RC-433' },
 { id: 4, mno: 'DHT', en: 'DHT11' },
 { id: 5, mno: 'I2C', en: 'I2C bus' },
 { id: 6, mno: 'SPI', en: 'SPI bus' },
 { id: 7, mno: 'SIM', en: 'Simulator' }
],
DeviceTypeSource = {
 localdata: DeviceTypeData,
 datatype: 'array',
 datafields: [{ name: 'id' }, { name: 'mno' }, { name: 'en' }]
},
DeviceTypeAdapter = new $.jqx.dataAdapter(DeviceTypeSource),

DevicePresentData = [
 { id: 0, mno: 'UNDEF', en: 'Unknown' },
 { id: 1, mno: 'NO', en: 'No' },
 { id: 2, mno: 'YES', en: 'Yes' },
 { id: 3, mno: 'ERROR', en: 'Error' }
],
DevicePresentSource = {
 localdata: DevicePresentData,
 datatype: 'array',
 datafields: [{ name: 'id' }, { name: 'mno' }, { name: 'en' }]
},
DevicePresentAdapter = new $.jqx.dataAdapter(DevicePresentSource),

DeviceDirectionData = [
 { id: 0, mno: 'UNDEF', en: 'Unknown' },
 { id: 1, mno: 'IN_BIN', en: 'Binary input' },
 { id: 2, mno: 'OUT_BIN', en: 'Binary output' },
 { id: 3, mno: 'IN_ANALOG', en: 'Analog input' },
 { id: 4, mno: 'OUT_ANALOG', en: 'Analog output' },
 { id: 5, mno: 'OUT_PWM', en: 'PWM output' },
 { id: 6, mno: 'INTERN', en: 'Intern' }
],
DeviceDirectionSource = {
 localdata: DeviceDirectionData,
 datatype: 'array',
 datafields: [{ name: 'id' }, { name: 'mno' }, { name: 'en' }]
},
DeviceDirectionAdapter = new $.jqx.dataAdapter(DeviceDirectionSource),

// Temp sensors droptdown list
tempsensorSource = {
 datatype: 'json',
 datafields: [
  { name: 'uuid', type: 'string' },
  { name: 'name', type: 'string' }
 ],
 url: 'drop_tempsensors.php'
},
tempsensorlist = new $.jqx.dataAdapter(tempsensorSource),

// Switches dropdown list
switchesSource = {
 datatype: 'json',
 datafields: [
  { name: 'uuid', type: 'string' },
  { name: 'name', type: 'string' }
 ],
 url: 'drop_switches.php'
},
switcheslist = new $.jqx.dataAdapter(switchesSource),

// Contacts dropdown list
contactsSource = {
 datatype: 'json',
 datafields: [
  { name: 'uuid', type: 'string' },
  { name: 'name', type: 'string' }
 ], 
 url: 'drop_contacts.php'
},
contactslist = new $.jqx.dataAdapter(contactsSource),


// options for editors

Show0dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 0 },
Show1dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 1 },
Spin0dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 0, spinButtons: true },
Spin1dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true },
Spin2dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 2, spinButtons: true },
Spin3dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 3, spinButtons: true },
  PosInt = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 0, spinButtons: true },
  SubInt = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 63, decimalDigits: 0, spinButtons: true },
 GPIOInt = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: -1, max:31, decimalDigits: 0, spinButtons: true },
Perc1dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 100, decimalDigits: 1, spinButtons: true },
   Perc0 = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true };


/* Websocket interface. Place "websocket.onmessage = function(evt) {}" in the user script. */
var websocket = new ReconnectingWebSocket('ws://'+location.hostname+'/ws');

websocket.onerror = function(event) {
 console.log('Websocket error: ' + event.data);
}



$(document).ready(function() {

 $('#jqxMenu').jqxMenu({
  width: 1280,
  height: '30px',
  autoOpen: false,
  clickToOpen: true,
  theme: theme
 });
 $('#jqxWidget').css('visibility', 'visible');
});

mercurial