pari: trunk r871 - /trunk/config/trunks.html

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Fri May 4 15:10:19 MST 2007


Author: pari
Date: Fri May  4 17:10:19 2007
New Revision: 871

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=871
Log:
make sure that analog lines are used in only once

Modified:
    trunk/config/trunks.html

Modified: trunk/config/trunks.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/trunks.html?view=diff&rev=871&r1=870&r2=871
==============================================================================
--- trunk/config/trunks.html (original)
+++ trunk/config/trunks.html Fri May  4 17:10:19 2007
@@ -40,7 +40,9 @@
 var isnewtrunk;
 var dids_array = [];
 var old_trunkname;
-
+var used_fxos = {};
+used_fxos.oldvalue = "";
+used_fxos.newvalue = "";
 
 function add_didcontext(trunk){
 	var didcontext = asterisk_guiTDPrefix + trunk ;
@@ -126,7 +128,14 @@
 }
 
 callbacks.format = function(t) {
-	if( InArray(dids_array, t.name) ){ return t.fieldbyname['trunkname']; }
+	if( InArray(dids_array, t.name) ){ 
+		// 
+		if(t.fieldbyname['zapchan']){ 
+			var s = t.fieldbyname['zapchan'].split(",");
+			for(var u=0; u < s.length; u++){ used_fxos[s[u]] = true ; }
+		} 
+		return t.fieldbyname['trunkname']; 
+	}
 	return null;
 }
 
@@ -234,6 +243,8 @@
 	}else{
 
 		if( _$('trunkstyleanalog').checked ){
+
+			used_fxos.oldvalue = _$('devices').stored_config.catbyname[_dvcs_v].fieldbyname['zapchan'] ;
 			_$('context').value =  asterisk_guiTDPrefix + _$('name').value  ;
 			var needcomma = 0 ;
 			var count = 0 ;
@@ -246,6 +257,7 @@
 					count++ ;
 				}
 			}
+			used_fxos.newvalue = _$('trunkname').value;
 			_$('trunkname').value = ((count > 1) ? "Ports ":"Port ") + _$('trunkname').value ;
 		}
 
@@ -257,6 +269,7 @@
 }
 
 callbacks.savechanges = function() {
+	update_used_fxos();
 	if(isnewtrunk == 1){ //New Trunk created , add [DID_trunk_x] in extensions.conf
 		add_didcontext(_$('name').value);
 		if (_$('trunkstylevoip').checked) {
@@ -271,9 +284,19 @@
 		callbacks_savechanges_step2();
 	}else{
 		if(old_trunkname != _$('name').value ){ update_didcontext(old_trunkname, _$('name').value); } // rename DID if needed
+		hideSPdetails();
+		loadServiceProvidersintotable();
 	}
 
 	return true;
+}
+
+function update_used_fxos(){
+	var r; 
+	var ovs = used_fxos.oldvalue.split(",");
+	var nvs = used_fxos.newvalue.split(",");
+	for(r=0; r < ovs.length; r++){ delete used_fxos[ovs[r]]; }
+	for(r=0; r < nvs.length; r++){ used_fxos[nvs[r]] = true; }
 }
 
 
@@ -349,6 +372,7 @@
 		_provider.selectedIndex  = -1;
 		count = 0;
 		_trunkname.value = "";
+		used_fxos.oldvalue = "";
 		for (var x=0;x<_zapchan.options.length;x++) {
 			if (_zapchan.options[x].selected) {
 				if (needcomma){ _trunkname.value += "," }
@@ -357,6 +381,7 @@
 				count++;
 			}
 		}
+		used_fxos.newvalue = _trunkname.value; 
 		_trunkname.value = ((count > 1) ? "Ports ":"Port ") + _trunkname.value;
 		_$('callerid').value = 'asreceived';
 		_$('hassip').value = 'no';
@@ -463,6 +488,7 @@
 	_zcal.innerHTML ="";
 	_$('customvoip').style.display = "none" ;
 	_$('voip').style.display= "none";
+	var disablestring;
 
 	if (_$('trunkstyleanalog').checked) {
 		_$('analog').style.display = "block";
@@ -472,10 +498,17 @@
 		}else{
 			for (k=0;k< _zapchan.length ;k++ ){
 				var selectedline = "selectedline" + k;
+				
+				if( used_fxos[_zapchan.options[k].value] && !_zapchan.options[k].selected){
+					disablestring = " disabled";
+				}else{
+					disablestring = "";
+				}
+
 				if(_zapchan.options[k].selected){
-					_zcal.innerHTML += '<LABEL FOR="' + selectedline + '"><INPUT id="' + selectedline + '" TYPE="CHECKBOX" VALUE="'+ _zapchan.options[k].value+ '" checked onclick="update_zapchan()">' + _zapchan.options[k].text + '</LABEL><BR>';
+					_zcal.innerHTML += '<LABEL FOR="' + selectedline + '"><INPUT id="' + selectedline + '" TYPE="CHECKBOX" VALUE="'+ _zapchan.options[k].value+ '" checked onclick="update_zapchan()"' + disablestring +'>' + _zapchan.options[k].text + '</LABEL><BR>';
 				}else{
-					_zcal.innerHTML += '<LABEL FOR="'+ selectedline+'"><INPUT id="' + selectedline + '" TYPE="CHECKBOX" VALUE="'+ _zapchan.options[k].value+ '" onclick="update_zapchan()">' + _zapchan.options[k].text + '</LABEL><BR>';
+					_zcal.innerHTML += '<LABEL FOR="'+ selectedline+'"><INPUT id="' + selectedline + '" TYPE="CHECKBOX" VALUE="'+ _zapchan.options[k].value+ '" onclick="update_zapchan()"' + disablestring +'>' + _zapchan.options[k].text + '</LABEL><BR>';
 				}
 			}
 		}



More information about the asterisk-gui-commits mailing list