remote-control: rename that api
This commit is contained in:
parent
d989c3423d
commit
89c89dbfce
5 changed files with 34 additions and 26 deletions
|
|
@ -158,11 +158,6 @@ module.exports = {
|
|||
$('#grid-width-input').remove()
|
||||
EDITING = false
|
||||
},
|
||||
tabsEnable: function(tabs){
|
||||
for (i in tabs) {
|
||||
$(`[data-id="${tabs[i]}"]`).trigger('fake-click')
|
||||
}
|
||||
},
|
||||
traversingDisable: function(){
|
||||
$('.traversingEnable, .traversingDisable').toggleClass('on')
|
||||
$('#container').trigger('disableTraversingGestures')
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ var {widgetManager} = require('./managers'),
|
|||
var Osc = function(){
|
||||
|
||||
this.syncOnly = false
|
||||
this.remoteExec = ()=>{console.error('remote-exec module not loaded')}
|
||||
this.remoteControl = ()=>{console.error('remote-control module not loaded')}
|
||||
|
||||
}
|
||||
|
||||
Osc.prototype.init = function(data) {
|
||||
this.remoteExec = require('./remote-exec')
|
||||
this.remoteControl = require('./remote-control')
|
||||
}
|
||||
|
||||
Osc.prototype.send = function(data) {
|
||||
|
|
@ -29,8 +29,7 @@ Osc.prototype.send = function(data) {
|
|||
|
||||
Osc.prototype.receive = function(data){
|
||||
|
||||
if (data.address == '/EXEC') return this.remoteExec(data.args)
|
||||
if (data.address == '/TABS') return actions.tabsEnable(data.args)
|
||||
if (this.remoteControl.exists(data.address)) return this.remoteControl.exec(data.address, data.args)
|
||||
|
||||
// fetch ids corresponding to the osc address
|
||||
var address = data.address,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,13 @@ var {getObjectData, updateDom} = require('./editor/data-workers'),
|
|||
{widgetManager} = require('./managers')
|
||||
|
||||
var callbacks = {
|
||||
edit: function(args) {
|
||||
'/EXEC': function(args) {
|
||||
// backward-compatibility
|
||||
var [name, ...args] = args
|
||||
if (name == 'edit') return callbacks['/EDIT'](args)
|
||||
if (name == 'edit_soft') return callbacks['/EDIT_SOFT'](args)
|
||||
},
|
||||
'/EDIT': function(args) {
|
||||
var [id, json] = args,
|
||||
newdata = JSON.parse(json),
|
||||
containers = widgetManager.getWidgetById(id)
|
||||
|
|
@ -18,7 +24,7 @@ var callbacks = {
|
|||
updateDom(container,data,true)
|
||||
}
|
||||
},
|
||||
edit_soft: function(args) {
|
||||
'/EDIT_SOFT': function(args) {
|
||||
var [id, json] = args,
|
||||
newdata = JSON.parse(json),
|
||||
containers = widgetManager.getWidgetById(id)
|
||||
|
|
@ -31,12 +37,21 @@ var callbacks = {
|
|||
$.extend(true,data,newdata)
|
||||
updateDom(container,data,true)
|
||||
}
|
||||
},
|
||||
'/TABS': function(args) {
|
||||
for (i in args) {
|
||||
$(`[data-id="${args[i]}"]`).trigger('fake-click')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(args){
|
||||
var [name, ...args] = args
|
||||
if (callbacks[name]) {
|
||||
callbacks[name](args)
|
||||
module.exports = {
|
||||
exec: function(name, args){
|
||||
if (callbacks[name]) {
|
||||
callbacks[name](args)
|
||||
}
|
||||
},
|
||||
exists: function(name){
|
||||
return name in callbacks
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue