Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudwijma committed Apr 26, 2024
1 parent 1ff3511 commit 980f448
Show file tree
Hide file tree
Showing 5 changed files with 1,424 additions and 1,359 deletions.
14 changes: 12 additions & 2 deletions data/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@
<html>
<head>
<meta charset="utf-8">
<title>StarMod💫 by MoonModules 🌔</title>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta name="author" content="MoonModules ☾ and it's contributors">
<link rel="icon" href="https://ewowi.github.io/StarDocs/assets/images/ui/starmod/favicon-16x16.png">
<!-- <link rel="icon" type="image/x-icon" href="favicon-16x16.png"> currently only works in chrome -->
<!-- <link rel="mask-icon" type="image/x-icon" href="favicon-16x16.png"> for safari tabs? -->
<!-- <link rel="shortcut icon" type="image/x-icon" href="favicon-16x16.png"> found in wled... -->
<link rel="stylesheet" href="index.css">
<script src="app.js"></script>
<script src="index.js"></script>
<title>StarMod💫 by MoonModules 🌔</title>

<!-- favicon in safari not working. see: -->
<!-- https://stackoverflow.com/questions/68885882/favicon-not-displaying-on-safari -->
<!-- test: rm /Users/ewoudwijma/Library/Safari/Favicon\ Cache also from trash bin -->

<!-- tbd: add max-age=86400 to imports -->
<!-- tbd: add max-age=86400 to imports -->

<!-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules -->
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
Expand Down
38 changes: 19 additions & 19 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function onLoad() {
d.addEventListener("visibilitychange", handleVisibilityChange, false);
}

function consolelog() {
function ppf() {
let logNode = gId("log");
let sep = "";
if (logNode) {
Expand Down Expand Up @@ -117,7 +117,7 @@ function makeWS() {
let module = json;
model.push((module)); //this is the model
console.log("WS receive createHTML", module);
consolelog("WS receive createHTML", module.id);
ppf("WS receive createHTML", module.id);
createHTML(module); //no parentNode

if (module.id == "System") {
Expand Down Expand Up @@ -614,24 +614,24 @@ function receiveData(json) {

//special commands
if (key == "uiFun") {
consolelog("receiveData no action", key, value); //should not happen anymore
ppf("receiveData no action", key, value); //should not happen anymore
}
else if (key == "view") {
consolelog("receiveData", key, value);
ppf("receiveData", key, value);
changeHTMLView(value);
}
else if (key == "theme") {
consolelog("receiveData", key, value);
ppf("receiveData", key, value);
changeHTMLTheme(value);
}
else if (key == "canvasData") {
consolelog("receiveData no action", key, value);
ppf("receiveData no action", key, value);
} else if (key == "details") {
let variable = value.var;
let rowNr = value.rowNr == null?UINT8_MAX:value.rowNr;
let nodeId = variable.id + ((rowNr != UINT8_MAX)?"#" + rowNr:"");
//if var object with .n, create .n (e.g. see setEffect and fixtureGenChFun, tbd: )
consolelog("receiveData details", key, variable.id, nodeId, rowNr);
ppf("receiveData details", key, variable.id, nodeId, rowNr);
if (gId(nodeId + "_n")) gId(nodeId + "_n").remove(); //remove old ndiv

let modelVar = findVar(variable.id);
Expand All @@ -648,7 +648,7 @@ function receiveData(json) {
flushUIFunCommands(); //make sure uiFuns of new elements are called
}
else if (key == "addRow") { //update the row of a table
consolelog("receiveData", key, value);
ppf("receiveData", key, value);

if (value.id && value.rowNr != null) {
let tableId = value.id;
Expand All @@ -658,18 +658,18 @@ function receiveData(json) {
let tableNode = gId(tableId);
let tbodyNode = tableNode.querySelector("tbody");

consolelog("addRow ", tableVar, tableNode, rowNr);
ppf("addRow ", tableVar, tableNode, rowNr);

let newRowNr = tbodyNode.querySelectorAll("tr").length;

genTableRowHTML(tableVar, tableNode, newRowNr);
}
else
consolelog("dev receiveData addRow no id and/or rowNr specified", key, value);
ppf("dev receiveData addRow no id and/or rowNr specified", key, value);

} else if (key == "delRow") { //update the row of a table

consolelog("receiveData", key, value);
ppf("receiveData", key, value);
let tableId = value.id;
let tableVar = findVar(tableId);
let rowNr = value.rowNr;
Expand All @@ -682,7 +682,7 @@ function receiveData(json) {

varRemoveValuesForRow(tableVar, rowNr);

consolelog("delRow ", tableVar, tableNode, rowNr);
ppf("delRow ", tableVar, tableNode, rowNr);

} else if (key == "updRow") { //update the row of a table

Expand All @@ -691,19 +691,19 @@ function receiveData(json) {
let rowNr = value.rowNr;
let tableRow = value.value;

// consolelog("receiveData updRow", key, tableId, rowNr, tableRow);
// consolelog("updRow main", tableId, tableRows, tableNode, tableVar);
// ppf("receiveData updRow", key, tableId, rowNr, tableRow);
// ppf("updRow main", tableId, tableRows, tableNode, tableVar);

let colNr = 0;
for (let colVar of tableVar.n) {
let colValue = tableRow[colNr];
// consolelog(" col", colNr, colVar, colValue);
// ppf(" col", colNr, colVar, colValue);
changeHTML(colVar, {"value":colValue, "chk":"updRow"}, rowNr);
colNr++;
}

} else if (key == "sysInfo") { //update the row of a table
consolelog("receiveData", key, value);
ppf("receiveData", key, value.board);
sysInfo = value;
} else { //{variable:{label:value:options:comment:}}

Expand All @@ -712,19 +712,19 @@ function receiveData(json) {
if (variable) {
let rowNr = value.rowNr == null?UINT8_MAX:value.rowNr;
// if (variable.id == "fxEnd" || variable.id == "fxSize" || variable.id == "point")
// consolelog("receiveData ", variable, value);
// ppf("receiveData ", variable, value);
variable.fun = -2; // request processed

value.chk = "uiFun";
changeHTML(variable, value, rowNr); //changeHTML will find the rownumbers if needed
}
else
consolelog("receiveData key is no variable", key, value);
ppf("receiveData key is no variable", key, value);
}
} //for keys
} //isObject
else
consolelog("receiveData no Object", object);
ppf("receiveData no Object", object);
} //receiveData

//do something with an existing (variable) node, key is an existing node, json is what to do with it
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ build_flags =
${STARMOD_USERMOD_E131.build_flags}
; ${STARMOD_USERMOD_HA.build_flags}
-DAPP=StarMod
-DVERSION=24042519 ; Date and time (GMT!)
-DVERSION=24042614 ; Date and time (GMT!)
-DPIOENV=$PIOENV
lib_deps =
${starmod.lib_deps}
Expand Down
7 changes: 4 additions & 3 deletions src/Sys/SysModWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,16 +680,17 @@ void SysModWeb::serveJson(WebRequest *request) {
deserializeJson(docState, jsonState);
root["state"] = docState;

//tbd: //StarMod has no idea about leds so this should be led independent
root["state"]["bri"] = mdl->getValue("bri");
root["state"]["on"] = mdl->getValue("on").as<bool>();
root["info"]["name"] = mdl->getValue("instanceName");
root["info"]["arch"] = "esp32"; //platformName

root["info"]["rel"] = _INIT(TOSTRING(APP));
root["info"]["ver"] = "0.0.1";
root["info"]["ver"] = _INIT(TOSTRING(VERSION));
root["info"]["vid"] = VERSION; //WLED-native needs int otherwise status offline!!!
root["info"]["leds"]["count"] = 999;
root["info"]["leds"]["countP"] = 998;
root["info"]["leds"]["count"] = 999; //StarMod has no idea about leds
root["info"]["leds"]["countP"] = 998; //StarMod has no idea about leds
root["info"]["leds"]["fps"] = mdl->getValue("fps"); //tbd: should be realFps but is ro var
root["info"]["wifi"]["rssi"] = WiFi.RSSI();// mdl->getValue("rssi"); (ro)

Expand Down
Loading

0 comments on commit 980f448

Please sign in to comment.