espiceland: branch 2.0 r5070 - /branches/2.0/config/js/
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Thu Aug 26 11:36:55 CDT 2010
Author: espiceland
Date: Thu Aug 26 11:36:51 2010
New Revision: 5070
URL: http://svnview.digium.com/svn/asterisk-gui?view=rev&rev=5070
Log:
Fixed issue where filter function was being added to the calling rule
incorrectly. Some of r5010 had not been applied here, and some more code
from an unknown revision. Fixes ASTGUI-199
Modified:
branches/2.0/config/js/astman.js
branches/2.0/config/js/callingrules.js
Modified: branches/2.0/config/js/astman.js
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/js/astman.js?view=diff&rev=5070&r1=5069&r2=5070
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Thu Aug 26 11:36:51 2010
@@ -1685,11 +1685,60 @@
getArgsArrayFromArgsString: function(x){ // expects x as 'context,exten,pri' or 'context,exten,pri'
if (typeof x != 'string') return [];
+
+ var nested_parse = function (str, sep) {
+ var buffer = '';
+ var stack = new Array();
+ var depth = 0;
+ var len = str.length;
+ for(var i=0; i<len; i++) {
+ var char = str.charAt(i);
+ switch(char) {
+ case '(':
+ depth++;
+ break;
+ case sep.toString():
+ if (!depth) {
+ if (buffer != '') {
+ stack.push(buffer);
+ buffer = '';
+ }
+
+ continue;
+ }
+
+ break;
+ case ' ':
+ if (!depth) {
+ continue;
+ }
+ break;
+ case ')':
+ if (depth) {
+ depth--;
+ } else {
+ stack.push("" + buffer + char);
+ buffer = '';
+ continue;
+ }
+ break;
+ }
+ buffer += char;
+ }
+
+ if (buffer == '') {
+ stack.push(buffer);
+ }
+
+ return stack;
+ };
+
if(x.contains(',') ){
- return x.split(',');
+ nested_parse(x,',');
+ return nested_parse(x,',');
}
if(x.contains('|') ){
- return x.split('|');
+ return nested_parse(x,'|');
}
return [x] ;
},
@@ -1906,16 +1955,26 @@
if(!WhatToDial.contains('${EXTEN')){ // if WhatToDial is in some other format that the gui does not understand
// TODO : replace the above if condition with a regular expression to check for the acceptable formats
// TODO : THROW ERROR
- return {name : trunkname, channel : channel, prepend : WhatToDial, stripx : ''};
+ return {name : trunkname, channel : channel, prepend : WhatToDial, stripx : '', filter: ''};
}
var prepend = WhatToDial.beforeChar('$') ;
- var extenString = WhatToDial.betweenXY('{','}') ;
+ if (WhatToDial.contains('FILTER')) {
+ var filterstring = WhatToDial.betweenXY('(', ')');
+ filterstring = filterstring.split(',');
+
+ var extenString = filterstring[1].betweenXY('{', '}');
+ var filter = filterstring[0];
+ } else {
+ var extenString = WhatToDial.betweenXY('{','}') ;
+ var filter = '';
+ }
var stripXdigitsfromfront = ( extenString.contains(':') ) ? extenString.afterChar(':') || '0' : '0' ;
} else { // WhatToDial is a plain extension string such as '911' or 'pari'
var prepend = WhatToDial ;
var stripXdigitsfromfront = 'ALL' ;
- }
- return { name : trunkname, channel : channel, prepend : prepend, stripx : stripXdigitsfromfront };
+ var filter = '';
+ }
+ return { name : trunkname, channel : channel, prepend : prepend, stripx : stripXdigitsfromfront, filter: filter};
},
obCallingRule: function(str){ // usage ASTGUI.parseContextLine.obCallingRule(str)
@@ -1953,16 +2012,19 @@
cr.firstTrunk = t1.name ;
cr.firstPrepend = t1.prepend ;
cr.stripdigits_firstTrunk = t1.stripx ;
+ cr.firstFilter = t1.filter;
if( macroargs.length <= 2 || ( macroargs.length > 2 && macroargs[2].trim() == '') ){ // if a failback trunk is not defined
cr.secondTrunk = '' ;
cr.secondPrepend = '' ;
cr.stripdigits_secondTrunk = '' ;
+ cr.secondFilter = '';
}else{
var t2 = ASTGUI.parseContextLine.parseTrunkDialArgument( macroargs[2] ) ;
cr.secondTrunk = t2.name ;
cr.secondPrepend = t2.prepend ;
cr.stripdigits_secondTrunk = t2.stripx ;
+ cr.secondFilter = t2.filter;
}
}else{
cr.destination = ASTGUI.parseContextLine.getAppWithArgs( str ) ;
Modified: branches/2.0/config/js/callingrules.js
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/js/callingrules.js?view=diff&rev=5070&r1=5069&r2=5070
==============================================================================
--- branches/2.0/config/js/callingrules.js (original)
+++ branches/2.0/config/js/callingrules.js Thu Aug 26 11:36:51 2010
@@ -45,6 +45,9 @@
var edit_CR_form = function(a,b){
isNew = false;
_$('cr_dialog_title').innerHTML =' Edit Calling Rule';
+
+ DOM_new_crl_tr_filter.value = '';
+ DOM_new_crl_fotr_filter.value = '';
EDIT_CR = a;
EDIT_CR_RULE = b;
@@ -63,11 +66,13 @@
DOM_new_crl_tr_stripx.value = tmp_cr.stripdigits_firstTrunk ;
DOM_new_crl_tr_prepend.value = tmp_cr.firstPrepend ;
+ DOM_new_crl_tr_filter.value = tmp_cr.firstFilter;
if(tmp_cr.secondTrunk){
DOM_new_crl_foChkbx.checked = true
ASTGUI.selectbox.selectOption(DOM_new_crl_fotrunk, tmp_cr.secondTrunk );
DOM_new_crl_fotr_stripx.value = tmp_cr.stripdigits_secondTrunk ;
DOM_new_crl_fotr_prepend.value = tmp_cr.secondPrepend ;
+ DOM_new_crl_fotr_filter.value = tmp_cr.secondFilter;
} else {
DOM_new_crl_foChkbx.checked = false;
}
@@ -335,12 +340,12 @@
}
var t1_braces = (t1 == 'Skype') ? t1 : '${' + t1 + '}' ;
- var Trunk_Build_str = ',' + t1_braces + '/' + DOM_new_crl_tr_prepend.value + '${' + DOM_new_crl_tr_filter.value +',${EXTEN:' + tmp_stripx + '})}' ;
+ var Trunk_Build_str = ',' + t1_braces + '/' + DOM_new_crl_tr_prepend.value + '${FILTER(' + DOM_new_crl_tr_filter.value +',${EXTEN:' + tmp_stripx + '})}' ;
var foTrunk_Build_str = ',' ;
if(DOM_new_crl_foChkbx.checked){
var t2_braces = (t2 == 'Skype') ? t2 : '${' + t2 + '}' ;
- foTrunk_Build_str += t2_braces + '/' + DOM_new_crl_fotr_prepend.value + '${EXTEN:' + tmp_fotr_stripx + '}' ;
+ foTrunk_Build_str += t2_braces + '/' + DOM_new_crl_fotr_prepend.value + '${FILTER(' + DOM_new_crl_fotr_filter.value + ',${EXTEN:' + tmp_fotr_stripx + '})}' ;
}
var t1_cidarg = ( t1 == 'Skype') ? ',' : ',' + t1 ;
More information about the asterisk-gui-commits
mailing list