pari: trunk r1694 - /trunk/config/digital.html

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Tue Oct 16 22:44:06 CDT 2007


Author: pari
Date: Tue Oct 16 22:44:06 2007
New Revision: 1694

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=1694
Log:
providing an option to select a number of channels to use in each span

Modified:
    trunk/config/digital.html

Modified: trunk/config/digital.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/digital.html?view=diff&rev=1694&r1=1693&r2=1694
==============================================================================
--- trunk/config/digital.html (original)
+++ trunk/config/digital.html Tue Oct 16 22:44:06 2007
@@ -73,6 +73,29 @@
 
 function hide_mymenu(){ menu.style.display="none"; }
 
+
+function calc_bchan_fxx(l){ // calculates the bchan,and fxx strings for a given span
+	var y = Number(SPANS[l]['min_ch']);
+	var z = Number(SPANS[l]['definedchans']);
+	if(z==1){return String(z);}
+
+	if ( SPANS[l]['signalling'].beginsWith('fx') ){
+		return y + "-" + String(y+z-1);
+	}else{
+		if(SPANS[l]['totchans'] <= 24){ // if T1
+			return y + "-" + String(y+z-1);
+		}else{ // if E1 - take first 15 as b-channels, then a d channel and then take the next 15 as bchannels
+			if(z==16){ return y+"-"+String(y+14)+","+String(y+16); }
+			if(z<= 15){
+				return y+"-"+String(y+z-1);
+			}else{
+				return y+"-"+String(y+14)+","+String(y+16) +"-"+ String(y+z);
+			}
+		}
+	}
+}
+
+
 function canelSpanInfo(){
 	_$('edit_span').style.display = "none";
 	_$('bg_transparent').style.display = "none";
@@ -87,7 +110,21 @@
 		_$('editspan_SPAN').innerHTML = SPANS[l]['description'];
 		_$('editspan_ALARMS').innerHTML = SPANS[l]['alarms'];
 
+		// console.log( SPANS[l]['min_ch'] );
+		// console.log( SPANS[l]['max_ch'] );
+		// console.log( SPANS[l]['definedchans']  );
+
 		ASTGUI.selectbox.clear( _$('editspan_fac') );
+		var w = _$('edit_DefinedChans') ;
+
+		var ijkl = function(){
+			ASTGUI.selectbox.clear(w);
+			var f = Number( SPANS[l]['totchans'] ), g=0;
+			for(g=1; g <=f; g++){ ASTGUI.selectbox.append(w,g,g); }
+			ASTGUI.selectbox.selectOption(w,SPANS[l]['definedchans']);
+			_$('edit_labelReserved').innerHTML = SPANS[l]['reserved_ch'];
+			_$('edit_labelZapchan').innerHTML = calc_bchan_fxx(l)
+		}();
 
 		if ( Number(SPANS[l]['totchans']) <= 24 ){
 			ASTGUI.selectbox.append(_$('editspan_fac'),'ESF/B8ZS', 'ESF/B8ZS');
@@ -222,10 +259,12 @@
 var loadConfigFiles = {
 	// read applyzap.conf (if exists) - so that the GUI knows the last configured hardware
 	// run ztscan - to detect digital cards
-	// read ztscan.conf - read spans information 
+	// read ztscan.conf - read spans information - also set the max , min values for each span
 	//   see if the number of spans in ztscan.conf matches with that from applyzap.conf 
 	//   (this way we know if any changes in digital hardware since the gui was last used)
-	// read users.conf - and read spans information
+	// read users.conf - and read spans information 
+	//   check if the channels in zapchan are within max and min
+	//   if yes then set the current range values
 
 	readApplyzap: function(){
 		
@@ -273,7 +312,7 @@
 				//_$('tablecontainer').style.display="none";
 				return false;
 			}
-		
+			var q = 0;
 			for( var l in n ){ if(n.hasOwnProperty(l)){
 				if( l =='general') { 
 					if(n[l]['continue'] && n[l]['continue'] == "no") {
@@ -298,6 +337,11 @@
 					SPANS[l][k] = n[l][k];
 					if( k == 'totchans' ){
 						SPANS[l]['spantype'] = ( Number(n[l][k]) <= 24) ? "T1" : "E1";
+						SPANS[l]['min_ch'] = q + 1;
+						SPANS[l]['max_ch'] = q + Number(n[l][k]) ;
+						SPANS[l]['reserved_ch'] = q + ( (Number(n[l][k])<=24)? 24 : 16 );
+						SPANS[l]['definedchans'] = 1; // default value
+						q += Number(n[l][k]);
 					}
 				}}
 			}}
@@ -316,13 +360,41 @@
 				//_$('tablecontainer').style.display="none";
 				return false;
 			}
+
+			var efgh = function(zc){ 
+					// calculate the number of channels defined for use in zapchan string
+					// zc can be in the format 'u', 'u-v', 'u-v,w-x' or 'u-v,w'
+					// the function returns 1 if u, (v-u +1) for the second case 
+					// and x-u for the third and // v-u+2 for the fourth case
+				try{
+					if( zc.contains('-') ){
+						if(zc.contains(',')){ // case 3 or case 4
+							if( zc.split('-').length > 2 ) { // case 3
+								return (Number(zc.split('-')[2]) - Number(zc.split('-')[0]));
+							}else{ // case 4
+								return (Number((zc.split('-')[1]).split(',')[0])-Number(zc.split('-')[0]) + 2);
+							}
+						} else { // case 'u-v'
+							return (Number(zc.split('-')[1])-Number(zc.split('-')[0])+1);
+						}
+					}else{ // case 1
+						return 1;
+					}
+				}catch(err){
+					return null;
+				}
+			};
+
 			var abcd = function(){
 				var tmp;
 				for( var l in n ){ if(n.hasOwnProperty(l)){
 					if( l.beginsWith('span_')) {
 						tmp = l.split('span_')[1];
 						if (!SPANS[tmp]){SPANS[tmp] = {};}
-						for( var k in n[l] ){ if(n[l].hasOwnProperty(k)){ SPANS[tmp][k] = n[l][k]; }}
+						for( var k in n[l] ){ if(n[l].hasOwnProperty(k)){ 
+							SPANS[tmp][k] = n[l][k];
+							if( k=='zapchan' ){ SPANS[tmp]['definedchans'] = efgh(n[l][k]); }
+						}}
 					}
 				}}
 			}();
@@ -422,9 +494,12 @@
 		var add_lines = function(){
 			var fxx={};
 			var c = 0, bchanstring = '', dchanstring = '', context = 'general';
+			var totalchans = 0, firstpart , secondpart, tmp2 , tmp3;
+
 			uri = build_action('delcat', c, context,"", ""); c++;
 			uri += build_action('newcat', c , context, "", ""); c++;
-			var totalchans = 0, firstpart , secondpart, tmp, tmp2 , tmp3;
+
+
 			for( var k in SPANS ){ if( SPANS.hasOwnProperty(k) ){ if(SPANS[k]['signalling']){
 				firstpart = "span";
 				/* XXX Timing source for card is being set to zero? */
@@ -432,31 +507,16 @@
 				secondpart = k + "," + SPANS[k]['syncsrc']  + "," + SPANS[k]['lbo'] + "," + SPANS[k]['fac'].toLowerCase().replace("/", ",");
 				uri += build_action('append', c, context, firstpart, secondpart ); c++;
 				tmp2 = (bchanstring)? ",":"";
-				
+				tmp3 = (dchanstring)? ",":"";
+
+				var ppp = calc_bchan_fxx(k);
 				if ( SPANS[k]['signalling'].beginsWith('fx') ){ 
-					bchanstring += '';
-					dchanstring += '';
-					tmp = totalchans + Number(SPANS[k]['totchans']);
-					tmp3 = String(totalchans+1) + "-" + String(tmp);
-					totalchans = tmp;
-					fxx[SPANS[k]['signalling']] = (fxx[SPANS[k]['signalling']])? fxx[SPANS[k]['signalling']] + "," + tmp3: tmp3 ;
+					fxx[SPANS[k]['signalling']] = ((fxx[SPANS[k]['signalling']])? fxx[SPANS[k]['signalling']] + ",":"") + ppp;
 				}else{
-					if(SPANS[k]['totchans'] <= 24){
-						tmp = totalchans + Number(SPANS[k]['totchans']);
-						dchanstring += tmp2 + String(tmp) ;
-						tmp3 = String(totalchans+1) + "-" + String(tmp-1);
-						bchanstring += tmp2 + tmp3;
-						totalchans = tmp;
-					}else{ // take first 15 as b-channels, then a d channel and then take the next 15 as bchannels
-						tmp = totalchans + Number(15);
-						tmp3 = String(totalchans+1) + "-" + String(tmp);
-						dchanstring += tmp2 + String(totalchans+16) ;
-						tmp3 += "," + String(tmp+2) + "-" + String(tmp+16);
-						bchanstring += tmp2 + tmp3;
-						totalchans = tmp + Number(16);
-					}
+					bchanstring += tmp2 + ppp;
+					dchanstring += tmp3 + SPANS[k]['reserved_ch'];
 				}
-				SPANS[k]['zapchanstring'] = tmp3;
+				SPANS[k]['zapchanstring'] = ppp;
 			}}}
 
 			for( var e in fxx ){ if(fxx.hasOwnProperty(e)){
@@ -529,16 +589,18 @@
 <div id="edit_span" STYLE="display:none; position: absolute; left: 30; top: 40; width:500; height:310;  background-color:#F4EFE5;   border-width: 1px; border-color: #7E5538; border-style: solid; z-index:5">
 	<table width="100%" cellpadding=0 cellspacing=0  onmousedown="ASTGUI.startDrag(event , 'edit_span');">
 	<TR bgcolor="#7E5538"  style="background-image:url('images/title_gradient.gif');">
-		<TD Height="20" align="right" style="cursor: move">
+		<TD Height="20" align="left" style="cursor: move">
+			<font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">
+			&nbsp;&nbsp;SPAN : <span id="editspan_SPAN"></span>
+			</font>
+		</TD>
+		<TD Height="20" align="right" style="cursor: move" width=20>
 			<A href="#" onclick="$('cancel_a').click();"><font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</font></A>
 		</TD>
 		<TD width=4></TD>
 	</TR>
 	</table>
 	<TABLE	align=center cellpadding=2 cellspacing=2 border=0>
-	<TR>	<TD align="right">SPAN:</TD>
-		<TD><span id="editspan_SPAN"></span></TD>
-	</TR>
 	<TR>	<TD align="right">ALARMS:</TD>
 		<TD><span id="editspan_ALARMS"></span></TD>
 	</TR>
@@ -591,7 +653,16 @@
 			</select>
 		</TD>
 	</TR>
-	
+
+	<TR>    <TD align="right" valign=top>Channels:</TD>
+		<TD>    <table border=0 cellpadding=2 cellspacing=1>
+				<tr>	<td> Use : <select id="edit_DefinedChans"></select>	</td>	</tr>
+				<tr>	<td> From : <span id="edit_labelZapchan"></span>	</td>	</tr>
+				<tr>	<td> Reserved : <span id="edit_labelReserved"></span>	</td>	</tr>
+			</table>
+		</TD>
+	</TR>
+
 	<TR>	<TD colspan=2 align=center height=50 valign=middle>  
 			<input type="button" id="save_a" value="Update" onclick="updateSpanInfo();">&nbsp;&nbsp;
 			<input type="button" id="cancel_a" value="Cancel" onclick="canelSpanInfo();">




More information about the asterisk-gui-commits mailing list