Skip to content

Commit

Permalink
Introduce mapping virtual leds to physical leds + small things
Browse files Browse the repository at this point in the history
index.js: 
- change innerHTML to innerText
- button: like others: initCap(id) and use .label to overwrite (instead of default value)

AppModLeds
- split into .h and .cpp
- split into Physical and Virtual Leds !!
- add LedsV class for mapping physical and virtual
- adjust effects to support P and V (WIP)
- rename ledFixes!! (will be renamed again ! WIP)
- use fun callback to calculate mapping

main.cpp
- change order so leds is shown first in UI (default)

SysModFiles
- change initButton to reflect refactor
- JsonRDWS: add lookFor array of values in callback functions (x,y,z for leds)
- JsonRDWS: not lazy anymore as whole file must be scanned for leds (to map them)
- JsonRDWS: add funList, objectStack, uint16CollectList
- JsonRDWS: next: implement array parsing
- JsonRDWS: check: add fun callback
  • Loading branch information
ewoudwijma committed Jul 28, 2023
1 parent 389138d commit d023d8d
Show file tree
Hide file tree
Showing 16 changed files with 1,405 additions and 1,010 deletions.
57 changes: 31 additions & 26 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,24 @@ function generateHTML(parentNode, json) {
}
var newNode = null;
let labelNode = cE("label");
labelNode.innerHTML = initCap(json.id);
labelNode.innerText = initCap(json.id);

if (json.type == "module") {
newNode = cE("div");
newNode.id = json.id
newNode.draggable = true;
newNode.className = "box";
let h2Node = cE("h2");
h2Node.innerHTML = initCap(json.id);
h2Node.innerText = initCap(json.id);
newNode.appendChild(h2Node);
let pNode = cE("p");
pNode.innerHTML = "Enable"
pNode.innerText = "Enable"
let checkBoxNode = cE("input");
checkBoxNode.id = json.id;
checkBoxNode.type = "checkbox";
pNode.appendChild(checkBoxNode);
let commentNode = cE("comment");
commentNode.innerHTML = "WIP"
commentNode.innerText = "WIP"
pNode.appendChild(commentNode);
newNode.appendChild(pNode);
setupBox(newNode);
Expand Down Expand Up @@ -131,7 +131,7 @@ function generateHTML(parentNode, json) {
newNode.appendChild(labelNode);
let spanNode = cE("span");
spanNode.id = json.id;
if (json.value) spanNode.innerHTML = json.value;
if (json.value) spanNode.innerText = json.value;
newNode.appendChild(spanNode);
}
else {
Expand Down Expand Up @@ -163,7 +163,7 @@ function generateHTML(parentNode, json) {
newNode.id = json.id;
newNode.readOnly = json.ro;
newNode.addEventListener('click', (event) => {toggleModal(event.target);});
if (json.value) newNode.innerHTML = json.value;
if (json.value) newNode.innerText = json.value;
// newNode.appendChild(textareaNode);
pNode.innerText += "🔍";
}
Expand All @@ -172,15 +172,15 @@ function generateHTML(parentNode, json) {
if (parentNode.nodeName.toLocaleLowerCase() == "table") { //table add the id in the header
let tdNode = cE("th");
tdNode.id = json.id;
tdNode.innerHTML = initCap(json.id); //label uiFun response can change it
tdNode.innerText = initCap(json.id); //label uiFun response can change it
parentNode.firstChild.firstChild.appendChild(tdNode); //<thead><tr>
}
else {
newNode = cE("p");
newNode.appendChild(labelNode);
let spanNode = cE("span");
spanNode.id = json.id;
if (json.value) spanNode.innerHTML = json.value;
if (json.value) spanNode.innerText = json.value;
newNode.appendChild(spanNode);
}
}
Expand All @@ -196,18 +196,18 @@ function generateHTML(parentNode, json) {
if (json.value) inputNode.checked = json.value;
inputNode.addEventListener('change', (event) => {console.log(json.type + " change", event);setCheckbox(event.target);});
} else if (json.type == "button") {
if (json.value) inputNode.value = json.value;
inputNode.value = initCap(json.id);
inputNode.addEventListener('click', (event) => {console.log(json.type + " click", event);setButton(event.target);});
} else {
//input types: text, search, tel, url, email, and password.
if (json.value) inputNode.value = json.value;
inputNode.addEventListener('change', (event) => {console.log(json.type + " change", event);setInput(event.target);});
if (["text", "password", "number"].includes(json.type) ) {
buttonSaveNode = cE("text");
buttonSaveNode.innerHTML = "✅";
buttonSaveNode.innerText = "✅";
buttonSaveNode.addEventListener('click', (event) => {console.log(json.type + " click", event);});
buttonCancelNode = cE("text");
buttonCancelNode.innerHTML = "🛑";
buttonCancelNode.innerText = "🛑";
buttonCancelNode.addEventListener('click', (event) => {console.log(json.type + " click", event);});
}
if (json.type == "number") {
Expand Down Expand Up @@ -255,14 +255,19 @@ function processUpdate(json) {

if (json[key].label) {
console.log("processUpdate label", key, json[key].label);
let labelNode;
if (gId(key).nodeName.toLocaleLowerCase() == "canvas" || gId(key).nodeName.toLocaleLowerCase() == "table")
labelNode = gId(key).previousSibling.firstChild; //<p><label> before <canvas>/<table>
else if (gId(key).nodeName.toLocaleLowerCase() == "th") //table header
labelNode = gId(key); //the <th>
else
labelNode = gId(key).parentNode.firstChild; //<label> before <span or input> within <p>
labelNode.innerHTML = json[key].label;
if (gId(key).nodeName.toLocaleLowerCase() == "input" && gId(key).type == "button") {
gId(key).value = initCap(json[key].label);
}
else {
let labelNode;
if (gId(key).nodeName.toLocaleLowerCase() == "canvas" || gId(key).nodeName.toLocaleLowerCase() == "table")
labelNode = gId(key).previousSibling.firstChild; //<p><label> before <canvas>/<table>
else if (gId(key).nodeName.toLocaleLowerCase() == "th") //table header
labelNode = gId(key); //the <th>
else
labelNode = gId(key).parentNode.firstChild; //<label> before <span or input> within <p>
labelNode.innerText = initCap(json[key].label);
}
}
if (json[key].comment) {
console.log("processUpdate comment", key, json[key].comment);
Expand All @@ -280,7 +285,7 @@ function processUpdate(json) {
commentNode = cE("comment");
parentNode.appendChild(commentNode);
}
commentNode.innerHTML = json[key].comment;
commentNode.innerText = json[key].comment;
}
if (json[key].select) {
console.log("processUpdate select", key, json[key].select);
Expand All @@ -289,12 +294,12 @@ function processUpdate(json) {
for (var value of json[key].select) {
if (parseInt(gId(key).textContent) == index) {
// console.log("processUpdate select1", value, gId(key), gId(key).textContent, index);
gId(key).textContent = value; //replace the id by its value TBD: THIS DOES NOT WORK FOR SOME REASON
gId(key).textContent = value; //replace the id by its value
// console.log("processUpdate select2", value, gId(key), gId(key).textContent, index);
overruleValue = true; //in this case we do not want the value set
}
index++;
}
overruleValue = true; //in this case we do not want the value set
}
else { //select
var index = 0;
Expand All @@ -320,16 +325,16 @@ function processUpdate(json) {
let trNode = cE("tr");
for (var columnRow of row) {
let tdNode = cE("td");
tdNode.innerHTML = columnRow;
tdNode.innerText = columnRow;
trNode.appendChild(tdNode);
}
tbodyNode.appendChild(trNode);
}
gId(key).replaceChild(tbodyNode, gId(key).lastChild); //replace <table><tbody>
}
if (json[key].value && !overruleValue) { //after select, in case used
if (key=="ledFix" || key =="ledFixGen")
console.log("processUpdate value", key, json[key].value, gId(key));
// if (key=="ledFix" || key =="ledFixGen"|| key =="reset0")
// console.log("processUpdate value", key, json[key].value, gId(key));
if (gId(key).nodeName.toLocaleLowerCase() == "span") //read only objects
gId(key).textContent = json[key].value;
else if (gId(key).nodeName.toLocaleLowerCase() == "canvas") {
Expand Down Expand Up @@ -518,7 +523,7 @@ function handleDragStart(e) {
dragSrcEl = this;

e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('text/html', this.innerHTML);
e.dataTransfer.setData('text/html', this.innerText);
console.log("handleDragStart", this, e, e.dataTransfer);
e.dataTransfer.setData('text/plain', this.id);
}
Expand Down
Loading

0 comments on commit d023d8d

Please sign in to comment.