remote control: add /SET method (issue #56)

This commit is contained in:
jean-emmanuel 2017-12-21 12:33:58 +01:00
parent 2569dda2bd
commit 322c98ce6e
3 changed files with 49 additions and 0 deletions

View file

@ -87,6 +87,38 @@ var callbacks = {
}
},
'/SET':function(args) {
var [idOrAddress, ...preArgsOrValue] = args,
widgets = [],
value = null
if (idOrAddress[0] == '/') {
[widgets, value] = widgetManager.getWidgetByAddressAndArgs(
idOrAddress,
preArgsOrValue
)
} else {
widgets = widgetManager.getWidgetById(idOrAddress)
value = preArgsOrValue
if (value.length == 0) value = null
else if (value.length == 1) value = value[0]
}
for (var i = widgets.length - 1; i >= 0; i--) {
return widgets[i].setValue(value, {
sync: true,
send: true
})
}
},
'/TABS': function(args) {