Skip to content

Commit

Permalink
pid, id for UI, Network and Web module, checkbox type using bool3State
Browse files Browse the repository at this point in the history
RAM:   [==        ]  17.6% (used 57748 bytes from 327680 bytes)
Flash: [========  ]  75.7% (used 1438593 bytes from 1900544 bytes)

index.js:
- initCap: add isLowerCase function (WIP)
- createHTML: check variable.value != null (bugfix)

newui/modules.js
- check variable.value != null (bugfix)

model.json
- rename clTbl to clients including columns
- rename ethOn, WifiOn, apOn to ethernet, wiFi, AP including children
- rename vlTbl to loops including columns

SysModModel
- showObsolete, don't use class variable
- callVarOnChange: checkbox pointer: use bool3State type

SysModNetwork
- rename ethOn, WifiOn, apOn to ethernet, wiFi, AP including children

SysModUI
- rename vlTbl to loops including columns
- initCheckbox use bool3State type
- callVarFun: use bool3State type

SysModWeb
- rename clTbl to clients including columns
  • Loading branch information
ewoudwijma committed Oct 8, 2024
1 parent 404c5b7 commit 44d6239
Show file tree
Hide file tree
Showing 16 changed files with 1,742 additions and 1,787 deletions.
12 changes: 9 additions & 3 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ function createHTML(json, parentNode = null, rowNr = UINT8_MAX) {
changeHTML(variable, variable, rowNr); // set the variable with its own changed values
}
else { //onUI
if (variable.value)
if (variable.value != null) //also if value == false (checkbox)
changeHTML(variable, {"value":variable.value, "chk":"gen1"}, rowNr); //set only the value

if (variable.options) // eg for pin type
Expand Down Expand Up @@ -1425,14 +1425,21 @@ function toggleModal(varNode) { //canvas or textarea
}
// https://stackoverflow.com/questions/324303/cut-and-paste-moving-nodes-in-the-dom-with-javascript

function isLowerCase(s) {
return s.toLowerCase() == s
}

function initCap(s) {
if (typeof s !== 'string') return '';
let result = "";
for (let i = 0; i < s.length; i++) {
if (i==0) //first uppercase
result += s.charAt(i).toUpperCase();
else if (s.charAt(i).toLowerCase() !== s.charAt(i) && s.charAt(i-1).toLowerCase() == s.charAt(i-1)) //uppercase (previous not uppercase) => add space
else if (!isLowerCase(s.charAt(i)) && isLowerCase(s.charAt(i-1))) //uppercase (previous not uppercase) => add space
// else if (!isLowerCase(s.charAt(i)) && isLowerCase(s.charAt(i-1)) && (i+1 >= s.length || isLowerCase(s.charAt(i+1))))
result += " " + s.charAt(i);
// else if (!isLowerCase(s.charAt(i)) && !isLowerCase(s.charAt(i-1)) && (i+1 >= s.length || isLowerCase(s.charAt(i+1))))
// result += " " + s.charAt(i);
else if (s.charAt(i) == '-' || s.charAt(i) == '_') //- and _ is space
result += " ";
else
Expand All @@ -1441,7 +1448,6 @@ function initCap(s) {
return result;
}


//drag and drop functionality
//===========================

Expand Down
9 changes: 8 additions & 1 deletion data/newui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,21 @@ const UINT16_MAX = 256*256-1;
function gId(c) {return document.getElementById(c);}
function cE(e) { return document.createElement(e); }

function isLowerCase(s) {
return s.toLowerCase() == s
}

function initCap(s) {
if (typeof s !== 'string') return '';
let result = "";
for (let i = 0; i < s.length; i++) {
if (i==0) //first uppercase
result += s.charAt(i).toUpperCase();
else if (s.charAt(i).toLowerCase() !== s.charAt(i) && s.charAt(i-1).toLowerCase() == s.charAt(i-1)) //uppercase (previous not uppercase) => add space
else if (!isLowerCase(s.charAt(i)) && isLowerCase(s.charAt(i-1))) //uppercase (previous not uppercase) => add space
// else if (!isLowerCase(s.charAt(i)) && isLowerCase(s.charAt(i-1)) && (i+1 >= s.length || isLowerCase(s.charAt(i+1))))
result += " " + s.charAt(i);
// else if (!isLowerCase(s.charAt(i)) && !isLowerCase(s.charAt(i-1)) && (i+1 >= s.length || isLowerCase(s.charAt(i+1))))
// result += " " + s.charAt(i);
else if (s.charAt(i) == '-' || s.charAt(i) == '_') //- and _ is space
result += " ";
else
Expand Down
84 changes: 42 additions & 42 deletions misc/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,49 +312,49 @@
"max": 255,
"n": [
{
"id": "clTbl",
"id": "clients",
"type": "table",
"pid": "Web",
"ro": true,
"n": [
{
"id": "clNr",
"id": "nr",
"type": "number",
"pid": "clTbl",
"pid": "clients",
"ro": true,
"max": 999,
"o": 43,
"fun": 31
},
{
"id": "clIp",
"id": "ip",
"type": "text",
"pid": "clTbl",
"pid": "clients",
"ro": true,
"max": 16,
"o": 44,
"fun": 32
},
{
"id": "clIsFull",
"id": "full",
"type": "checkbox",
"pid": "clTbl",
"pid": "clients",
"ro": true,
"o": 45,
"fun": 33
},
{
"id": "clStatus",
"id": "status",
"type": "select",
"pid": "clTbl",
"pid": "clients",
"ro": true,
"o": 46,
"fun": 34
},
{
"id": "clLength",
"type": "number",
"pid": "clTbl",
"pid": "clients",
"ro": true,
"max": 64,
"o": 47,
Expand Down Expand Up @@ -420,72 +420,72 @@
"s": true,
"n": [
{
"id": "ethOn",
"id": "ethernet",
"type": "checkbox",
"pid": "Network",
"ro": false,
"value": 1,
"n": [
{
"id": "ethConfig",
"id": "config",
"type": "select",
"pid": "ethOn",
"pid": "ethernet",
"ro": false,
"value": 0,
"n": [
{
"id": "ethaddr",
"id": "address",
"type": "number",
"pid": "ethConfig",
"pid": "config",
"ro": false,
"max": 255,
"value": 0,
"o": 56,
"fun": 42
},
{
"id": "ethpower",
"id": "power",
"type": "pin",
"pid": "ethConfig",
"pid": "config",
"ro": false,
"max": 40,
"value": 14,
"o": 57,
"fun": 43
},
{
"id": "ethmdc",
"id": "mdc",
"type": "pin",
"pid": "ethConfig",
"pid": "config",
"ro": false,
"max": 40,
"value": 23,
"o": 58,
"fun": 44
},
{
"id": "ethmdio",
"id": "mdio",
"type": "pin",
"pid": "ethConfig",
"pid": "config",
"ro": false,
"max": 40,
"value": 18,
"o": 59,
"fun": 45
},
{
"id": "ethtype",
"id": "type",
"type": "select",
"pid": "ethConfig",
"pid": "config",
"ro": false,
"value": 0,
"o": 60,
"fun": 46
},
{
"id": "ethclkmode",
"id": "clockMode",
"type": "select",
"pid": "ethConfig",
"pid": "config",
"ro": false,
"value": 3,
"o": 61,
Expand All @@ -496,9 +496,9 @@
"fun": 41
},
{
"id": "etStatus",
"id": "status",
"type": "text",
"pid": "ethOn",
"pid": "ethernet",
"ro": true,
"max": 32,
"o": 62,
Expand All @@ -509,7 +509,7 @@
"fun": 40
},
{
"id": "wifiOn",
"id": "wiFi",
"type": "checkbox",
"pid": "Network",
"ro": false,
Expand All @@ -518,7 +518,7 @@
{
"id": "ssid",
"type": "text",
"pid": "wifiOn",
"pid": "wiFi",
"ro": false,
"max": 31,
"value": "ewtr",
Expand All @@ -527,9 +527,9 @@
"fun": 50
},
{
"id": "pw",
"id": "password",
"type": "password",
"pid": "wifiOn",
"pid": "wiFi",
"ro": false,
"max": 63,
"value": "xxx",
Expand All @@ -540,16 +540,16 @@
{
"id": "rssi",
"type": "text",
"pid": "wifiOn",
"pid": "wiFi",
"ro": true,
"max": 32,
"o": 66,
"fun": 52
},
{
"id": "wfStatus",
"id": "status",
"type": "text",
"pid": "wifiOn",
"pid": "wiFi",
"ro": true,
"max": 32,
"o": 67,
Expand All @@ -561,16 +561,16 @@
"fun": 49
},
{
"id": "apOn",
"id": "AP",
"type": "checkbox",
"pid": "Network",
"ro": false,
"value": 0,
"n": [
{
"id": "apStatus",
"id": "status",
"type": "text",
"pid": "apOn",
"pid": "AP",
"ro": true,
"max": 32,
"o": 69,
Expand Down Expand Up @@ -745,24 +745,24 @@
"max": 255,
"n": [
{
"id": "vlTbl",
"id": "loops",
"type": "table",
"pid": "UI",
"ro": true,
"n": [
{
"id": "vlVar",
"id": "variable",
"type": "text",
"pid": "vlTbl",
"pid": "loops",
"ro": true,
"max": 32,
"o": 88,
"fun": 70
},
{
"id": "vlLoopps",
"id": "#loops",
"type": "number",
"pid": "vlTbl",
"pid": "loops",
"ro": true,
"max": 999,
"o": 89,
Expand Down
Loading

0 comments on commit 44d6239

Please sign in to comment.