Merge pull request #358 from omar92/allow-equations-in-number-inputs

try solve the numbers equations
This commit is contained in:
Javi Agenjo
2023-04-07 19:23:20 +02:00
committed by GitHub

View File

@@ -9990,7 +9990,14 @@ LGraphNode.prototype.executeAction = function(action)
var delta = x < 40 ? -1 : x > widget_width - 40 ? 1 : 0;
if (event.click_time < 200 && delta == 0) {
this.prompt("Value",w.value,function(v) {
inner_value_change(this, this.value);
// check if v is a valid equation or a number
if (/^[0-9+\-*/()\s]+$/.test(v)) {
try {//solve the equation if possible
v = eval(v);
} catch (e) { }
}
this.value = Number(v);
inner_value_change(this, this.value);
}.bind(w),
event);
}