remote-exec: use a dedicated module to handle osc remote exec (edit etc)
This commit is contained in:
parent
5c2bbddbda
commit
6593cf29d4
4 changed files with 34 additions and 20 deletions
|
|
@ -2,14 +2,14 @@ var init = require('./init'),
|
|||
actions = require('./actions'),
|
||||
utils = require('./utils'),
|
||||
icon = utils.icon,
|
||||
{remoteEdit} = require('./editor/data-workers')
|
||||
remoteExec = require('./remote-exec')
|
||||
|
||||
module.exports = {
|
||||
|
||||
receiveOsc: function(event,data){
|
||||
var data = data || event
|
||||
|
||||
if (data.address == '/EDIT') return remoteEdit(data.args[0], data.args[1])
|
||||
if (data.address == '/EXEC') return remoteExec(data.args)
|
||||
|
||||
// fetch ids corresponding to the osc address
|
||||
var address = data.address,
|
||||
|
|
|
|||
|
|
@ -165,23 +165,8 @@ var incrementWidget = function(data){
|
|||
|
||||
}
|
||||
|
||||
var remoteEdit = function(id,json) {
|
||||
var newdata = JSON.parse(json),
|
||||
containers = WIDGETS[id]
|
||||
|
||||
if (!WIDGETS[id]) return
|
||||
for (var i=WIDGETS[id].length-1;i>=0;i--) {
|
||||
var container = WIDGETS[id][i].parent(),
|
||||
data = getObjectData(container)
|
||||
|
||||
$.extend(true,data,newdata)
|
||||
updateDom(container,data,true)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
updateDom:updateDom,
|
||||
getObjectData:getObjectData,
|
||||
incrementWidget:incrementWidget,
|
||||
remoteEdit:remoteEdit
|
||||
incrementWidget:incrementWidget
|
||||
}
|
||||
|
|
|
|||
25
src/browser/js/app/remote-exec.js
Normal file
25
src/browser/js/app/remote-exec.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
var {getObjectData, updateDom} = require('./editor/data-workers')
|
||||
|
||||
var callbacks = {
|
||||
edit: function(args) {
|
||||
var [id, json] = args,
|
||||
newdata = JSON.parse(json),
|
||||
containers = WIDGETS[id]
|
||||
|
||||
if (!WIDGETS[id]) return
|
||||
for (var i=WIDGETS[id].length-1;i>=0;i--) {
|
||||
var container = WIDGETS[id][i].parent(),
|
||||
data = getObjectData(container)
|
||||
|
||||
$.extend(true,data,newdata)
|
||||
updateDom(container,data,true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(args){
|
||||
var [name, ...args] = args
|
||||
if (callbacks[name]) {
|
||||
callbacks[name](args)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue