pari: branch pari/dahdi_support r4437 - in /team/pari/dahdi_support/config: ....

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Fri Jan 16 10:09:48 CST 2009


Author: pari
Date: Fri Jan 16 10:09:48 2009
New Revision: 4437

URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4437
Log:

 restoring hardware.html (just zaptel)



Added:
    team/pari/dahdi_support/config/js/hardware_dahdi.js
Modified:
    team/pari/dahdi_support/config/hardware.html
    team/pari/dahdi_support/config/js/hardware.js

Modified: team/pari/dahdi_support/config/hardware.html
URL: http://svn.digium.com/svn-view/asterisk-gui/team/pari/dahdi_support/config/hardware.html?view=diff&rev=4437&r1=4436&r2=4437
==============================================================================
--- team/pari/dahdi_support/config/hardware.html (original)
+++ team/pari/dahdi_support/config/hardware.html Fri Jan 16 10:09:48 2009
@@ -118,7 +118,9 @@
 
 	<div class="pageheading">Analog Hardware</div>
 	<div style="overflow:auto;left:40">
-		<table id="FXSFXO_ports_td" cellpadding=5 cellspacing=1 align=center border=0 class='taglist' width=480></table>
+		<table id="FXSFXO_ports_td" cellpadding=5 cellspacing=1 align=center border=0 class='taglist' width=480>
+
+		</table>
 	</div>
 
 	<div>
@@ -181,6 +183,7 @@
 	<div class="pageheading">Advanced Settings</div>
 	
 	<table align=center>
+	
 	<tr>	<td align=right>Module Name : </td>
 		<td>&nbsp;<input id="zap_moduleName" dfalt='wctdm24xxp' size=10></td>
 	</tr>

Modified: team/pari/dahdi_support/config/js/hardware.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/pari/dahdi_support/config/js/hardware.js?view=diff&rev=4437&r1=4436&r2=4437
==============================================================================
--- team/pari/dahdi_support/config/js/hardware.js (original)
+++ team/pari/dahdi_support/config/js/hardware.js Fri Jan 16 10:09:48 2009
@@ -19,7 +19,7 @@
  *
  */
 var MODULE_NAME = 'wctdm24xxp';
-var DRIVERS_LIST = [ 'tor2','wcb4xxp', 'wcfxo', 'wct1xxp', 'wct4xxp', 'wctc4xxp', 'wctdm24xxp', 'wctdm', 'wcte11xp', 'wcte12xp', 'wcusb', 'xpp_usb' ];
+var DRIVERS_LIST = [ 'tor2', 'wcfxo', 'wct1xxp', 'wct4xxp', 'wctc4xxp', 'wctdm24xxp', 'wctdm', 'wcte11xp', 'wcte12xp', 'wcusb', 'xpp_usb' ];
 
 var SPANS = {};
 
@@ -96,7 +96,7 @@
 };
 
 
-var detectHwChanges = function(){ // compare DETECTEDHARDWARE vs CONFIGUREDHARDWARE 
+function detectHwChanges(){ // compare DETECTEDHARDWARE vs CONFIGUREDHARDWARE 
 // returns true if a hardware change is detected and false if there are no hardware changes
 // we can actually check a lot of things here like
 	// [A] check if - any cards are missing 
@@ -140,27 +140,23 @@
 		ASTGUI.Log.Debug("DEVICES or basechans does not MATCHED");
 		return true;
 	}
-};
-
-
-
-
-
-var verify_priChLimit = function(){
+}
+
+
+
+
+
+function verify_priChLimit(){
 	var l = String(CURRENT_SPAN);
 	if( !_$('editspan_signalling').value.beginsWith('pri')){ return true;}
 	var y = Number(_$('edit_DefinedChans').value);
-	if( Number(SPANS[l]['totchans'] ) ==3 ){return true;}
 	if( Number(SPANS[l]['totchans'] ) <= 24 && y ==24){return false;}//alert("You should leave atleast 1 channel for PRI signalling");
 	if( Number(SPANS[l]['totchans'] ) > 24 && y ==31){return false;}//alert("You should leave atleast 1 channel for PRI signalling");
 	return true;
 };
 
-var calc_bchan_fxx = function(l){ // calculates the bchan,and fxx strings for a given span
+function calc_bchan_fxx(l){ // calculates the bchan,and fxx strings for a given span
 	var y = Number(SPANS[l]['min_ch']);
-	if( SPANS[l]['totchans'] == 3 ){
-		return y + "-" + String(y+1);
-	}
 	var z = Number(SPANS[l]['definedchans']);
 	if(z==1){return String(y);}
 
@@ -181,7 +177,7 @@
 }
 
 
-var canelSpanInfo = function(){
+function canelSpanInfo(){
 	_$('edit_span').style.display = "none";
 	ASTGUI.showbg(false);
 	CURRENT_SPAN = null;
@@ -202,37 +198,17 @@
 	var ijkl = function(){
 		ASTGUI.selectbox.clear(w);
 		var f = Number( SPANS[l]['totchans'] ), g=0;
-		if(f == 31){ f = 30; } // always make sure that only a max of 30 ports are available on E1 
+		if(f == 31){ f = 30;} // always make sure that only a max of 30 ports are available on E1 
 		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']) == 3 ){
-		ASTGUI.selectbox.append(_$('editspan_fac'),'CCS/AMI', 'CCS/AMI');
-		//_$('editspan_signalling')
-		ASTGUI.selectbox.clear(_$('editspan_signalling'));
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'bri_cpe', 'bri_cpe');
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'bri_net', 'bri_net');
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'bri_cpe_ptmp', 'bri_cpe_ptmp');
-	}else{
-		ASTGUI.selectbox.clear(_$('editspan_signalling'));
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'PRI - Net', 'pri_net');
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'PRI - CPE', 'pri_cpe');
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'E & M', 'em');
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'E & M -- Wink', 'em_w');
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'E & M -- featd(DTMF)', 'featd');
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'FXOKS', 'fxo_ks');
-		ASTGUI.selectbox.append(_$('editspan_signalling'),'FXOLS', 'fxo_ls');
-	}
-
-	if ( Number(SPANS[l]['totchans']) == 24 ){
+	if ( Number(SPANS[l]['totchans']) <= 24 ){
 		ASTGUI.selectbox.append(_$('editspan_fac'),'ESF/B8ZS', 'ESF/B8ZS');
 		ASTGUI.selectbox.append(_$('editspan_fac'),'D4/AMI', 'D4/AMI');
-	}
-
-	if ( Number(SPANS[l]['totchans']) == 31 ){
+	}else{
 		ASTGUI.selectbox.append(_$('editspan_fac'),'CCS/HDB3', 'CCS/HDB3');
 		ASTGUI.selectbox.append(_$('editspan_fac'),'CCS/CRC4/HDB3', 'CCS/CRC4/HDB3');
 	}
@@ -247,14 +223,12 @@
 
 	_$('editspan_channels').innerHTML = String(SPANS[l]['definedchans']) + "/" + String(SPANS[l]['totchans']) + " ("+SPANS[l]['spantype']+")";
 
-
 	if( SPANS[l]['signalling'] ){
 		ASTGUI.selectbox.selectOption( _$('editspan_signalling') , SPANS[l]['signalling'] );
 	}else{
 		_$('editspan_signalling').selectedIndex = -1 ; 
 	}
 	disablEnable_sc();
-
 	if(SPANS[l]['switchtype']){
 		ASTGUI.selectbox.selectOption( _$('editspan_switchtype') , SPANS[l]['switchtype'] );
 	}else{
@@ -276,7 +250,7 @@
 };
 
 
-var showtable = function(){ // navigates through the SPANS object and presents as a table to the user
+function showtable(){ // navigates through the SPANS object and presents as a table to the user
 	var keepalert = false ;
 	try{
 		var tbl = _$('digitalcardstable') ;
@@ -356,7 +330,7 @@
 			parent.ASTGUI.dialog.hide();
 		}
 	}
-};
+}
 
 
 var loadConfigFiles = {
@@ -373,7 +347,7 @@
 		var n = config2json({filename:hwcfgfile, usf:1});
 		if( n.getOwnProperties().length == 0 ){ // if file not found or no previous hardware detected
 				hwchanged = -1;
-				loadConfigFiles.run_detectdahdi();
+				loadConfigFiles.runZtscan();
 				return;
 		}else{
 			CONFIGUREDHARDWARE = {};
@@ -383,29 +357,28 @@
 				CONFIGUREDHARDWARE[l]['basechan'] = n[l]['basechan'];
 				CONFIGUREDHARDWARE[l]['type'] = n[l]['type'];
 			}}
-			loadConfigFiles.run_detectdahdi();
+			loadConfigFiles.runZtscan();
 		}
 		ASTGUI.Log.Debug("end of function: loadConfigFiles.load_hwcfgfile()");
 	},
 
-	run_detectdahdi: function(){
-		ASTGUI.Log.Debug("start function: loadConfigFiles.run_detectdahdi()");
+	runZtscan: function(){
+		ASTGUI.Log.Debug("start function: loadConfigFiles.runZtscan()");
 
 		ASTGUI.miscFunctions.createConfig( 'applyzap.conf', function(){
-			parent.ASTGUI.systemCmd( top.sessionData.directories.app_DahdiScan , function(){ // run ztscan and then try loading ztscan.conf
-				window.setTimeout( loadConfigFiles.read_DahdiScanConf , 700 ); // leave some time for ztscan to generate ztscan.conf
+			parent.ASTGUI.systemCmd( top.sessionData.directories.app_Ztscan , function(){ // run ztscan and then try loading ztscan.conf
+				window.setTimeout( loadConfigFiles.readZtscanConf , 700 ); // leave some time for ztscan to generate ztscan.conf
 			});
-			ASTGUI.Log.Debug("end of function: loadConfigFiles.run_detectdahdi()");
+			ASTGUI.Log.Debug("end of function: loadConfigFiles.runZtscan()");
 		});
 	},
 
-	//readZtscanConf: function(){
-	read_DahdiScanConf: function(){
-		ASTGUI.Log.Debug("start function: loadConfigFiles.read_DahdiScanConf()");
-		var ztsc = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename=' + ASTGUI.globals.dahdiScanOutput , async: false }).responseText;
+	readZtscanConf: function(){
+		ASTGUI.Log.Debug("start function: loadConfigFiles.readZtscanConf()");
+		var ztsc = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename=ztscan.conf', async: false }).responseText;
 		var ztsc_Lower = ztsc.toLowerCase();
 		if( ztsc_Lower.contains('response: error') && ztsc_Lower.contains('message: config file not found') ){
-			parent.ASTGUI.dialog.waitWhile("Please check if <B>ztscan</B> is installed ? <BR> /etc/asterisk/dahdi_scan.conf not found");
+			parent.ASTGUI.dialog.waitWhile("Please check if <B>ztscan</B> is installed ? <BR> /etc/asterisk/ztscan.conf not found");
 			ASTGUI.feedback( { msg:"No Cards/Spans found,  No Config File found !!", showfor:2 });
 			return;
 		}
@@ -435,24 +408,11 @@
 					DETECTEDHARDWARE[ n[l]['location'] ]['type'] = n[l]['type'];
 				}
 				if( k == 'totchans' ){
-					SPANS[l]['spantype'] = n[l]['type'].split('-')[1]; // part after '-' in 'digital-T1' or 'digital-E1' or 'digital-NT' or 'digital-TE'
-					SPANS[l]['min_ch'] = Number(n[l]['basechan']) ;
+					SPANS[l]['spantype'] = n[l]['type'].split('-')[1]; // part after '-' in 'digital-T1' or 'digital-E1'
+					SPANS[l]['min_ch'] = Number(n[l]['basechan']); 
 					SPANS[l]['max_ch'] =  Number(n[l]['basechan']) + Number(n[l]['totchans']) - 1 ; 
-
-					var n_tc = Number(n[l]['totchans']) ;
-					switch(n_tc){
-						case 3:
-							SPANS[l]['definedchans'] = 2;
-							SPANS[l]['reserved_ch'] = Number(n[l]['basechan']) + 2 ;
-						case 24:
-							SPANS[l]['definedchans'] = 23;
-							SPANS[l]['reserved_ch'] = Number(n[l]['basechan']) + 23;
-						case 31:
-							SPANS[l]['definedchans'] = 30;
-							SPANS[l]['reserved_ch'] = Number(n[l]['basechan']) + 15;
-						default:
-							SPANS[l]['definedchans'] = 0; // default values
-					}
+					SPANS[l]['reserved_ch'] = Number(n[l]['basechan']) + ( (Number(n[l]['totchans'])==24)? 23 : 15 );
+					SPANS[l]['definedchans'] = (Number(n[l]['totchans'])==24)? 23 : 30 ; // default values
 				}
 				if( k == 'lbo' ) {
 					switch(n[l][k]){
@@ -479,7 +439,7 @@
 			}}
 		}}
 		if(hwchanged != -1){ hwchanged = detectHwChanges(); }
-		ASTGUI.Log.Debug("end of function: loadConfigFiles.read_DahdiScanConf()");
+		ASTGUI.Log.Debug("end of function: loadConfigFiles.readZtscanConf()");
 		loadConfigFiles.readUsersConf(); // read span_x (where T1/E1 trunks are defined)
 	},
 
@@ -547,12 +507,8 @@
 					}
 					SPANS[tmp]['definedchans'] = 0;
 					for( var k in n[l] ){ if(n[l].hasOwnProperty(k)){
-						if( k == 'zapchan' || k == 'dahdichan' ){
-							SPANS[tmp]['dahdichan'] = n[l][k];
-						}else if( k == 'signalling' || k == 'switchtype' ){
-							SPANS[tmp][k] = n[l][k];
-						}
-						if( k=='zapchan' || k == 'dahdichan' ){ SPANS[tmp]['definedchans'] = efgh(n[l][k]); }
+						if( k == 'signalling' || k == 'zapchan' || k == 'switchtype' ){ SPANS[tmp][k] = n[l][k]; }
+						if( k=='zapchan'){ SPANS[tmp]['definedchans'] = efgh(n[l][k]); }
 					}}
 				}
 			}}
@@ -564,7 +520,7 @@
 	load_zaptel_conf: function(){
 		ASTGUI.Log.Debug("start function: loadConfigFiles.load_zaptel_conf()");
 		// we parse zaptel.conf to get the loadzone and syncsrc for each span
-		var tmp_file = ASTGUI.globals.dahdiIncludeFile ;
+		var tmp_file = ASTGUI.globals.zaptelIncludeFile;
 		var parseZaptelconf = function(zp){
 			(function (){
 				var t = (zp.hasOwnProperty('general')) ? zp['general'] : [] ; // t is an array
@@ -599,9 +555,16 @@
 		};
 
 		var s = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename=' + tmp_file , async: false }).responseText;
-
 		if( s.contains('Response: Error') && s.contains('Message: Config file not found') ){
-			top.window.location.reload(); // ASTGUI.globals.dahdiIncludeFile is created by onLogInFunctions.run_detectdahdi()
+			ASTGUI.miscFunctions.createConfig( tmp_file, function(){
+				var u = new listOfSynActions(tmp_file) ;
+				u.new_action('delcat', 'general', "", ""); 
+				u.new_action('newcat', 'general', "", ""); 
+				u.new_action('update', 'general', '#include "../zaptel.conf" ;', ' ;');
+				u.callActions();
+				var q = config2json({filename:tmp_file, usf:0});
+				parseZaptelconf(q);
+			});
 			return;
 		}else{
 			var q = config2json({ configFile_output:s , usf:0 });
@@ -613,15 +576,7 @@
 	}
 };
 
-var disablEnable_sc = function(){
-	_$('edit_DefinedChans').disabled = false;
-	if( Number(SPANS[CURRENT_SPAN]['totchans']) == 3 ){
-		_$('edit_DefinedChans').selectedIndex = 1 ;
-		_$('edit_DefinedChans').disabled = true;
-		_$('edit_labelReserved').innerHTML = Number(SPANS[CURRENT_SPAN]['basechan']) + 2 ;
-		return true;
-	}
-
+function disablEnable_sc() {
 	if( !_$('editspan_signalling').value.beginsWith('pri') ){
 		_$('editspan_switchtype').disabled =  true;
 		_$('editspan_switchtype').selectedIndex = -1;
@@ -637,10 +592,11 @@
 			if(_$('edit_DefinedChans').selectedIndex == 23 ){ _$('edit_DefinedChans').selectedIndex = 22 ; }
 		}
 	}
+
 	return true;
-};
-
-var updateSpanInfo = function(){
+}
+
+function updateSpanInfo(){
 	if( !verify_priChLimit() ){
 		alert("You should leave atleast one channel for signalling.");
 		return true;
@@ -659,6 +615,7 @@
 	}
 
 	var b = String(CURRENT_SPAN);
+
 	if( _$('editspan_fac').value == 'CCS/CRC4/HDB3' ){
 		SPANS[b]['framing'] = 'CCS/CRC4';
 		SPANS[b]['coding'] = 'HDB3';
@@ -675,7 +632,7 @@
 	_$('row'+ b).style.background = "#C9AAAA";
 
 	canelSpanInfo();
-};
+}
 
 
 
@@ -889,7 +846,7 @@
 			pri_trunk['group'] = NEWGROUPNUMBER ;
 
 			if( !EX_CF['globals'].hasOwnProperty(d) ){
-				y.new_action( 'update', 'globals', d, parent.sessionData.DahdiDeviceString + '/g' + String(NEWGROUPNUMBER) );
+				y.new_action('update', 'globals', d,'Zap/g'+String(NEWGROUPNUMBER));
 			}
 
 			if( !EX_CF.hasOwnProperty(e) ){
@@ -921,8 +878,8 @@
 				x.new_action('update', d , "context", e);
 				pri_trunk['context'] = e ;
 			}
-			x.new_action('update', d , parent.sessionData.DahdiChannelString , SPANS[k]['dahdichanstring']);
-				pri_trunk[ parent.sessionData.DahdiChannelString ] = SPANS[k]['dahdichanstring'] ;
+			x.new_action('update', d , "zapchan", SPANS[k]['zapchanstring']);
+				pri_trunk['zapchan'] = SPANS[k]['zapchanstring'] ;
 
 			parent.sessionData.pbxinfo['trunks']['pri'][d] = pri_trunk;
 		}}}
@@ -990,7 +947,7 @@
 				bchanstring += tmp2 + ppp;
 				dchanstring += tmp3 + SPANS[k]['reserved_ch'];
 			}
-			SPANS[k]['dahdichanstring'] = ppp;
+			SPANS[k]['zapchanstring'] = ppp;
 		}}}
 
 		for( var e in fxx ){ if(fxx.hasOwnProperty(e)){	x.new_action('append', context, e, fxx[e]);	}}
@@ -1064,13 +1021,13 @@
 };
 
 
-var applyDigitalSettings = function(){
+function applyDigitalSettings(){
  	// write to applyzap.conf - generate new applyzap.conf
  	// write to users.conf - update [spans_x] contexts
  	// call the asterisk_guiEditZap - which will generate zaptel.conf from applyzap.conf
 	ASTGUI.showbg(true);
 	applySettings.updateZaptel();
-};
+}
 
 
 var localajaxinit = function(){
@@ -1155,13 +1112,9 @@
 			return true;
 		}
 
-		if(SPANS[b]['totchans'] == 3){
-			SPANS[b]['definedchans'] = y = 2;
-		}else{
-			SPANS[b]['definedchans'] = y;
-			_$('edit_labelZapchan').innerHTML = calc_bchan_fxx(b);
-		}
+		SPANS[b]['definedchans'] = y;
 		//_$('edit_labelReserved').innerHTML = SPANS[b]['reserved_ch'];
+		_$('edit_labelZapchan').innerHTML = calc_bchan_fxx(b);
 	};
 
 	ASTGUI.events.add( _$('edit_DefinedChans'), "change", edit_DefinedChans_changed );
@@ -1226,4 +1179,4 @@
 		loadConfigFiles.load_hwcfgfile(); // try to load last detected/configured hardware information
 	});
 
-};
+}

Added: team/pari/dahdi_support/config/js/hardware_dahdi.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/pari/dahdi_support/config/js/hardware_dahdi.js?view=auto&rev=4437
==============================================================================
--- team/pari/dahdi_support/config/js/hardware_dahdi.js (added)
+++ team/pari/dahdi_support/config/js/hardware_dahdi.js Fri Jan 16 10:09:48 2009
@@ -1,0 +1,1229 @@
+/*
+ * Asterisk-GUI	- an Asterisk configuration interface
+ *
+ * hardware.html functions
+ *
+ * Copyright (C) 2006-2008, Digium, Inc.
+ *
+ * Pari Nannapaneni <pari at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ *
+ */
+var MODULE_NAME = 'wctdm24xxp';
+var DRIVERS_LIST = [ 'tor2','wcb4xxp', 'wcfxo', 'wct1xxp', 'wct4xxp', 'wctc4xxp', 'wctdm24xxp', 'wctdm', 'wcte11xp', 'wcte12xp', 'wcusb', 'xpp_usb' ];
+
+var SPANS = {};
+
+var oldSpanCount = 0; 	// we get this from previuos applyzap.conf
+var oldLoadZone;
+var GROUPS = [];
+var NEWGROUPNUMBER;
+var CURRENT_SPAN; 	// span being edited
+var CONFIGUREDHARDWARE = {}; // configuration read from an existing hwcfgfile (if exists)
+var DETECTEDHARDWARE = {};
+var hwcfgfile = ASTGUI.globals.hwcfgFile ;
+var spans_todelete = [];  // we delete all the span_x entries in users.conf (and their extensions.conf counter parts) before writing back any new information.
+var hwchanged = true ; // -1 for no previous configuration found (first time), true for detected hardware changes, false for no hardware changes
+var HAS_ANALOGHARDWARE = true; var HAS_DIGITALHARDWARE = true; 
+		// if the user does not have any hardware - always set parent.sessionData.REQUIRE_RESTART to false
+var SPANCOUNT_LOCATION = {}; // this object is used to store the number of spans found in each location Ex: SPANCOUNT_LOCATION['PCI Bus 02 Slot 04'] = 4;
+var portsSignalling = {};
+
+var digital_miscFunctions = {
+	show_analog_signalling_form: function(a){ //digital_miscFunctions.show_analog_signalling_form()
+		var b = [], ct = _$('edit_analog_signalling_options_container');
+		ct.FXSFXO = a ;
+		ASTGUI.domActions.removeAllChilds(ct);
+
+		if(a == 'FXO') b = parent.sessionData.FXO_PORTS_DETECTED;
+		if(a == 'FXS') b = parent.sessionData.FXS_PORTS_DETECTED;
+
+		var h_2_orig = document.createElement('select');
+		ASTGUI.selectbox.append( h_2_orig, 'Kewl Start', 'ks');
+		ASTGUI.selectbox.append( h_2_orig, 'Loop Start', 'ls');
+
+		b.each( function(this_port){
+			var h = document.createElement('div');
+			var h_1 = document.createElement('span');
+			var h_2 = h_2_orig.cloneNode(true);
+
+			h_1.innerHTML = 'Port ' + this_port + '&nbsp;:&nbsp;' ;
+			h_2.PORT = this_port;
+			h_2.className = 'EASOC_PORT';
+			h.appendChild(h_1);
+			h.appendChild(h_2);
+			if(  portsSignalling.ls.contains(this_port)  ){
+				ASTGUI.selectbox.selectOption(h_2, 'ls');
+			}else{
+				ASTGUI.selectbox.selectOption(h_2, 'ks');
+			}
+			ct.appendChild(h);
+		} );
+
+		//console.log( portsSignalling.ls );
+		//console.log( parent.sessionData.PORTS_SIGNALLING.ks );
+
+		$('#edit_analog_signalling').showWithBg();
+	},
+
+	save_analog_signalling_prefs: function(){ // digital_miscFunctions.save_analog_signalling_prefs()
+		var t = $('.EASOC_PORT') ;
+		for(var i=0; i < t.length; i ++){
+			//alert( t[i].PORT + ' : ' + t[i].value ) ;
+			if(t[i].value == 'ls'){
+				portsSignalling.ls.push_IfNotPresent( t[i].PORT );
+				portsSignalling.ks = portsSignalling.ks.withOut( t[i].PORT ) ;
+			}
+			if(t[i].value == 'ks'){
+				portsSignalling.ks.push_IfNotPresent( t[i].PORT );
+				portsSignalling.ls = portsSignalling.ls.withOut( t[i].PORT ) ;
+			}
+		}
+		var ct = _$('edit_analog_signalling_options_container');
+		var ct_r = _$( 'FXSFXO_ports_td__' + ct.FXSFXO );
+		ct_r.style.background = "#C9AAAA";
+		$('#edit_analog_signalling').hideWithBg();
+	}
+};
+
+
+var detectHwChanges = function(){ // compare DETECTEDHARDWARE vs CONFIGUREDHARDWARE 
+// returns true if a hardware change is detected and false if there are no hardware changes
+// we can actually check a lot of things here like
+	// [A] check if - any cards are missing 
+	//	if yes - delete all existing configuration and ask the user to reconfigure from scratch
+
+	// [B] check if - any cards are added  - if something is added 
+	//	- check if the basechan of configured hardware matches with basechan of detected hardware
+	//	- if (matches) { 
+	//		no need to delete existing configuration - just present the current card information as detected/configured and new card as unconfigured 
+	//	}else{ 
+	//		delete all existing configuration and ask the user to reconfigure from scratch 
+	//	}
+
+	// [C] if all the cards match - check if basechan of detected hardware matches with basechan of configured hardware
+	//	- if does not match - delete all existing configuration and ask the user to reconfigure from scratch
+// BUT to avoid all the complexity and to keep things simple (atleast for now) - we will just do [c]
+	// check if the devices match 
+	// check if the basechan match for all the devices
+
+	var configured_devices = [];
+	var detected_devices = [];
+	for( var l in CONFIGUREDHARDWARE ){ if(CONFIGUREDHARDWARE.hasOwnProperty(l)){ 
+		configured_devices.push( CONFIGUREDHARDWARE[l]['device'] + '::' + CONFIGUREDHARDWARE[l]['basechan'] + '::' + CONFIGUREDHARDWARE[l]['type'] ); 
+		// this way we can check for whether 'device' and 'basechan' and 'type' all matched in one go
+	}}
+	for( var l in DETECTEDHARDWARE ){ if(DETECTEDHARDWARE.hasOwnProperty(l)){ 
+		detected_devices.push( DETECTEDHARDWARE[l]['device'] + '::' + DETECTEDHARDWARE[l]['basechan'] + '::' + DETECTEDHARDWARE[l]['type']  ); 
+	}}
+	configured_devices.sort(); detected_devices.sort();
+	if( !configured_devices.length && !detected_devices.length){ return false; }
+	if(configured_devices.length == detected_devices.length){
+		for(var l=0; l < configured_devices.length; l++){
+			if(configured_devices[l] != detected_devices[l]){ // devices does not match - but the number of devices match
+				ASTGUI.Log.Debug("DEVICES or basechans does not MATCHED");
+				return true;
+			}
+		}
+		ASTGUI.Log.Debug("DEVICES and basechans MATCH");
+		return false;
+	}else{	
+		ASTGUI.Log.Debug("DEVICES or basechans does not MATCHED");
+		return true;
+	}
+};
+
+
+
+
+
+var verify_priChLimit = function(){
+	var l = String(CURRENT_SPAN);
+	if( !_$('editspan_signalling').value.beginsWith('pri')){ return true;}
+	var y = Number(_$('edit_DefinedChans').value);
+	if( Number(SPANS[l]['totchans'] ) ==3 ){return true;}
+	if( Number(SPANS[l]['totchans'] ) <= 24 && y ==24){return false;}//alert("You should leave atleast 1 channel for PRI signalling");
+	if( Number(SPANS[l]['totchans'] ) > 24 && y ==31){return false;}//alert("You should leave atleast 1 channel for PRI signalling");
+	return true;
+};
+
+var calc_bchan_fxx = function(l){ // calculates the bchan,and fxx strings for a given span
+	var y = Number(SPANS[l]['min_ch']);
+	if( SPANS[l]['totchans'] == 3 ){
+		return y + "-" + String(y+1);
+	}
+	var z = Number(SPANS[l]['definedchans']);
+	if(z==1){return String(y);}
+
+	if( SPANS[l]['signalling'] && !SPANS[l]['signalling'].beginsWith('pri') ){ // if is an fxo/fxs or e&m
+		return y + "-" + String(y+z);
+	}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);
+			}
+		}
+	}
+}
+
+
+var canelSpanInfo = function(){
+	_$('edit_span').style.display = "none";
+	ASTGUI.showbg(false);
+	CURRENT_SPAN = null;
+}
+
+var editSPAN = function(l){ // show values for SPAN l in the edit_span dialog box
+	CURRENT_SPAN = l;
+	_$('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;
+		if(f == 31){ f = 30; } // always make sure that only a max of 30 ports are available on E1 
+		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']) == 3 ){
+		ASTGUI.selectbox.append(_$('editspan_fac'),'CCS/AMI', 'CCS/AMI');
+		//_$('editspan_signalling')
+		ASTGUI.selectbox.clear(_$('editspan_signalling'));
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'bri_cpe', 'bri_cpe');
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'bri_net', 'bri_net');
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'bri_cpe_ptmp', 'bri_cpe_ptmp');
+	}else{
+		ASTGUI.selectbox.clear(_$('editspan_signalling'));
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'PRI - Net', 'pri_net');
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'PRI - CPE', 'pri_cpe');
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'E & M', 'em');
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'E & M -- Wink', 'em_w');
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'E & M -- featd(DTMF)', 'featd');
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'FXOKS', 'fxo_ks');
+		ASTGUI.selectbox.append(_$('editspan_signalling'),'FXOLS', 'fxo_ls');
+	}
+
+	if ( Number(SPANS[l]['totchans']) == 24 ){
+		ASTGUI.selectbox.append(_$('editspan_fac'),'ESF/B8ZS', 'ESF/B8ZS');
+		ASTGUI.selectbox.append(_$('editspan_fac'),'D4/AMI', 'D4/AMI');
+	}
+
+	if ( Number(SPANS[l]['totchans']) == 31 ){
+		ASTGUI.selectbox.append(_$('editspan_fac'),'CCS/HDB3', 'CCS/HDB3');
+		ASTGUI.selectbox.append(_$('editspan_fac'),'CCS/CRC4/HDB3', 'CCS/CRC4/HDB3');
+	}
+
+	if(SPANS[l]['framing'] && SPANS[l]['coding']) {
+		if( SPANS[l]['framing'] == 'CCS/CRC4' ){
+			ASTGUI.selectbox.selectOption( _$('editspan_fac') , 'CCS/CRC4/HDB3' );
+		}else{
+			ASTGUI.selectbox.selectOption( _$('editspan_fac') , SPANS[l]['framing'] + '/' + SPANS[l]['coding'] );
+		}
+	}
+
+	_$('editspan_channels').innerHTML = String(SPANS[l]['definedchans']) + "/" + String(SPANS[l]['totchans']) + " ("+SPANS[l]['spantype']+")";
+
+
+	if( SPANS[l]['signalling'] ){
+		ASTGUI.selectbox.selectOption( _$('editspan_signalling') , SPANS[l]['signalling'] );
+	}else{
+		_$('editspan_signalling').selectedIndex = -1 ; 
+	}
+	disablEnable_sc();
+
+	if(SPANS[l]['switchtype']){
+		ASTGUI.selectbox.selectOption( _$('editspan_switchtype') , SPANS[l]['switchtype'] );
+	}else{
+		_$('editspan_switchtype').selectedIndex = -1 ;
+	}
+
+	(function (){
+		ASTGUI.selectbox.clear( _$('editspan_syncsrc'));
+		var y = SPANCOUNT_LOCATION[ SPANS[l]['location'] ];
+		var u =0; 
+		while(u<=y){ ASTGUI.selectbox.append( _$('editspan_syncsrc'),u,u ); u++ }
+		if( !SPANS[l].hasOwnProperty('syncsrc') ){ SPANS[l]['syncsrc'] = '1' } // default
+		ASTGUI.selectbox.selectOption( _$('editspan_syncsrc') , SPANS[l]['syncsrc'] );
+	})();
+
+	ASTGUI.selectbox.selectOption( _$('editspan_lbo') , SPANS[l]['lbo'] );
+	_$('edit_span').style.display = "";
+	ASTGUI.showbg(true);
+};
+
+
+var showtable = function(){ // navigates through the SPANS object and presents as a table to the user
+	var keepalert = false ;
+	try{
+		var tbl = _$('digitalcardstable') ;
+		var add_fRow = function(){
+			var newRow = tbl.insertRow(-1);
+			newRow.className = "frow";
+			ASTGUI.domActions.tr_addCell( newRow, {html: 'SPAN' } );
+			ASTGUI.domActions.tr_addCell( newRow, {html: 'ALARMS' } );
+			ASTGUI.domActions.tr_addCell( newRow, {html: 'Framing/Coding' } );
+			ASTGUI.domActions.tr_addCell( newRow, {html: 'channels Used/Total', align : 'center' } );
+			ASTGUI.domActions.tr_addCell( newRow, {html: 'Signalling', align : 'center'} );
+			ASTGUI.domActions.tr_addCell( newRow, {html: '' } );
+		};
+		var addrow_totable = function(span){
+			if( LAST_LOCATION != SPANS[span]['location'] ){
+				var newRow = tbl.insertRow(-1);
+				var tmp = '<B>' + SPANS[span]['location'] + ' --> ' + SPANS[span]['devicetype'] + '</B>' ;
+				ASTGUI.domActions.tr_addCell( newRow, {html: tmp , colspan :6, bgcolor : '#B0B9D0' , align : 'center' } );
+			}
+
+			var singalling_defs = {pri_net: 'PRI - Net', pri_cpe: 'PRI - CPE', em: 'E & M',em_w: 'E & M -- Wink', featd:'E & M -- featd(DTMF)', fxo_ks:'FXOKS', fxo_ls:'FXOLS'  };
+
+			var sno = tbl.rows.length + 1;
+			var newRow = tbl.insertRow(-1);
+			newRow.className = ((tbl.rows.length)%2==1)?"odd":"even";
+			newRow.id ="row" + span ;
+			newRow["span_value"] = span;
+			(function(){
+				var u = SPANS[span]['name'].split('/'); // Ex: name=TE4/2/1 where 2 is card number and 1 is the span number on that card
+				var w = SPANS[span]['devicetype'] ; // Ex: 'Wildcard TE410P/TE405P (1st Gen)'
+				var v = w + ', Card ' + String(Number(u[1]) + 1) + ' - Port ' + u[2] + "&nbsp;(span_" + span + ")&nbsp;&nbsp;" ;
+				ASTGUI.domActions.tr_addCell( newRow, { html: v } );// Ex: 'Wildcard TE410P/TE405P (1st Gen), Card 3 - Port 1, (span_3)'
+			})();
+			ASTGUI.domActions.tr_addCell( newRow, { html: SPANS[span]['alarms'] , align:'center' } );
+			ASTGUI.domActions.tr_addCell( newRow, { html: (SPANS[span]['framing'] && SPANS[span]['coding']) ? SPANS[span]['framing'] + '/' + SPANS[span]['coding'] : '' } );
+			ASTGUI.domActions.tr_addCell( newRow, { html: String(SPANS[span]['definedchans']) + '/' + String(SPANS[span]['totchans']) , align:'center' } );
+			ASTGUI.domActions.tr_addCell( newRow, { html: (SPANS[span]['signalling'])? singalling_defs[ SPANS[span]['signalling'] ] : "<font color=red>NOT DEFINED</font>" , align:'center' } );
+			ASTGUI.domActions.tr_addCell( newRow, { html: "<span class=\"guiButton\" id='" + "span_" + span + "'  onclick=\"editSPAN( '"+ span + "');\">Edit</span>" , align:'center', width: 90} );
+			LAST_LOCATION = SPANS[span]['location'] ;
+		};
+
+		$('#digital_settings').show();
+		ASTGUI.domActions.clear_table(tbl);
+		add_fRow();
+		var foo_spans =0;
+		var LAST_LOCATION = '';
+		for( var k in SPANS ){ if( SPANS.hasOwnProperty(k) ){ foo_spans++; addrow_totable(k); }}
+		if(!foo_spans){
+			ASTGUI.domActions.clear_table(tbl);
+			var newRow = tbl.insertRow(-1);
+			newRow.className = "even";
+	
+			var newCell0 = newRow.insertCell(0);
+			newCell0.innerHTML = "No Digital Hardware detected !!";
+			HAS_DIGITALHARDWARE = false;
+		}
+
+		if(foo_spans && hwchanged == -1){ // no previous hardware information found - configuring for the first time
+			ASTGUI.dialog.alertmsg('Please configure your hardware using the Edit button(s)' + '<BR>'+
+				"When done click on the 'Update Settings'" );
+			keepalert = true;
+		}else{ // if previous config file found 
+			if(foo_spans && hwchanged){ //
+				ASTGUI.dialog.alertmsg('Hardware Changes detected !! <BR><BR>' +
+					'When you "Update Settings" all your previous settings will be over written' );
+				keepalert = true;
+			}else{ // no hardware changes detected
+				//gui_alert('No Hardware Changes detected !! ');
+				keepalert = false;
+			}
+		}
+	}catch(err){
+
+	}finally{
+		loadConfigFiles.load_zaptel_conf(); // used only for retreiving loadzone
+		if( !keepalert ){
+			parent.ASTGUI.dialog.hide();
+		}
+	}
+};
+
+
+var loadConfigFiles = {
+	// read hwcfgfile (if exists) into CONFIGUREDHARDWARE - so that the GUI knows the last configured hardware
+	// run ztscan - to detect digital cards
+	// read ztscan.conf - store hardware information in DETECTEDHARDWARE, read spans information - also set the max , min values for each span
+	//   see if the hardware matches with that from CONFIGUREDHARDWARE 
+	//   (this way we know if any changes in digital hardware since the gui was last used)
+	// 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
+	load_hwcfgfile: function(){ // read hwcfgfile (if exists) into CONFIGUREDHARDWARE 
+		ASTGUI.Log.Debug("load last configured hardware information, start function: loadConfigFiles.load_hwcfgfile()");
+		var n = config2json({filename:hwcfgfile, usf:1});
+		if( n.getOwnProperties().length == 0 ){ // if file not found or no previous hardware detected
+				hwchanged = -1;
+				loadConfigFiles.run_detectdahdi();
+				return;
+		}else{
+			CONFIGUREDHARDWARE = {};
+			for( var l in n ){ if(n.hasOwnProperty(l) && l!='ANALOGPORTS' ){ // l is location
+				CONFIGUREDHARDWARE[l] = {};
+				CONFIGUREDHARDWARE[l]['device'] = n[l]['device'];
+				CONFIGUREDHARDWARE[l]['basechan'] = n[l]['basechan'];
+				CONFIGUREDHARDWARE[l]['type'] = n[l]['type'];
+			}}
+			loadConfigFiles.run_detectdahdi();
+		}
+		ASTGUI.Log.Debug("end of function: loadConfigFiles.load_hwcfgfile()");
+	},
+
+	run_detectdahdi: function(){
+		ASTGUI.Log.Debug("start function: loadConfigFiles.run_detectdahdi()");
+
+		ASTGUI.miscFunctions.createConfig( 'applyzap.conf', function(){
+			parent.ASTGUI.systemCmd( top.sessionData.directories.app_DahdiScan , function(){ // run ztscan and then try loading ztscan.conf
+				window.setTimeout( loadConfigFiles.read_DahdiScanConf , 700 ); // leave some time for ztscan to generate ztscan.conf
+			});
+			ASTGUI.Log.Debug("end of function: loadConfigFiles.run_detectdahdi()");
+		});
+	},
+
+	//readZtscanConf: function(){
+	read_DahdiScanConf: function(){
+		ASTGUI.Log.Debug("start function: loadConfigFiles.read_DahdiScanConf()");
+		var ztsc = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename=' + ASTGUI.globals.dahdiScanOutput , async: false }).responseText;
+		var ztsc_Lower = ztsc.toLowerCase();
+		if( ztsc_Lower.contains('response: error') && ztsc_Lower.contains('message: config file not found') ){
+			parent.ASTGUI.dialog.waitWhile("Please check if <B>ztscan</B> is installed ? <BR> /etc/asterisk/dahdi_scan.conf not found");
+			ASTGUI.feedback( { msg:"No Cards/Spans found,  No Config File found !!", showfor:2 });
+			return;
+		}
+		var n = config2json({ configFile_output: ztsc, usf : 1 });
+
+		for( var l in n ){ if(n.hasOwnProperty(l)){
+			if(n[l]['type'] == 'analog'){
+				DETECTEDHARDWARE[ n[l]['location'] ] = {};
+				DETECTEDHARDWARE[ n[l]['location'] ]['device'] = n[l]['devicetype'];
+				DETECTEDHARDWARE[ n[l]['location'] ]['basechan'] = n[l]['basechan'];
+				DETECTEDHARDWARE[ n[l]['location'] ]['type'] = n[l]['type'] ;
+				continue;
+			} // in this page, we care only about digital spans 
+			//  note: function detectHwChanges checks if there are any changes in analog ports detected
+			if(  n[l]['description'].toLowerCase().contains('ztdummy') ){ continue;} // ignore ztdummy :-)
+			SPANS[l] = {};
+			for( var k in n[l] ){ if(n[l].hasOwnProperty(k)){ 
+				SPANS[l][k] = n[l][k]; // store all the other fields in spans[l]
+				if( k == 'location'){
+					if(!(SPANCOUNT_LOCATION[n[l]['location']]) ){ SPANCOUNT_LOCATION[n[l]['location']] = 0; }
+					SPANCOUNT_LOCATION[n[l]['location']] = SPANCOUNT_LOCATION[n[l]['location']] + 1;
+				}
+				if( k=='location' && !(DETECTEDHARDWARE[n[l]['location']]) ){
+					DETECTEDHARDWARE[ n[l]['location'] ] = {};
+					DETECTEDHARDWARE[ n[l]['location'] ]['device'] = n[l]['devicetype'];
+					DETECTEDHARDWARE[ n[l]['location'] ]['basechan'] = n[l]['basechan'];
+					DETECTEDHARDWARE[ n[l]['location'] ]['type'] = n[l]['type'];
+				}
+				if( k == 'totchans' ){
+					SPANS[l]['spantype'] = n[l]['type'].split('-')[1]; // part after '-' in 'digital-T1' or 'digital-E1' or 'digital-NT' or 'digital-TE'
+					SPANS[l]['min_ch'] = Number(n[l]['basechan']) ;
+					SPANS[l]['max_ch'] =  Number(n[l]['basechan']) + Number(n[l]['totchans']) - 1 ; 
+
+					var n_tc = Number(n[l]['totchans']) ;
+					switch(n_tc){
+						case 3:
+							SPANS[l]['definedchans'] = 2;
+							SPANS[l]['reserved_ch'] = Number(n[l]['basechan']) + 2 ;
+						case 24:
+							SPANS[l]['definedchans'] = 23;
+							SPANS[l]['reserved_ch'] = Number(n[l]['basechan']) + 23;
+						case 31:
+							SPANS[l]['definedchans'] = 30;
+							SPANS[l]['reserved_ch'] = Number(n[l]['basechan']) + 15;
+						default:
+							SPANS[l]['definedchans'] = 0; // default values
+					}
+				}
+				if( k == 'lbo' ) {
+					switch(n[l][k]){
+						case '0 db (CSU)/0-133 feet (DSX-1)':
+							SPANS[l]['lbo'] = 0; break; 
+						case '133-266 feet (DSX-1)':
+							SPANS[l]['lbo'] = 1; break; 
+						case '266-399 feet (DSX-1)':
+							SPANS[l]['lbo'] = 2; break;
+						case '399-533 feet (DSX-1)':
+							SPANS[l]['lbo'] = 3; break;
+						case '533-655 feet (DSX-1)':
+							SPANS[l]['lbo'] = 4; break;
+						case '-7.5db (CSU)':
+							SPANS[l]['lbo'] = 5; break;
+						case '-15db (CSU)':
+							SPANS[l]['lbo'] = 6; break;
+						case '-22.5db (CSU)':
+							SPANS[l]['lbo'] = 7; break;
+						default:
+							SPANS[l]['lbo'] = 0; break; 
+					}
+				}
+			}}
+		}}
+		if(hwchanged != -1){ hwchanged = detectHwChanges(); }
+		ASTGUI.Log.Debug("end of function: loadConfigFiles.read_DahdiScanConf()");
+		loadConfigFiles.readUsersConf(); // read span_x (where T1/E1 trunks are defined)
+	},
+
+	readUsersConf: function(){
+		ASTGUI.Log.Debug("start function: loadConfigFiles.readUsersConf()");
+
+		var usrs = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename=users.conf', async: false }).responseText;
+		var usrs_Lower = usrs.toLowerCase();
+		if( usrs_Lower.contains('response: error') && usrs_Lower.contains('message: config file not found') ){
+			ASTGUI.feedback( { msg:"No Users File found !!", showfor:2 });
+			parent.ASTGUI.dialog.waitWhile("/etc/asterisk/users.conf not found");
+			return;
+		}
+		var n = config2json({ configFile_output: usrs, usf : 1 });// read users.conf and load switchtype, signalling, zapchan into the SPANS object
+
+		(function(){
+			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 tmp;
+			var tmp_spantodelete = {};
+			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_spantodelete = {};
+					tmp_spantodelete['spanName'] = l;
+					if( n[l]['context'] ){ tmp_spantodelete['spanContext'] = n[l]['context']; }
+
+					spans_todelete.push(tmp_spantodelete);
+
+					tmp = l.split('span_')[1];

[... 687 lines stripped ...]



More information about the asterisk-gui-commits mailing list