Edit button for module block
This commit is contained in:
@ -161,7 +161,7 @@ function handleUpdateMessage(src, message) {
|
||||
if (debugCommunication > 1) {
|
||||
console.log(message);
|
||||
}
|
||||
updateValues(message, src);
|
||||
handleUpdate(message, src);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -188,65 +188,42 @@ function resetTimer(src) {
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
function updateValues(message, src) {
|
||||
function handleUpdate(message, src) {
|
||||
// Handles changes of parameter-values
|
||||
for (var i = 0; i < message.updates.length; i++) {
|
||||
let component = message.updates[i];
|
||||
let comp_value = component.value;
|
||||
let matches = document.getElementsByName(component.name);
|
||||
|
||||
// Check for status updates
|
||||
if (component.name.split(":")[1] == 'status') {
|
||||
updateStatus(component);
|
||||
}
|
||||
// Check for target updates in the module block
|
||||
if (component.name.split(":")[1] == 'target') {
|
||||
updateTarget(component);
|
||||
}
|
||||
|
||||
for (var j = 0; j < matches.length; j++) {
|
||||
let elem = matches[j];
|
||||
let type = elem.__ctype__; // -> Show Dom-Properties
|
||||
|
||||
if (type == "rdonly" || type == "rdlink") {
|
||||
let text = htmlEscape(component.formatted);
|
||||
if (text) {
|
||||
elem.innerHTML = text;
|
||||
}
|
||||
} else if (type == "input") {
|
||||
let row = elem.closest('div');
|
||||
row.style.backgroundColor = "white";
|
||||
updateValue(component);
|
||||
}
|
||||
}
|
||||
|
||||
let oldValue = ('oldValue' in elem) ? elem.oldValue : elem.value;
|
||||
if (comp_value != elem.value && parseFloat(comp_value) != parseFloat(elem.value) && comp_value != oldValue) {
|
||||
if (elem == document.activeElement || oldValue != elem.value) {
|
||||
row.style.backgroundColor = "orange";
|
||||
} else {
|
||||
elem.value = comp_value;
|
||||
}
|
||||
}
|
||||
elem.actualValue = comp_value;
|
||||
resizeTextfield(elem);
|
||||
} else if (type == "checkbox") {
|
||||
let row = elem.closest('div');
|
||||
row.style.backgroundColor = "white";
|
||||
|
||||
console.log('receive: ', comp_value);
|
||||
if (comp_value == 'False' || comp_value == 'false' || comp_value == 0) {
|
||||
elem.checked = false;
|
||||
} else {
|
||||
elem.checked = true;
|
||||
}
|
||||
} else if (type == "enum") {
|
||||
elem.style.display = "block";
|
||||
let row = elem.closest('div');
|
||||
row.style.backgroundColor = "white";
|
||||
|
||||
let options = elem.childNodes;
|
||||
for (var j = 0; j < options.length; j++) {
|
||||
if (options[j].label == comp_value) {
|
||||
elem.value = j + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
function updateTarget(component) {
|
||||
let matches = document.getElementsByName(component.name);
|
||||
let elem = matches[0]; // Should be the only match
|
||||
elem.value = component.value;
|
||||
|
||||
let row = elem.closest('div');
|
||||
row.style.backgroundColor = "white";
|
||||
|
||||
let oldValue = ('oldValue' in elem) ? elem.oldValue : elem.value;
|
||||
if (component.value != elem.value && parseFloat(component.value) != parseFloat(elem.value) && component.value != oldValue) {
|
||||
if (elem == document.activeElement || oldValue != elem.value) {
|
||||
row.style.backgroundColor = "orange";
|
||||
} else {
|
||||
elem.value = component.value;
|
||||
}
|
||||
}
|
||||
elem.actualValue = component.value;
|
||||
resizeTextfield(elem);
|
||||
}
|
||||
|
||||
function updateStatus(component) {
|
||||
@ -292,6 +269,57 @@ function updateStatus(component) {
|
||||
|
||||
}
|
||||
|
||||
function updateValue(component) {
|
||||
|
||||
let matches = document.getElementsByName(component.name);
|
||||
|
||||
for (var j = 0; j < matches.length; j++) {
|
||||
let elem = matches[j];
|
||||
let type = elem.__ctype__; // -> Show Dom-Properties
|
||||
if (type == "rdonly" || type == "rdlink") {
|
||||
let text = htmlEscape(component.formatted);
|
||||
if (text) {
|
||||
elem.innerHTML = text;
|
||||
}
|
||||
} else if (type == "input") {
|
||||
let row = elem.closest('div');
|
||||
row.style.backgroundColor = "white";
|
||||
|
||||
let oldValue = ('oldValue' in elem) ? elem.oldValue : elem.value;
|
||||
if (component.value != elem.value && parseFloat(component.value) != parseFloat(elem.value) && component.value != oldValue) {
|
||||
if (elem == document.activeElement || oldValue != elem.value) {
|
||||
row.style.backgroundColor = "orange";
|
||||
} else {
|
||||
elem.value = component.value;
|
||||
}
|
||||
}
|
||||
elem.actualValue = component.value;
|
||||
resizeTextfield(elem);
|
||||
} else if (type == "checkbox") {
|
||||
let row = elem.closest('div');
|
||||
row.style.backgroundColor = "white";
|
||||
|
||||
console.log('receive: ', component.value);
|
||||
if (component.value == 'False' || component.value == 'false' || component.value == 0) {
|
||||
elem.checked = false;
|
||||
} else {
|
||||
elem.checked = true;
|
||||
}
|
||||
} else if (type == "enum") {
|
||||
elem.style.display = "block";
|
||||
let row = elem.closest('div');
|
||||
row.style.backgroundColor = "white";
|
||||
|
||||
let options = elem.childNodes;
|
||||
for (var j = 0; j < options.length; j++) {
|
||||
if (options[j].label == comp_value) {
|
||||
elem.value = j + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// XMLHttpRequest
|
||||
|
||||
|
Reference in New Issue
Block a user