pari: trunk r992 - /trunk/config/

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Tue May 29 14:29:44 MST 2007


Author: pari
Date: Tue May 29 16:29:43 2007
New Revision: 992

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=992
Log:
replacing   'try/catch','if(ie)'  crap with the new SelectBox functions

Modified:
    trunk/config/feditor.html
    trunk/config/iax.html
    trunk/config/incoming.html
    trunk/config/localexts.html
    trunk/config/ringgroups.html
    trunk/config/timerules.html
    trunk/config/users.html

Modified: trunk/config/feditor.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/feditor.html?view=diff&rev=992&r1=991&r2=992
==============================================================================
--- trunk/config/feditor.html (original)
+++ trunk/config/feditor.html Tue May 29 16:29:43 2007
@@ -56,14 +56,7 @@
 	parent.astmanEngine.run_tool( "touch " + asterisk_configfolder + fn, callback = function() {
 		cancel_file();
 		gui_feedback("Created file: '" + fn + "'",'blue');
-		New_OPTION = document.createElement('option');
-		New_OPTION.text =  fn ;
-		New_OPTION.value = fn ;
-		try {
-			_$('filenames').add(New_OPTION, null); // W3C way
-		}catch(ex) {
-			_$('filenames').add(New_OPTION); // IE way
-		}
+		ASTGUI.selectbox_push(_$('filenames'),fn, fn);
 		_$('filenames').selectedIndex = _$('filenames').options.length -1 ;
 		loadfile();
 	});
@@ -126,17 +119,8 @@
 		onComplete: function(originalRequest){
 			// Add config files to the list of files
 			var recfiles = originalRequest.responseText.split("\n") ;
-
-			New_OPTION = document.createElement('option');
-			New_OPTION.text = "Config Files"  ;
-			New_OPTION.value = ""  ;
-			New_OPTION.style.fontWeight = "bold";
-			try {
-				_$('filenames').add(New_OPTION, null); // W3C way
-			}catch(ex) {
-				_$('filenames').add(New_OPTION); // IE way
-			}
-
+			ASTGUI.selectbox_push(_$('filenames'),"Config Files", "");
+			_$('filenames').options[0].style.fontWeight = "bold";
 			var file_name;
 			for( var i =0 ; i < recfiles.length ; i++){
 				if( typeof recfiles[i] == "undefined"  || recfiles[i] == "" ){
@@ -146,14 +130,7 @@
 				if( recfiles[i] == "" ){ continue; }
 				if( recfiles[i].substr( (recfiles[i].length - 5), recfiles[i].length) != ".conf") { continue; }
 				file_name = recfiles[i].stripTags() ;
-				New_OPTION = document.createElement('option');
-				New_OPTION.text =  file_name  ;
-				New_OPTION.value = file_name ;
-				try {
-					_$('filenames').add(New_OPTION, null); // W3C way
-				}catch(ex) {
-					_$('filenames').add(New_OPTION); // IE way
-				}
+				ASTGUI.selectbox_push(_$('filenames'),file_name, file_name);
 			}
 		},
 		onFailure: function(t) { alert("Config Error: " + t.status + ": " + t.statusText); }

Modified: trunk/config/iax.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/iax.html?view=diff&rev=992&r1=991&r2=992
==============================================================================
--- trunk/config/iax.html (original)
+++ trunk/config/iax.html Tue May 29 16:29:43 2007
@@ -83,15 +83,7 @@
 	}
 
 	function addtosel(a,b,c){ // a is text, b is value, c is the select box id
-	  var newoption = document.createElement('option');
-	  newoption.text = a ;
-	  newoption.value = b ;
-	  var selectbox = document.getElementById( c );
-	  try {
-		selectbox.add(newoption, null); // standards compliant; doesn't work in IE
-	  }catch(ex) {
-		selectbox.add(newoption); // IE only
-	  }
+          ASTGUI.selectbox_push(_$(c),a, b);
 	}
 }
 function 	selectbox_remove(selectbox_id,codec){

Modified: trunk/config/incoming.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/incoming.html?view=diff&rev=992&r1=991&r2=992
==============================================================================
--- trunk/config/incoming.html (original)
+++ trunk/config/incoming.html Tue May 29 16:29:43 2007
@@ -32,14 +32,7 @@
 var editstatus , edit_pattern, edit_DIDtrunk, edit_action, edit_priority ;
 
 function add_toext(a,b){ // a is value, b is text
-	var New_OPTION = document.createElement('option');
-	New_OPTION.text = b ;
-	New_OPTION.value = a ;
-	try {
-		_$('toextension').add(New_OPTION, null); // W3C way
-	}catch(ex) {
-		_$('toextension').add(New_OPTION); // IE way
-	}
+	ASTGUI.selectbox_push(_$('toextension'),b,a);
 }
 
 user_callbacks.format = function(t, x) {
@@ -113,20 +106,9 @@
 numplan_callbacks.loaded = function() {
 	// load list of trunks to 'fromprovider'
 	var t ;
-	for ( t in didtrunks){
-	if(  didtrunks.hasOwnProperty(t) ){
-		  var a = document.createElement('option');
-		  a.text = didtrunks[t].trunkname ;
-		  a.value = t ;
-		  var b = document.getElementById('fromprovider');
-		  try {
-			b.add(a, null); 
-		  }
-		  catch(ex) {
-			b.add(a); 
-		  }
-	  }
-	}
+	for (t in didtrunks){	if(  didtrunks.hasOwnProperty(t) ){
+		ASTGUI.selectbox_push(_$('fromprovider'),didtrunks[t].trunkname, t);
+	}}
 	// load the object didtrunks into the table callingRulesTable
 	refreshtable();
 	parent.loadscreen(this);

Modified: trunk/config/localexts.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/localexts.html?view=diff&rev=992&r1=991&r2=992
==============================================================================
--- trunk/config/localexts.html (original)
+++ trunk/config/localexts.html Tue May 29 16:29:43 2007
@@ -35,11 +35,8 @@
 	if(t.name == "general" ){ return t.name; }
 
 	if( !t.fieldbyname['trunkstyle'] ){ // all entries from users.conf other than trunks
-		var ie = (document.attachEvent)? 1:0;
-		h = document.createElement('option');
-		h.text = (t.fieldbyname['fullname'])? unescape(t.fieldbyname['fullname'])+" ("+t.name+")" : "Local Extension ("+t.name+")";
-		h.value = t.name;
-		if(ie){ _$('operatorExtension').add(h);} else{ _$('operatorExtension').add(h,null);}
+		var ht = (t.fieldbyname['fullname'])? unescape(t.fieldbyname['fullname'])+" ("+t.name+")" : "Local Extension ("+t.name+")";
+		ASTGUI.selectbox_push(_$('operatorExtension'),ht, t.name);
 	}
 
 	return null;

Modified: trunk/config/ringgroups.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/ringgroups.html?view=diff&rev=992&r1=991&r2=992
==============================================================================
--- trunk/config/ringgroups.html (original)
+++ trunk/config/ringgroups.html Tue May 29 16:29:43 2007
@@ -27,8 +27,6 @@
 var UserExtensions = [];
 var LISTOFCHANNELS = {};
 var ringgroups = {};
-var opt_temp = document.createElement('option');
-if(document.attachEvent){ ie=1;}else{ie=0;}
 var RG_COMMENT = 'gui_ring_groupname';
 var RG_FORMAT = 'ringroups-custom-';
 var RG_EDITING;
@@ -90,26 +88,16 @@
 	if( this_ringgroup.ringstyle == 'ringinorder' ){ _$('select_strategy').selectedIndex = 1 ; }
 
 	var r = _$('select_ringthesechannels');
-	while (r.options.length)
-		r.remove(0);
-
 	var s = _$('select_listofchannels');
-	while (s.options.length)
-		s.remove(0);
-
+	ASTGUI.selectbox_clear(s);
+	ASTGUI.selectbox_clear(r);
 	for (var y=0; y < this_ringgroup.rgchannels.length ; y++ ){
-		h = opt_temp.cloneNode(true);
-		h.text = this_ringgroup.rgchannels[y] ;
-		h.value = this_ringgroup.rgchannels[y] ;
-		if(ie){r.add(h);} else{ r.add(h,null);}
+		ASTGUI.selectbox_push(r,this_ringgroup.rgchannels[y], this_ringgroup.rgchannels[y]);
 	}
 
 	for( var u in LISTOFCHANNELS ){ if(LISTOFCHANNELS.hasOwnProperty(u)) {
 		if( !InArray(this_ringgroup.rgchannels, u) ){
-			h = opt_temp.cloneNode(true);
-			h.text = u ;
-			h.value = u ;
-			if(ie){s.add(h);} else{ s.add(h,null);}
+			ASTGUI.selectbox_push(s,u,u);
 		}
 	}}
 
@@ -258,12 +246,8 @@
 
 
 function a2b(a,b){
-	var h; 
-	h = opt_temp.cloneNode(true);
 	if(a.selectedIndex < 0){return false;}
-	h.text = a.options[a.selectedIndex].text ;
-	h.value = a.options[a.selectedIndex].value;
-	if(ie){b.add(h);} else{ b.add(h,null);}
+	ASTGUI.selectbox_push(b,a.options[a.selectedIndex].text, a.options[a.selectedIndex].value);
 	a.remove(a.selectedIndex);
 }
 
@@ -315,11 +299,7 @@
 			UserExtensions.push(l);
 			if( n[l]['hassip']=='yes'){LISTOFCHANNELS['SIP/' + l] = true;}
 			if( n[l]['hasiax']=='yes'){LISTOFCHANNELS['IAX2/' + l] = true;}
-
-			h = opt_temp.cloneNode(true);
-			h.text = l + " -- " + n[l]['fullname'] ;
-			h.value = 'Voicemail(' + l + ',b)';
-			if(ie){el.add(h);} else{ el.add(h,null);}
+			ASTGUI.selectbox_push(el, l + " -- " + n[l]['fullname'] , 'Voicemail(' + l + ',b)');
 		}
 	}}
 	config2json('extensions.conf', 0, read_extensions) ;
@@ -348,10 +328,7 @@
 
 		t = l.substr(0,17);
 		if( t =='voicemenu-custom-' ){ // if is a Voice Menu
-			h = opt_temp.cloneNode(true);
-			h.text = get_menuname(n[l]);
-			h.value = 'Goto('+ n[l] + '|s|1)';
-			if(ie){el.add(h);} else{ el.add(h,null);}
+			ASTGUI.selectbox_push(el,get_menuname(n[l]), 'Goto('+ n[l] + '|s|1)' );
 		}
 	}}
 	config2json('zapscan.conf', 1, read_zapchannels) ;
@@ -429,18 +406,13 @@
 	_$('ringgroup_editdiv').style.display = '';
 
 	var r = _$('select_ringthesechannels');
-	while (r.options.length)
-		r.remove(0);
-
 	var y = _$('select_listofchannels');
-	while (y.options.length)
-		y.remove(0);
+
+	ASTGUI.selectbox_clear(r);
+	ASTGUI.selectbox_clear(y);
 
 	for( var u in LISTOFCHANNELS ){ if(LISTOFCHANNELS.hasOwnProperty(u)) {
-		h = opt_temp.cloneNode(true);
-		h.text = u ;
-		h.value = u ;
-		if(ie){y.add(h);} else{ y.add(h,null);}
+		ASTGUI.selectbox_push(y,u,u);
 	}}
 }
 

Modified: trunk/config/timerules.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/timerules.html?view=diff&rev=992&r1=991&r2=992
==============================================================================
--- trunk/config/timerules.html (original)
+++ trunk/config/timerules.html Tue May 29 16:29:43 2007
@@ -236,38 +236,25 @@
 
 
 function set_selectboxes(){
-	var ie;
-	var opt_temp = document.createElement('option');
-	if(document.attachEvent){ ie=1;}else{ie=0;}
-
 	var tostring = function (s){
 		return (s<10)?"0"+String(s):s;
 	}
 
 	var updateselect = function( el,start,end ){
-		var s,u;
-		for(s =start; s< end; s++){
-			u = opt_temp.cloneNode(true);
+		for( var s =start; s< end; s++){
 			s = tostring(s);
-			u.text = s ;	u.value = s;
-			if(ie){el.add(u);} else{el.add(u,null);}
+			ASTGUI.selectbox_push(el,s,s);
 		}
 		el.selectedIndex = -1;
 	}
 
 	var update_select_menus = function(el){
-		var g,h;
+		var g;
 		for ( g=0; g <voicemenus.length; g++){
-			h = opt_temp.cloneNode(true);
-			h.text = voicemenus[g].menuname ;
-			h.value = voicemenus[g].menucontextstring;
-			if(ie){el.add(h);} else{ el.add(h,null);}
+			ASTGUI.selectbox_push(el,voicemenus[g].menuname,voicemenus[g].menucontextstring);
 		}
 		for ( g=0 ; g <user_extens.length; g++){
-			h = opt_temp.cloneNode(true);
-			h.text = user_extens[g].username;
-			h.value = user_extens[g].usercontextstring;
-			if(ie){ el.add(h);} else{ el.add(h,null);}
+			ASTGUI.selectbox_push(el,user_extens[g].username,user_extens[g].usercontextstring);
 		}
 	}
 

Modified: trunk/config/users.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/users.html?view=diff&rev=992&r1=991&r2=992
==============================================================================
--- trunk/config/users.html (original)
+++ trunk/config/users.html Tue May 29 16:29:43 2007
@@ -199,14 +199,7 @@
 
 	for( var d in c ){
 		if ( c.hasOwnProperty(d) && c[d]['port'] && (c[d]['port'] == 'fxo' ) ) {
-			var New_OPTION = document.createElement('option');
-			New_OPTION.text =  "Analog Port #" + d ;
-			New_OPTION.value = d ;
-			try {
-				_zapchan.add(New_OPTION, null); // W3C way
-			}catch(ex) {
-				_zapchan.add(New_OPTION); // IE way
-			}
+			ASTGUI.selectbox_push(_zapchan,"Analog Port #" + d, d);
 		}
 	}
 	
@@ -214,11 +207,7 @@
 		_zapchan.style.display="none";
 		_$('noanaloglines').style.display="";
 	}
-	var noneopt = document.createElement("OPTION");
-	_zapchan.options.add(noneopt,0);
-	noneopt.value = "";
-	noneopt.innerText = "None";
-
+	ASTGUI.selectbox_insert_before(_zapchan,"None", "", 0);
 	config2json('extensions.conf', 1, dialplans_loaded ) ;
 	//parent.astmanEngine.config2list("extensions.conf", _$('context'), new Array(), numcallbacks);
 }
@@ -229,17 +218,8 @@
 
 	for( var d in c ){
 		if ( c.hasOwnProperty(d) && d.substr(0,11) == 'numberplan-'  ) {
-			var New_OPTION = document.createElement('option');
-			if(c[d]['plancomment'])
-				New_OPTION.text =  unescape( c[d]['plancomment'] ) ;
-			else
-				New_OPTION.text =  d ;
-			New_OPTION.value = d ;
-			try {
-				_context.add(New_OPTION, null); // W3C way
-			}catch(ex) {
-				_context.add(New_OPTION); // IE way
-			}
+			var txt = (c[d]['plancomment'])?unescape(c[d]['plancomment']) : d;
+			ASTGUI.selectbox_push(_context,txt, d);
 		}
 	}
 



More information about the asterisk-gui-commits mailing list