FIXED: gestion des regexp

This commit is contained in:
xdrm-brackets 2016-09-18 15:13:14 +02:00
parent 6fb77480ca
commit dff156a88b
2 changed files with 2 additions and 5 deletions

View File

@ -4,6 +4,6 @@ FormBuilder.prototype.add_definition=function(a){for(var b in a)this.defs_object
FormBuilder.prototype.attach=function(a){if(!(a instanceof Element)&&null==this.parent_element)return!1;this.parent_element=a instanceof Element?a:this.parent_element};FormBuilder.formatFormObject=function(a,b){if(a.hasOwnProperty("children"))for(var g in a.children)a.children[g].parent=a,FormBuilder.formatFormObject(a.children[g],b);return a};
FormBuilder.fetchNodeDefinition=function(a,b){var g,c;r=FormBuilder.regex.reg_in_key;if("undefined"!=typeof b&&b.hasOwnProperty(a))return{def:b[a]};for(g in b)if(r.test(g)&&(c=new RegExp(g.slice(1,-1)),c.test(a))){matches={};for(c=1;c<RegExp.length&&10>c;c++)matches["$"+c]=RegExp["$"+c];return{def:b[g],scope:matches}}return{}};
FormBuilder.replaceStatements=function(a,b,g){a=a instanceof Object?a:{};b=b instanceof Object?JSON.parse(JSON.stringify(b)):{};var c,f,e,h;if(a.hasOwnProperty("scope")&&a.scope instanceof Object)for(c in a.scope)b[c]=a.scope[c];if(a.hasOwnProperty("node")&&"string"==typeof a.node&&(f=FormBuilder.fetchNodeDefinition(a.node,g),f.hasOwnProperty("def")&&(a.node_link=JSON.parse(JSON.stringify(f.def)),f.hasOwnProperty("scope"))))for(c in f.scope)b[c]=f.scope[c];a.received=b;for(c in a)if("string"==typeof a[c]){f=
FormBuilder.regex.arr_out_set;var d=[];(e=f.exec(a[c]))&&d.push(e[1]);for(e in d)b.hasOwnProperty(d[e])||(b[d[e]]=[]),a[c]=b[d[e]];if(!(0<d.length)){f=FormBuilder.regex.reg_out_val;h=-1;for(d=[];null!==(e=f.exec(a[c]))&&!(h>=f.lastIndex);)h=f.lastIndex,d.push(e[1]);for(e in d)b.hasOwnProperty(d[e])||(b[d[e]]=""),f=new RegExp("{$"+d[e][1]+"}","g"),a[c]=a[c].replace(f,b[d[e]]);if(!(0<d.length)){f=FormBuilder.regex.pri_out_val;for(d=[];null!==(e=f.exec(a[c]));)d.push(e[1]);for(e in d)b.hasOwnProperty(d[e])||
FormBuilder.regex.arr_out_set;var d=[];(e=f.exec(a[c]))&&d.push(e[1]);for(e in d)b.hasOwnProperty(d[e])||(b[d[e]]=[]),a[c]=b[d[e]];if(!(0<d.length)){f=FormBuilder.regex.reg_out_val;h=-1;for(d=[];null!==(e=f.exec(a[c]))&&!(h>=f.lastIndex);)h=f.lastIndex,d.push(e[1]);for(e in d)b.hasOwnProperty(d[e])||(b[d[e]]=""),f=new RegExp("{\\$"+d[e][1]+"}","g"),console.log(f),a[c]=a[c].replace(f,b[d[e]]);if(!(0<d.length)){f=FormBuilder.regex.pri_out_val;for(d=[];null!==(e=f.exec(a[c]));)d.push(e[1]);for(e in d)b.hasOwnProperty(d[e])||
(b[d[e]]=""),f=new RegExp("{"+d[e]+"}","g"),console.log("replacing",a[c],f,b[d[e]]),a[c]=a[c].replace(f,b[d[e]]);f=FormBuilder.regex.arr_out_val;for(d=[];null!==(e=f.exec(a[c]));)d.push(e[1]);for(e in d)b.hasOwnProperty(d[e])||(b[d[e]]=""),f=new RegExp("{"+d[e]+"}","g"),a[c]=a[c].replace(f,b[d[e]])}}}for(c in a)FormBuilder.regex.pri_in_key.test(c)?b[c.substring(1)]=a[c]:FormBuilder.regex.arr_in_key.test(c)&&(b[c.substring(2)]=a[c]);b=JSON.parse(JSON.stringify(b));for(c in a)if(-1<FormBuilder.spread_attr.indexOf(c))if(a[c]instanceof
Array)for(var k in a[c])FormBuilder.replaceStatements(a[c][k],b,g);else a[c]instanceof Object&&FormBuilder.replaceStatements(a[c],b,g);return a};FormBuilder.buildString=function(a){var b,g="";for(b in a)a[b]instanceof refObject?g+=""+a[b].get():"undefined"!=typeof a[b]?g+=""+a[b].toString():console.log(a[b],"cant be displayed");return g};

View File

@ -399,12 +399,9 @@ FormBuilder.replaceStatements = function(object, scope, definitions){
scope[m_reg[m]] = ''; // on met une chaine vide
// {2} on remplace toutes les occurences par la valeur //
tmp = new RegExp( "{$"+m_reg[m][1]+"}", 'g' );
// FIXME
tmp = new RegExp( "{\\$"+m_reg[m][1]+"}", 'g' );
object[key] = object[key].replace(tmp, scope[m_reg[m]]);
// console.log('reg', m_reg[m], scope);
}
/* (1.4) Si on a trouvé qqch, on passe à la clé suivante */