major rework

- modified chartjs for better zoom on touchpad
- flexible number of charts
- handle bool as checkbox
- handle enum as select (pull down menu)
- disable swiper where not needed
and many more
This commit is contained in:
2020-12-23 11:11:22 +01:00
parent 1de819cd26
commit 97c6aa1a87
14 changed files with 2480 additions and 1609 deletions

View File

@ -94,7 +94,7 @@ function handleUpdateMessage(src, message) {
document.title = "SEA "+clientTitle + " " + message.title;
}
var header = document.getElementById("header");
header.setAttribute("style", "width: auto;");
header.style.width = 'auto';
header.innerHTML = clientTitle;
console.log('ID', initCommands);
nextInitCommand();
@ -137,6 +137,7 @@ function handleUpdateMessage(src, message) {
break;
// graph-message: Evokes redraw of graphics.
case "graph":
alert('obsolete code "graph" called')
console.log("graph");
createCharts2(message.graph);
break;
@ -169,6 +170,7 @@ function handleUpdateMessage(src, message) {
}
function htmlEscape(str) {
str = "" + str;
if (!str) return "";
return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g,
'&#39;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
@ -196,8 +198,9 @@ function updateValues(message, src) {
var component = message.updates[i];
var value = component.value;
var matches = document.getElementsByName(component.name);
for (var j = 0; j < matches.length; j++) {
var type = matches[j].getAttribute("__ctype__");
var type = matches[j].__ctype__;
if (type == "rdonly") {
var text = htmlEscape(value);
if (text) {
@ -207,8 +210,7 @@ function updateValues(message, src) {
var row = matches[j].parentNode.parentNode.parentNode;
row.style.backgroundColor = "white";
var mval = matches[j].value;
var oldValue = matches[j].getAttribute("oldValue");
if (oldValue === null) oldValue = mval;
var oldValue = ('oldValue' in matches[j]) ? matches[j].oldValue : mval;
if (value != mval && parseFloat(value) != parseFloat(mval) && value != oldValue) {
if (matches[j] == document.activeElement
|| oldValue != mval) {
@ -217,12 +219,13 @@ function updateValues(message, src) {
matches[j].value = value;
}
}
matches[j].setAttribute("actualValue", value);
matches[j].actualValue = value;
resizeTextfield(matches[j]);
} else if (type == "checkbox") {
var row = matches[j].parentNode.parentNode;
row.style.backgroundColor = "white";
matches[j].checked = value == 1 && value == "1";
console.log('CBX', matches[j].name, message, Boolean(value && value != 'false'));
matches[j].checked = Boolean(value && value != 'false');
} else if (type == "enum") {
matches[j].style.display = "block";
var row = matches[j].parentNode.parentNode;
@ -277,14 +280,16 @@ function successHandler(s, message) {
}
if (message.path == "main") {
// Happens only initially or at device change.
for (var sLocal = 0; sLocal < MAXBLOCK; sLocal++) {
for (var sLocal = 0; sLocal < 2; sLocal++) { // was up to MAXBLOCK
insertSlide(sLocal, message.title, "main", createContent(
sLocal, message));
}
insertSlide(2, "", "parameters", createContent(2, {components:[]}));
} else {
if (s < 0) { // redraw: check for slides in all swiper instances
for (var isw = 0; isw < MAXBLOCK; isw ++) {
var slide = findSlide(isw, message.path);
var isl = findSlide(isw, message.path);
var slide = swiper[isl].slides[i];
if (slide) {
console.log("redraw", isw);
replaceSlideContent(slide, message.title,
@ -292,8 +297,10 @@ function successHandler(s, message) {
}
}
} else {
insertSlide(s, message.title, message.path, createContent(s,
message));
// insertSlide(s, message.title, message.path, createContent(s, message));
let sLocal = paramSlider[s];
isl = insertSlide(sLocal, message.title, "parameters", createContent(sLocal, message));
swiper[sLocal].slideTo(isl); /* go to found slide */
}
}
nextInitCommand();
@ -360,6 +367,7 @@ function successHandler(s, message) {
if (debugCommunication) {
console.log("graph-draw", message);
}
alert('obsolete code graph-draw called')
createCharts2(message.graph);
nextInitCommand();
// Request for updates.