www/js/global.js

Wed, 24 Apr 2024 16:46:45 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 24 Apr 2024 16:46:45 +0200
changeset 703
344470c6bb1c
parent 697
685f20ad87ed
child 714
24749c296a50
permissions
-rw-r--r--

Fermenter editor layout is ready. Load record done. Add and Delete a new fermenter is done.


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