1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-13 11:29:53 +03:00

Basic render of global function table

This commit is contained in:
Pawel Spychalski (DzikuVx) 2020-04-10 11:37:52 +02:00
parent a15277ae25
commit 7478f6cd04
8 changed files with 256 additions and 35 deletions

View file

@ -260,5 +260,37 @@ GUI_control.prototype.load = function(rel, callback) {
});
}
GUI_control.prototype.renderOperandValue = function ($container, operandMetadata, operand, value, onChange) {
$container.find('.logic_element__operand--value').remove();
switch (operandMetadata.type) {
case "value":
$container.append('<input type="number" class="logic_element__operand--value" data-operand="' + operand + '" step="' + operandMetadata.step + '" min="' + operandMetadata.min + '" max="' + operandMetadata.max + '" value="' + value + '" />');
break;
case "range":
case "dictionary":
$container.append('<select class="logic_element__operand--value" data-operand="' + operand + '"></select>');
let $t = $container.find('.logic_element__operand--value');
if (operandMetadata.type == "range") {
for (let i = operandMetadata.range[0]; i <= operandMetadata.range[1]; i++) {
$t.append('<option value="' + i + '">' + i + '</option>');
}
} else if (operandMetadata.type == "dictionary") {
for (let k in operandMetadata.values) {
if (operandMetadata.values.hasOwnProperty(k)) {
$t.append('<option value="' + k + '">' + operandMetadata.values[k] + '</option>');
}
}
}
$t.val(value);
break;
}
$container.find('.logic_element__operand--value').change(onChange);
};
// initialize object into GUI variable
var GUI = new GUI_control();