widget mananger: declare the address/preargs separator only once, in the module
editor: fix incrementer not properly checking for existing widgets in store
This commit is contained in:
parent
07529b9753
commit
ed8405a315
3 changed files with 21 additions and 5 deletions
|
|
@ -130,13 +130,18 @@ var incrementWidget = function(data){
|
|||
|
||||
} else if (address){
|
||||
var addressref
|
||||
while (widgetManager.getWidgetByAddress(addressref)) {
|
||||
while (widgetManager.getWidgetByAddress(addressref).length) {
|
||||
address = address.replace(/([0-9]*)$/,function(m){
|
||||
var n = parseInt(m)+1
|
||||
n = isNaN(n)?1:n
|
||||
return n
|
||||
})
|
||||
addressref = data.preArgs&&data.preArgs.length?address+'||||'+data.preArgs.join('||||'):address
|
||||
addressref = widgetManager.createAddressRef({
|
||||
widgetData: {
|
||||
preArgs: data.preArgs,
|
||||
address: address
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
data.address = address
|
||||
|
|
@ -144,7 +149,7 @@ var incrementWidget = function(data){
|
|||
}
|
||||
|
||||
if (id) {
|
||||
while (widgetManager.getWidgetById(id)) {
|
||||
while (widgetManager.getWidgetById(id).length) {
|
||||
id = id.replace(/([0-9]*)$/,function(m){
|
||||
var n = parseInt(m)+1
|
||||
n = isNaN(n)?1:n
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
var WidgetManager = function(){
|
||||
|
||||
this.widgets = []
|
||||
|
||||
this.addressRoute = {}
|
||||
this.idRoute = {}
|
||||
this.linkIdRoute = {}
|
||||
|
||||
this.preArgsSeparator = '||||'
|
||||
|
||||
$(document).ready(()=>{
|
||||
$('body').off('sync.global').on('sync.global',(e)=>{
|
||||
|
||||
|
|
@ -49,7 +52,7 @@ WidgetManager.prototype.createHash = function(widget) {
|
|||
WidgetManager.prototype.createAddressRef = function(widget) {
|
||||
|
||||
return widget.widgetData.preArgs && widget.widgetData.preArgs.length ?
|
||||
widget.widgetData.address + '||||' + widget.widgetData.preArgs.join('||||')
|
||||
widget.widgetData.address + this.preArgsSeparator + widget.widgetData.preArgs.join(this.preArgsSeparator)
|
||||
: widget.widgetData.address
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,12 +34,20 @@ Osc.prototype.receive = function(data){
|
|||
|
||||
if (typeof data.args == 'object') {
|
||||
for (var i=data.args.length-1;i>=0;i--) {
|
||||
var ref = address+'||||'+data.args.slice(0,i).join('||||')
|
||||
|
||||
var ref = widgetManager.createAddressRef({
|
||||
widgetData: {
|
||||
preArgs: data.args.slice(0,i),
|
||||
address: address
|
||||
}
|
||||
})
|
||||
|
||||
if (widgetManager.getWidgetByAddress(ref).length) {
|
||||
addressref = ref
|
||||
args = data.args.slice(i,data.args.length)
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
args = data.args
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue