- now storing path and widgets id references at init for faster cross-app synchronization

This commit is contained in:
jean-emmanuel 2015-09-09 15:12:06 +02:00 • committed by bordun
parent 2d673310dd
commit 32e9fe7de6
3 changed files with 9 additions and 3 deletions

View file

@ -1,7 +1,8 @@
ipc.on('receiveOsc',function(data){
// fetch id
var path = data.address;
var id = $('[path="'+path+'"]').attr('widgetId');
var id = __widgetsIds__[path]
// update
if (__widgets__[id]!=undefined) {

View file

@ -34,6 +34,7 @@ init = function(callback) {
// Tabs...
$('.tablist a').click(function(){

View file

@ -38,6 +38,7 @@ parsetabs = function(tabs,parent,sub){
}
__widgets__ = {}
__widgetsIds__ = {}
parsewidgets = function(widgets,parent) {
@ -55,16 +56,19 @@ parsewidgets = function(widgets,parent) {
</div>\
');
// create widget
var widgetInner = createWidget[type](widgetData,parent)
widgetInner.type = widgetData.type || 'fader'
widgetInner.type = type
// store widget reference for cross widget sync
widget.append(widgetInner)
if (__widgets__[widgetId]==undefined) {
__widgets__[widgetId] = []
}
__widgets__[widgetId].push(widgetInner)
// store path vs widget id for faster cross-app sync
__widgetsIds__[widgetData.path ] = widgetId
parent.append(widget);
}