pari: branch asterisknow r1911 - in /branches/asterisknow/config: ./ scripts/
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Wed Dec 5 17:12:26 CST 2007
Author: pari
Date: Wed Dec 5 17:12:26 2007
New Revision: 1911
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=1911
Log:
rework on how group numbers are assigned for zap channels
Modified:
branches/asterisknow/config/digital.html
branches/asterisknow/config/scripts/astman.js
branches/asterisknow/config/trunks.html
Modified: branches/asterisknow/config/digital.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/digital.html?view=diff&rev=1911&r1=1910&r2=1911
==============================================================================
--- branches/asterisknow/config/digital.html (original)
+++ branches/asterisknow/config/digital.html Wed Dec 5 17:12:26 2007
@@ -96,6 +96,8 @@
var oldSpanCount = 0; // we get this from previuos applyzap.conf
var oldLoadZone;
var menu ; // document.getElementById('mymenu');
+var GROUPS = [];
+var NEWGROUPNUMBER;
function hide_mymenu(){ menu.style.display="none"; }
@@ -432,6 +434,16 @@
var abcd = function(){
var tmp;
for( var l in n ){ if(n.hasOwnProperty(l)){
+
+ if( n[l]['group'] && l !='general' ){
+ if( GROUPS.contains( Number(n[l]['group'])) ){
+ // duplicate group ???
+ // we wish to address this situation in future
+ }else{
+ GROUPS.push( Number(n[l]['group']) );
+ }
+ }
+
if( l.beginsWith('span_')) {
tmp = l.split('span_')[1];
//if (!SPANS[tmp]){ SPANS[tmp] = {}; }
@@ -545,9 +557,11 @@
uri += build_action('update', c, d , "trunkstyle", 'digital'); c++;
uri += build_action('update', c, d , "hassip", 'no'); c++;
uri += build_action('update', c, d , "hasiax", 'no'); c++;
+ NEWGROUPNUMBER = GROUPS.firstAvailable() ;
+ uri += build_action('update', c, d , "group", NEWGROUPNUMBER ); c++;
+ GROUPS.push(NEWGROUPNUMBER);
if ( !SPANS[k]['signalling'].beginsWith('fxo') ){ // we donot want context to be set for user stations
- uri += build_action('update', c, d , "group", String(k)); c++;
uri += build_action('update', c, d , "context", e); c++;
}
Modified: branches/asterisknow/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/scripts/astman.js?view=diff&rev=1911&r1=1910&r2=1911
==============================================================================
--- branches/asterisknow/config/scripts/astman.js (original)
+++ branches/asterisknow/config/scripts/astman.js Wed Dec 5 17:12:26 2007
@@ -60,10 +60,18 @@
return str.replace(/^[\s]+/, "").replace(/[\s]+$/, "");
}
+Array.prototype.firstAvailable = function(start) {
+ if(!start){ start = 1; }else{ start = Number( start ); }
+ i=0;
+ while( i < 1 ){
+ if( this.contains(start) ){ start++; }else{ return start; }
+ }
+}
+
Array.prototype.contains = function(str) {
- for (var i in this)
- if(str == this[i])
- return true;
+ for(var i=0; i < this.length; i++ ){
+ if( this[i] === str )return true;
+ }
return false;
}
Modified: branches/asterisknow/config/trunks.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/trunks.html?view=diff&rev=1911&r1=1910&r2=1911
==============================================================================
--- branches/asterisknow/config/trunks.html (original)
+++ branches/asterisknow/config/trunks.html Wed Dec 5 17:12:26 2007
@@ -25,6 +25,8 @@
var callbacks = new Object;
var providercallbacks = new Object;
var globalvars = new Object;
+var GROUPS = [];
+var NEWGROUPNUMBER;
var fieldnames =[ 'disallow','allow','signalling','callerid','cancel','contact','context','delete','dialformat','fromdomain','fromuser','canreinvite','group','hasexten','hasiax','hassip','host','insecure',
'name','new','port','provider','registeriax','registersip','save','secret','trunkname','trunkstyleanalog','trunkstylecustomvoip',
'trunkstylevoip','username','zapchan'];
@@ -105,6 +107,17 @@
}
callbacks.format = function(t) {
+
+ //if( t.fieldbyname['group'] && t.fieldbyname['zapchan']){
+ if( t.fieldbyname['group'] && t.name !='general' ){
+ if(GROUPS.contains(Number(t.fieldbyname['group']) )){
+ // what the hell, duplicate group ???
+ // we wish to address this situation in future
+ }else{
+ GROUPS.push( Number(t.fieldbyname['group']) );
+ }
+ }
+
if( InArray(dids_array, t.name) ){
//
if(t.fieldbyname['zapchan']){
@@ -395,7 +408,8 @@
else
newvalue = "SIP/" + _devices.value;
} else {
- newvalue = "Zap/g"+tmp[1];
+ newvalue = "Zap/g" + NEWGROUPNUMBER;
+ GROUPS.push(NEWGROUPNUMBER);
}
if (newvalue != oldvalue) {
@@ -471,7 +485,8 @@
_$('hassip').value = 'no';
_$('hasiax').value = 'no';
_$('callerid').value = 'asreceived';
- _$('group').value = _$('name').value.split('_')[1];
+ NEWGROUPNUMBER = GROUPS.firstAvailable() ;
+ _$('group').value = NEWGROUPNUMBER ;
} else if( _$('trunkstylecustomvoip').checked ){
// Custom VOIP Provider
_trunkname.value = "Custom - " + _$('customvoip_name').value;
More information about the asterisk-gui-commits
mailing list