pari: trunk r961 - in /trunk/config: ./ scripts/

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Fri May 18 16:10:07 MST 2007


Author: pari
Date: Fri May 18 18:10:06 2007
New Revision: 961

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=961
Log:
moving 'makerequest()' from timerules into astman.js

Modified:
    trunk/config/cfgbasic.html
    trunk/config/feditor.html
    trunk/config/incoming.html
    trunk/config/localexts.html
    trunk/config/meetme.html
    trunk/config/menus.html
    trunk/config/numberplan.html
    trunk/config/options.html
    trunk/config/queues.html
    trunk/config/record.html
    trunk/config/scripts/astman.js
    trunk/config/timerules.html
    trunk/config/trunks.html

Modified: trunk/config/cfgbasic.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/cfgbasic.html?view=diff&rev=961&r1=960&r2=961
==============================================================================
--- trunk/config/cfgbasic.html (original)
+++ trunk/config/cfgbasic.html Fri May 18 18:10:06 2007
@@ -161,19 +161,7 @@
 }
 
 function makeping(){
-	var tmp;
-	var opt = {
-		method: 'get',
-		parameters: "action=ping",
-		asynchronous: true,
-		onComplete: function(t){
-			if( t.responseText.match(asterisk_guipingerror) ){
-				window.location.href=window.location.href;
-			}
-			
-		}
-	};
-	tmp = new Ajax.Request( asterisk_rawmanPath, opt);
+	makerequest("","","action=ping", function(t){ if( t.match(asterisk_guipingerror) ){ window.location.href=window.location.href;} } );
 }
 
 eventeater.eventcb = function(msgs) {
@@ -226,18 +214,7 @@
 
 function Logoff() {
 	if(!confirm("Are you sure ?")){ return true; }
-	var opt2 = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() {	 
-			window.location.href=window.location.href;
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};
-	opt2.parameters ="action=logoff";
-	var tmp2 = new Ajax.Request(asterisk_rawmanPath , opt2);
+	makerequest("","","action=logoff", function(t){ window.location.href=window.location.href; } );
 }
 
 function system_link(){
@@ -248,15 +225,10 @@
 function reloadConfig(){
 	_$('reloadconfig').style.display = 'none'; 
 	window.setTimeout( function(){ _$('reloadconfig').style.display=""; }, asterisk_guifbt );
-	var opt = { 
-		method: 'get', 
-		asynchronous: true, 
-		onSuccess: function(t) { gui_feedback("Restarted Asterisk !!",'blue'); } ,
-		onFailure: function(t) { gui_alert("Config Error: " + t.status + ": " + t.statusText); }
-	};
-	var uri = parent.build_action('renamecat', 0, "","", "", ""); 
-	opt.parameters="action=updateconfig&reload=yes&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	var tmp = new Ajax.Request(asterisk_rawmanPath , opt);
+
+	var uri = parent.build_action('renamecat', 0, "","", "", "");
+	var r = "action=updateconfig&reload=yes&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
+	makerequest("","",r, function(t){ gui_feedback("Restarted Asterisk !!",'blue'); } );
 }
 
 

Modified: trunk/config/feditor.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/feditor.html?view=diff&rev=961&r1=960&r2=961
==============================================================================
--- trunk/config/feditor.html (original)
+++ trunk/config/feditor.html Fri May 18 18:10:06 2007
@@ -78,25 +78,14 @@
 
 function delete_context(){
 	if(!confirm("Are you sure you want to delete the selected context ?")){ return true; }
-
 	var uri = build_action('delcat', 0, global_contextBeingEdited ,"", "");
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() {
+	makerequest('u', global_fileBeingEdited, uri , function(t) {
 			_$('AddContext').style.display = "none";
 			_$('div_editcontext').style.display = "none"; 
 			global_contextBeingEdited = "";
 			gui_feedback('Context Deleted','blue');
 			config2json( global_fileBeingEdited, 0, fileparsed );
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-			gui_alert("Failed to Rename the DID context for " + old_didcontext );
-		}
-	};
-	opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent(global_fileBeingEdited) + "&dstfilename=" + encodeURIComponent(global_fileBeingEdited) + uri;
-	var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+		});
 }
 
 
@@ -108,23 +97,13 @@
 
 function update_context(){ // rename from global_contextBeingEdited to $('context_edited').value
 	var uri = build_action('renamecat', 0, global_contextBeingEdited ,"", _$('context_edited').value );
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() {
+	makerequest('u',global_fileBeingEdited, uri, function(t) {
 			_$('AddContext').style.display = "none";
 			_$('div_editcontext').style.display = "none"; 
 			global_contextBeingEdited = "";
 			gui_feedback('Context Updated','blue');
 			config2json( global_fileBeingEdited, 0, fileparsed );
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-			gui_alert("Failed to Rename the DID context for " + old_didcontext );
-		}
-	};
-	opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent(global_fileBeingEdited) + "&dstfilename=" + encodeURIComponent(global_fileBeingEdited) + uri;
-	var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+		});
 }
 
 
@@ -258,23 +237,12 @@
 		uri += build_action('append', c, global_contextBeingEdited, firstpart, secondpart ); c++;
 	}
 
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() {
+	makerequest('u',global_fileBeingEdited, uri, function(t){
 			_$('div_editcontextContent').style.display = "none"; 
 			global_contextBeingEdited = "";
 			gui_feedback('Context Content Updated','blue');
 			config2json( global_fileBeingEdited, 0, fileparsed );
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-			gui_alert("Failed to Rename the DID context for " + old_didcontext );
-		}
-	};
-	opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent(global_fileBeingEdited) + "&dstfilename=" + encodeURIComponent(global_fileBeingEdited) + uri;
-	var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
-
+	});
 }
 
 
@@ -385,23 +353,12 @@
 
 function add_context(){
 	var uri = build_action('newcat', 0, _$('New_ContextName').value ,"", "");
-
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() {
+	makerequest('u',global_fileBeingEdited,uri, function(){
 			cancel_addcontext(); 
 			global_contextBeingEdited = "";
 			gui_feedback('New Context Added','blue');
 			config2json( global_fileBeingEdited, 0, fileparsed );
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-			gui_alert("Failed to Add New context ");
-		}
-	};
-	opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent(global_fileBeingEdited) + "&dstfilename=" + encodeURIComponent(global_fileBeingEdited) + uri;
-	var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+	});
 }
 </script>
 <body id="foo" onload="localajaxinit()"  bgcolor="FFFFFF" onunload="resetmainscreen();">

Modified: trunk/config/incoming.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/incoming.html?view=diff&rev=961&r1=960&r2=961
==============================================================================
--- trunk/config/incoming.html (original)
+++ trunk/config/incoming.html Fri May 18 18:10:06 2007
@@ -307,13 +307,10 @@
 		gui_feedback("An incoming call rule is already defined <BR> on this trunk for the selcted pattern !! ");
 		return false;
 	}
-	
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function(t) { 									
-			// add this to the global object
-			didtrunks[temp_provider][newpattern] = new Object();
+
+	makerequest('u','extensions.conf', uri,
+		function(t){
+			didtrunks[temp_provider][newpattern] = new Object(); // add this to the global object
 			didtrunks[temp_provider][newpattern].priority = temp_priority;
 			didtrunks[temp_provider][newpattern].action = temp_action ;
 			//addrowtotable(newpattern,temp_provider,temp_action,temp_priority) ; // a is pattern, b is DID_trunk, c is action, d is priority
@@ -321,15 +318,10 @@
 			_$('userscontent').style.display = "none";
 			_$('bg_transparent').style.display ='none';
 			gui_feedback("Added Incoming Rule",'blue');
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};
-
-	opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	var tmp = new Ajax.Request(asterisk_rawmanPath , opt);
-	// 
+		}
+	);
+
+
 }
 
 
@@ -384,10 +376,8 @@
 	}
 
 	// delete old entry and add new entry
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function(t) { 									
+	makerequest('u','extensions.conf', uri,
+		function(t){
 			delete didtrunks[edit_DIDtrunk][edit_pattern] ;
 			didtrunks[temp_provider][newpattern] = new Object();
 			didtrunks[temp_provider][newpattern].priority = temp_priority;
@@ -396,13 +386,9 @@
 			_$('bg_transparent').style.display ='none';
 			refreshtable();
 			gui_feedback("Updated Incoming Rule",'blue');
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};
-	opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	var tmp = new Ajax.Request(asterisk_rawmanPath , opt);
+		}
+	);
+
 }
 
 
@@ -434,28 +420,19 @@
 
 function delete_incomingrule(a,b,c,d){ // a is pattern, b is DID_trunk, c is action, d is priority
 	if( !confirm("Are you sure you want to delete this Incoming Calling Rule?") ){ return true; }
-
 	var tmp_match = a+","+d+","+c ;
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function(t) { 									
-			// add this to the global object
-			delete didtrunks[b][a];
-			refreshtable();
-			gui_feedback("Deleted 'Incoming Rule'",'default');
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};
 	var uri = build_action('delete',0, b, "exten" ,"", tmp_match);
 	if( a == "_X." ){
 		var tmp2_match = "s," + d + "," + c ;
 		uri += build_action('delete',1,b,"exten","", tmp2_match);
 	}
-	opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	var tmp = new Ajax.Request(asterisk_rawmanPath , opt);
+	makerequest('u','extensions.conf', uri,
+		function(t){
+			delete didtrunks[b][a];
+			refreshtable();
+			gui_feedback("Deleted 'Incoming Rule'",'default');
+		}
+	);
 }
 
 

Modified: trunk/config/localexts.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/localexts.html?view=diff&rev=961&r1=960&r2=961
==============================================================================
--- trunk/config/localexts.html (original)
+++ trunk/config/localexts.html Fri May 18 18:10:06 2007
@@ -58,17 +58,7 @@
 	} 
 	
 	if(uri!=""){
-		var opt = {
-			method: 'get',
-			asynchronous: true,
-			onSuccess: function() {},
-			onFailure: function(t) {
-				gui_alert("Config Error: " + t.status + ": " + t.statusText);
-				return false;
-			}
-		};
-		opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-		var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+		makerequest('u','extensions.conf', uri,function(t){});
 	}
 }
 
@@ -89,19 +79,12 @@
 	d.selectitem(0);
 
 	if ( typeof d.stored_config.catbyname['general'].fieldbyname['localextenlength'] == "undefined" ){ 
-		var opt = {
-			method: 'get',
-			asynchronous: true,
-			onSuccess: function(t) { 
+		makerequest('u','users.conf','&Action-000000=update&Cat-000000=general&Var-000000=localextenlength&Value-000000=4',
+			function(t){ 
 				_$('localextenlength').selectedIndex = 2 ;
 				parent.loadscreen(this);
-			},
-			onFailure: function(t) {
-				gui_alert("Config Error: " + t.status + ": " + t.statusText);
 			}
-		};
-		opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("users.conf") + "&dstfilename=" + encodeURIComponent("users.conf") + "&Action-000000=update&Cat-000000=general&Var-000000=localextenlength&Value-000000=4"; ;
-		var tmp = new Ajax.Request(asterisk_rawmanPath , opt);
+		);
 		return;
 	}
 	parent.loadscreen(this);

Modified: trunk/config/meetme.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/meetme.html?view=diff&rev=961&r1=960&r2=961
==============================================================================
--- trunk/config/meetme.html (original)
+++ trunk/config/meetme.html Fri May 18 18:10:06 2007
@@ -285,18 +285,18 @@
 			uri +=  build_action('delete', p, "rooms" ,"conf", "", oldvalue );  p++;
 		}
 		uri += build_action('append', p, "rooms","conf", newvalue );  p++;
-		var opt = { method: 'get', asynchronous: true, onComplete: function(){ 
+
+		makerequest('u','extensions.conf',uri,
+			function(t){
 				if( temp_rooms_r ==  -1 ){ // add
 					f.stored_config.catbyname.rooms.fields.push( newvalue );
 				}else{  // update
 					f.stored_config.catbyname.rooms.fields[temp_rooms_r] =  newvalue ;
 				}
-			_$('save').disabled = true; 
-			_$('cancel').disabled = true;
-			} 
-		};
-		opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("meetme.conf") + "&dstfilename=" + encodeURIComponent("meetme.conf") + uri;
-		var tmp = new Ajax.Request(asterisk_rawmanPath , opt);
+				_$('save').disabled = true; 
+				_$('cancel').disabled = true;	
+			}
+		);
 		return true;
 	}
 }
@@ -307,14 +307,10 @@
 	for ( var r=0; r < f.stored_config.catbyname.rooms.fields.length; r++ ) {
 		var k = f.stored_config.catbyname.rooms.fields[r].split(",");
 		if(k[0] == temp_selectedexten ){
-			var uri =  build_action('delete', 0, "rooms" ,"conf", "", f.stored_config.catbyname.rooms.fields[r] );  
-			var opt = { 	
-				method: 'get', 
-				asynchronous: true, 
-				onComplete: function(){ f.stored_config.catbyname.rooms.fields.splice(r ,1); } 
-			};
-			opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("meetme.conf") + "&dstfilename=" + encodeURIComponent("meetme.conf") + uri;
-			var tmp = new Ajax.Request(asterisk_rawmanPath , opt);
+			var uri =  build_action('delete', 0, "rooms" ,"conf", "", f.stored_config.catbyname.rooms.fields[r] );
+			makerequest('u','meetme.conf', uri ,
+				function(t){ f.stored_config.catbyname.rooms.fields.splice(r ,1); }
+			);
 			break;
 		}
 	}

Modified: trunk/config/menus.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/menus.html?view=diff&rev=961&r1=960&r2=961
==============================================================================
--- trunk/config/menus.html (original)
+++ trunk/config/menus.html Fri May 18 18:10:06 2007
@@ -214,20 +214,9 @@
 	}
 	// use the deleted_voicmenu to delete the alias (if it exists) in the default
 	if(_$('alias_exten').value.length > 0){
-		var opt = {
-			method: 'get',
-			asynchronous: true,
-			onSuccess: function(t) { 									
-				delete voicemenusdata[deleted_voicmenu];
-			},
-			onFailure: function(t) {
-				gui_alert("Config Error: " + t.status + ": " + t.statusText);
-			}
-		};
 		var existing_alias_string = voicemenusdata[deleted_voicmenu].alias_exten + ",1,Goto(" + deleted_voicmenu + "|s|1)"  ;
 		var uri = build_action('delete', 0, specialcontext ,"exten", "", existing_alias_string ); 
-		opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-		var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+		makerequest('u','extensions.conf', uri, function(t){ } );
 	}
 	delete voicemenusdata[deleted_voicmenu];
 }
@@ -293,44 +282,7 @@
 	_$('status_message').style.display = "";
 	// prepare a request to add the new step to the voicemenu
 	// make a request to append
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() { 
-			setTimeout(function(){ _$('status_message').style.display = 'none'; },sc_displaytime);
-			// if request successfull then add this to the steps select box
-			var newoption = document.createElement("option"); 
-			newoption.text = format_step(action_string ); 
-			newoption.value = action_string ;
-			var _steps = _$('steps') ;
-			_steps.options.add ( newoption );
-			// and also add the information to the voicemenus data
-			if(voicemenusdata[_vmv].extensions['s']){
-				voicemenusdata[_vmv].extensions['s'].push(action_string);
-			}else{
-				voicemenusdata[_vmv].extensions['s'] = new Array;
-				voicemenusdata[_vmv].extensions['s'][0] = action_string;
-			}
-			// empty this textbox & disable this button, select the newly added item to the steps options box
-			_nsa.selectedIndex = 0;
-			_$('deletestep').disabled = false;
-			_steps.selectedIndex = _steps.length - 1 ;
-			gui_feedback('New step added !','blue');
-			update_updown();
-			_nsv.value = "";
-			_nsv.style.display = "none" ;
-			_$('add_newstep_extensions').style.display = "none";
-			_$('add_newstep_menus').style.display = "none";
-			_$('combodiv_sounds').style.display = "none" ;
-			_nsvd = _$('newstep_var_digit'); 
-			_nsvd.value= "";
-			_nsvd.style.display= "none" ;
-		},
-		onFailure: function(t) {
-			_$('status_message').style.display = 'none';
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};
+
 	var uri = "";
 	var action_string = "";
 	var priorities = new Array;
@@ -392,8 +344,39 @@
 	}
 
 	uri += build_action('append', 0, _vmv,"exten", action_string ); 
-	opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+
+	makerequest('u','extensions.conf', uri,
+		function(t){
+			setTimeout(function(){ _$('status_message').style.display = 'none'; },sc_displaytime);
+			// if request successfull then add this to the steps select box
+			var newoption = document.createElement("option"); 
+			newoption.text = format_step(action_string ); 
+			newoption.value = action_string ;
+			var _steps = _$('steps') ;
+			_steps.options.add ( newoption );
+			// and also add the information to the voicemenus data
+			if(voicemenusdata[_vmv].extensions['s']){
+				voicemenusdata[_vmv].extensions['s'].push(action_string);
+			}else{
+				voicemenusdata[_vmv].extensions['s'] = new Array;
+				voicemenusdata[_vmv].extensions['s'][0] = action_string;
+			}
+			// empty this textbox & disable this button, select the newly added item to the steps options box
+			_nsa.selectedIndex = 0;
+			_$('deletestep').disabled = false;
+			_steps.selectedIndex = _steps.length - 1 ;
+			gui_feedback('New step added !','blue');
+			update_updown();
+			_nsv.value = "";
+			_nsv.style.display = "none" ;
+			_$('add_newstep_extensions').style.display = "none";
+			_$('add_newstep_menus').style.display = "none";
+			_$('combodiv_sounds').style.display = "none" ;
+			_nsvd = _$('newstep_var_digit'); 
+			_nsvd.value= "";
+			_nsvd.style.display= "none" ;
+		}
+	);
 
 }
 
@@ -421,11 +404,90 @@
 	}
 	_$('status_message').style.display ="" ;
 	var _cmv = _$('comment').value ;
-
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() { 
+	var uri = "" ;
+	var p = 0 ;
+	var buildstring = new Object ;
+
+	if( _vms.options[_vms.selectedIndex].innerHTML=='New Entry' ){
+		var current_vmenu = next_freevmenu();
+		uri += build_action('newcat', p, current_vmenu,"", ""); p = p+1;
+		uri += build_action('append', p, current_vmenu,"comment", _cmv ); p = p+1;
+		uri += build_action('append', p, current_vmenu,"alias_exten", _ae.value); p = p+1;
+		if(_ae.value.length > 0){
+			// alias for this voicemenu in [default] section of extensions.conf
+			var alias_string = _ae.value + ",1,Goto(" + current_vmenu + "|s|1)"  ;
+			uri += build_action('append', p, specialcontext ,"exten", alias_string ); p = p+1;
+		}
+
+		if( _ale.checked){ uri += build_action('append', p, current_vmenu,"include", "default"); p = p+1; }
+		uri += build_action('append', p, current_vmenu,"exten", answer_call_string); p = p+1;
+	}else{
+		// Updating existing Voicemenu
+		var current_vmenu = _vms.value;
+		if(  voicemenusdata[current_vmenu].comment != _cmv ){
+			uri += build_action('update', p, current_vmenu ,"comment", _cmv); p = p+1;
+			change_vmenuname_inlistofmenus(voicemenusdata[current_vmenu].comment,_cmv);
+			voicemenusdata[current_vmenu].comment = _cmv;
+		}
+		
+		if(  voicemenusdata[current_vmenu].alias_exten != _ae.value ){
+			var existing_alias_string = voicemenusdata[current_vmenu].alias_exten + ",1,Goto(" + current_vmenu + "|s|1)"  ;
+			if( _ae.value.length > 0 ){
+				// change alias for this voicemenu in 'default' section of extensions.conf
+				var new_alias_string = _ae.value + ",1,Goto(" + current_vmenu + "|s|1)"  ;
+				uri += build_action('update', p, specialcontext ,"exten", new_alias_string,existing_alias_string); p = p+1;
+			}else{
+				// if the user is deleting the alias for this voicemenu, then delete the defined alias in the [default] extensions.conf
+				uri += build_action('delete', p, specialcontext ,"exten", "",existing_alias_string); p = p+1;
+			}
+
+			uri += build_action('update', p, current_vmenu ,"alias_exten", _ae.value ); p = p+1;
+			voicemenusdata[current_vmenu].alias_exten = _ae.value;
+		}
+		
+		if( voicemenusdata[current_vmenu].include =="default" && !_ale.checked ){
+			uri += build_action('delete', p, current_vmenu ,"include",""); p = p+1;
+			voicemenusdata[current_vmenu].include = "" ;
+		}else if ( voicemenusdata[current_vmenu].include !="default"  && _ale.checked ){
+			uri += build_action('append', p, current_vmenu,"include", "default"); p = p+1;
+			voicemenusdata[current_vmenu].include = "default" ;
+		}else if ( !voicemenusdata[current_vmenu].include && _ale.checked ){
+			uri += build_action('append', p, current_vmenu ,"include", "default"); p = p+1;
+			voicemenusdata[current_vmenu].include = "default" ;
+		}
+
+		for (var k=0; k< keys.length; k++){
+			if(voicemenusdata[current_vmenu].extensions[keys[k]]){
+				uri += build_action('delete', p, current_vmenu,"exten", "", voicemenusdata[current_vmenu].extensions[keys[k]][0] ); p = p+1;
+			}
+		}
+	}
+
+	// Build exten strings for enabled keys and append/update the 
+	for (var k=0; k< keys.length; k++){
+		var current_key_action='keypress_'+ keys[k] + '_action';
+		var current_key_text='keypress_'+ keys[k] + '_text';
+		var current_key_exts='keypress_'+ keys[k] + '_exts';
+		var current_key_menus='keypress_'+ keys[k] + '_menus';
+	
+		if( $(current_key_action).value == "disabled")
+			continue;
+		else if( $(current_key_action).value == "gotomenu" )
+				buildstring[keys[k]] = keys[k] + ",1,Goto("+ $(current_key_menus).value + "|s|1)" ;					
+		else if( $(current_key_action).value == "gotoextension" )
+				buildstring[keys[k]] = keys[k] + ",1,Goto(default|"+ $(current_key_exts).value + "|1)" ;					
+		else if( $(current_key_action).value == "Custom" ) 
+				buildstring[keys[k]] = keys[k] + ",1,"+ $(current_key_text).value ;
+		else if( $(current_key_action).value == "Hangup" )
+				buildstring[keys[k]] = keys[k] + ",1,"+ "Hangup" ;					
+		else if( $(current_key_action).value == "PlayInvalid" ) 
+				buildstring[keys[k]] = keys[k] + ",1,"+ "Playback(invalid)" ;
+					
+		uri += build_action('append', p, current_vmenu,"exten", buildstring[keys[k]]); p = p+1;
+	}
+
+	makerequest('u','extensions.conf', uri ,
+		function(t){
 			setTimeout( function(){_$('status_message').style.display="none"; },sc_displaytime );
 			gui_feedback('Updated.','blue');
 			_$('savevmenu').disabled = true;
@@ -465,98 +527,8 @@
 					}
 				}
 			}
-
-		},
-		onFailure: function(t) {
-			_$('status_message').style.display='none';
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};
-	var uri = "" ;
-	var p = 0 ;
-	var buildstring = new Object ;
-
-	if( _vms.options[_vms.selectedIndex].innerHTML=='New Entry' ){
-		var current_vmenu = next_freevmenu();
-		uri += build_action('newcat', p, current_vmenu,"", ""); p = p+1;
-		uri += build_action('append', p, current_vmenu,"comment", _cmv ); p = p+1;
-		uri += build_action('append', p, current_vmenu,"alias_exten", _ae.value); p = p+1;
-		if(_ae.value.length > 0){
-			// alias for this voicemenu in [default] section of extensions.conf
-			var alias_string = _ae.value + ",1,Goto(" + current_vmenu + "|s|1)"  ;
-			uri += build_action('append', p, specialcontext ,"exten", alias_string ); p = p+1;
-		}
-
-		if( _ale.checked){ uri += build_action('append', p, current_vmenu,"include", "default"); p = p+1; }
-		uri += build_action('append', p, current_vmenu,"exten", answer_call_string); p = p+1;
-	}else{
-		// Updating existing Voicemenu
-		var current_vmenu = _vms.value;
-		if(  voicemenusdata[current_vmenu].comment != _cmv ){
-			uri += build_action('update', p, current_vmenu ,"comment", _cmv); p = p+1;
-			change_vmenuname_inlistofmenus(voicemenusdata[current_vmenu].comment,_cmv);
-			voicemenusdata[current_vmenu].comment = _cmv;
-		}
-		
-		if(  voicemenusdata[current_vmenu].alias_exten != _ae.value ){
-			var existing_alias_string = voicemenusdata[current_vmenu].alias_exten + ",1,Goto(" + current_vmenu + "|s|1)"  ;
-			if( _ae.value.length > 0 ){
-				// change alias for this voicemenu in 'default' section of extensions.conf
-				var new_alias_string = _ae.value + ",1,Goto(" + current_vmenu + "|s|1)"  ;
-				uri += build_action('update', p, specialcontext ,"exten", new_alias_string,existing_alias_string); p = p+1;
-			}else{
-				// if the user is deleting the alias for this voicemenu, then delete the defined alias in the [default] extensions.conf
-				uri += build_action('delete', p, specialcontext ,"exten", "",existing_alias_string); p = p+1;
-			}
-
-			uri += build_action('update', p, current_vmenu ,"alias_exten", _ae.value ); p = p+1;
-			voicemenusdata[current_vmenu].alias_exten = _ae.value;
-		}
-		
-		if( voicemenusdata[current_vmenu].include =="default" && !_ale.checked ){
-			uri += build_action('delete', p, current_vmenu ,"include",""); p = p+1;
-			voicemenusdata[current_vmenu].include = "" ;
-		}else if ( voicemenusdata[current_vmenu].include !="default"  && _ale.checked ){
-			uri += build_action('append', p, current_vmenu,"include", "default"); p = p+1;
-			voicemenusdata[current_vmenu].include = "default" ;
-		}else if ( !voicemenusdata[current_vmenu].include && _ale.checked ){
-			uri += build_action('append', p, current_vmenu ,"include", "default"); p = p+1;
-			voicemenusdata[current_vmenu].include = "default" ;
-		}
-
-		for (var k=0; k< keys.length; k++){
-			if(voicemenusdata[current_vmenu].extensions[keys[k]]){
-				uri += build_action('delete', p, current_vmenu,"exten", "", voicemenusdata[current_vmenu].extensions[keys[k]][0] ); p = p+1;
-			}
-		}
-	}
-
-	// Build exten strings for enabled keys and append/update the 
-	for (var k=0; k< keys.length; k++){
-		var current_key_action='keypress_'+ keys[k] + '_action';
-		var current_key_text='keypress_'+ keys[k] + '_text';
-		var current_key_exts='keypress_'+ keys[k] + '_exts';
-		var current_key_menus='keypress_'+ keys[k] + '_menus';
-	
-		if( $(current_key_action).value == "disabled")
-			continue;
-		else if( $(current_key_action).value == "gotomenu" )
-				buildstring[keys[k]] = keys[k] + ",1,Goto("+ $(current_key_menus).value + "|s|1)" ;					
-		else if( $(current_key_action).value == "gotoextension" )
-				buildstring[keys[k]] = keys[k] + ",1,Goto(default|"+ $(current_key_exts).value + "|1)" ;					
-		else if( $(current_key_action).value == "Custom" ) 
-				buildstring[keys[k]] = keys[k] + ",1,"+ $(current_key_text).value ;
-		else if( $(current_key_action).value == "Hangup" )
-				buildstring[keys[k]] = keys[k] + ",1,"+ "Hangup" ;					
-		else if( $(current_key_action).value == "PlayInvalid" ) 
-				buildstring[keys[k]] = keys[k] + ",1,"+ "Playback(invalid)" ;
-					
-		uri += build_action('append', p, current_vmenu,"exten", buildstring[keys[k]]); p = p+1;
-	}
-
-	opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	// send the request
-	tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+		}
+	);
 }
 
 
@@ -620,11 +592,13 @@
 
 	tmp1.splice(1,1,priority_2);
 	tmp2.splice(1,1,priority_1);
-
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() { 
+	var uri = "";
+	// ok find $('steps').options[a].value in extensions.conf and replace it with tmp1.join() and also replace $('steps').options[b].value with tmp2.join()	
+	uri += build_action('update', 0, _vms_v ,"exten",tmp1.join(), _steps.options[a].value);
+	uri += build_action('update', 1, _vms_v ,"exten",tmp2.join(), _steps.options[b].value);
+
+	makerequest('u','extensions.conf', uri,
+		function(t){
 			// update voicemenusdata
 			for(var p=0; p< voicemenusdata[_vms_v].extensions['s'].length; p++){
 				if( voicemenusdata[_vms_v].extensions['s'][p] == _steps.options[a].value ){
@@ -642,19 +616,8 @@
 			_steps.selectedIndex = b;
 			gui_feedback('Step Priority Updated!','blue');
 			update_updown();
-
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};	
-	var uri = "";
-
-	// ok find $('steps').options[a].value in extensions.conf and replace it with tmp1.join() and also replace $('steps').options[b].value with tmp2.join()	
-	uri += build_action('update', 0, _vms_v ,"exten",tmp1.join(), _steps.options[a].value);
-	uri += build_action('update', 1, _vms_v ,"exten",tmp2.join(), _steps.options[b].value);
-	opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+		}
+	);
 }
 
 
@@ -663,11 +626,10 @@
 	_$('status_message').style.display="";
 	var _vmenus = _$('vmenus');
 	var _steps = _$('steps');
-
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() { 
+	var uri = "";
+	uri += build_action('delete', 0, _vmenus.value,"exten", "", _steps.value); 
+	makerequest('u','extensions.conf', uri,
+		function(t){
 			setTimeout(function(){ _$('status_message').style.display='none';} ,sc_displaytime);
 			// Update voicemenusdata
 			for(var p=0; p< voicemenusdata[_vmenus.value].extensions['s'].length; p++){
@@ -678,16 +640,9 @@
 			_steps.remove( _steps.selectedIndex);
 			gui_feedback('Step Deleted !','default');
 			_$('deletestep').disabled = true;
-		},
-		onFailure: function(t) {
-			_$('status_message').style.display='none';
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};	
-	var uri = "";
-	uri += build_action('delete', 0, _vmenus.value,"exten", "", _steps.value); 
-	opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+		}
+	);
+
 }
 
 

Modified: trunk/config/numberplan.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/numberplan.html?view=diff&rev=961&r1=960&r2=961
==============================================================================
--- trunk/config/numberplan.html (original)
+++ trunk/config/numberplan.html Fri May 18 18:10:06 2007
@@ -132,10 +132,12 @@
 	commentstring = _ptv + ',' + this_priority + ',' + _rnv + "," + commentstring ;
 	uri += build_action('append', 1 , _extv ,"comment", commentstring );
 
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function(t) { 
+	_$('userscontent').style.display = "none";
+	_$('bg_transparent').style.display = "none";
+	_$('status_message').style.display = "";
+
+	makerequest('u', 'extensions.conf', uri,
+		function(t){
 			_$('status_message').style.display="none";
 			var m = numberplansdata[_extv]['npdata'];
 			if ( typeof m[_ptv] == 'undefined' ) { m[_ptv] = { }; }
@@ -143,16 +145,8 @@
 			m[_ptv][this_priority].rulename =  _rnv ; 
 			m[_ptv][this_priority].ruledesc = (iscustom) ? "custom" : parsepattern(_ptv,0) ;
 			oncomplete(); 
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};
-	opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	_$('userscontent').style.display = "none";
-	_$('bg_transparent').style.display = "none";
-	_$('status_message').style.display = "";
-	var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+		}
+	);
 }
 
 function saverule(){
@@ -373,24 +367,17 @@
 	var uri = build_action('delete', 0, _extv ,"exten", "", rule_string ); 
 	commentstring = a + ',' + b + ',' + m[a][b].rulename + ',' + commentstring ;
 	uri += build_action('delete', 1 , _extv ,"comment","", commentstring );
-
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function(t) { 
+	_$('userscontent').style.display = "none";
+	_$('bg_transparent').style.display = "none";
+	_$('status_message').style.display = "";
+
+	makerequest('u','extensions.conf', uri,
+		function(t){
 			_$('status_message').style.display="none";
 			delete numberplansdata[ _extv ]['npdata'][a][b] ;
 			oncomplete(); 
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};
-	opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	_$('userscontent').style.display = "none";
-	_$('bg_transparent').style.display = "none";
-	_$('status_message').style.display = "";
-	var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+		}
+	);
 }
 
 
@@ -597,14 +584,7 @@
 	var uri = build_action('newcat', 0, default_planname ,"", "");
 	uri += build_action('append', 1, default_planname,"plancomment", "DialPlan1"); 
 	uri += build_action('append', 2, default_planname,"include", "default"); 
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function(t) { gui_feedback("Created Default DialPlan",'green'); location.reload(); },
-		onFailure: function(t) { gui_alert("Config Error: " + t.status + ": " + t.statusText); }
-	};
-	opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
-	var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+	makerequest('u','extensions.conf', uri, function(t){gui_feedback("Created Default DialPlan",'green'); location.reload(); }   );
 }
 
 

Modified: trunk/config/options.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/options.html?view=diff&rev=961&r1=960&r2=961
==============================================================================
--- trunk/config/options.html (original)
+++ trunk/config/options.html Fri May 18 18:10:06 2007
@@ -27,21 +27,6 @@
 <script>
 var current_username = parent.document.getElementById('login_name').value;
 
-function askforRelogin(originalRequest){
-	if ( originalRequest.responseText.match("Success") ) {
-		gui_feedback("Password Updated Successfully", "blue", 5000);
-		alert("Password Updated Successfully!!  \n\n You will now be redirected to the login page \n You must relogin using your new password") ;
-		var opt2 = {
-			method: 'get',
-			asynchronous: true,
-			onSuccess: function() { parent.window.location.href = parent.window.location.href; },
-			onFailure: function(t) { gui_alert("Config Error: " + t.status + ": " + t.statusText); }
-		};
-		opt2.parameters ="action=logoff";
-		var tmp2 = new Ajax.Request(asterisk_rawmanPath, opt2);
-	}
-}
-
 function changepassword(){
 	var _newpass = _$('newpass'); 
 	if( _newpass.value!=_$('newpass_rep').value ){
@@ -56,14 +41,16 @@
 		return true;
 	}
 
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: askforRelogin ,
-		onFailure: function(t) { gui_alert("Config Error: " + t.status + ": " + t.statusText); }
-	};
-	opt.parameters ="action=updateconfig&srcfilename=manager.conf&dstfilename=manager.conf&Action-000000=update&Cat-000000=" + current_username + "&Var-000000=secret&Value-000000="+ encodeURIComponent( _newpass.value );
-	var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
+	var acs = build_action('update', 0, current_username, "secret",'', _newpass.value ) ;
+	makerequest('u', 'manager.conf',acs,
+		function(t){
+			if ( t.match("Success") ) {
+				gui_feedback("Password Updated Successfully", "blue", 5000);
+				alert("Password Updated Successfully!!  \n\n You will now be redirected to the login page \n You must relogin using your new password") ;
+				makerequest("","","action=logoff", function(t){parent.window.location.href = parent.window.location.href;} );
+			}
+		}
+	);
 	return;
 }
 

Modified: trunk/config/queues.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/queues.html?view=diff&rev=961&r1=960&r2=961
==============================================================================
--- trunk/config/queues.html (original)
+++ trunk/config/queues.html Fri May 18 18:10:06 2007
@@ -44,57 +44,22 @@
 function rename_extension(a,b){
 	// rename extension 'a' in extensions.conf to 'b'
 	// change 'exten => a,1,Queue' in default to 'exten => b,1,Queue'
-	var opt0 = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() { 
-			return true;	
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-			return false;
-		}
-	};
-	uri0 = build_action('update', 0, specialcontext ,'exten', b+',1,Queue(${EXTEN})', a+',1,Queue(${EXTEN})' ); 
-	opt0.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri0;
-	tmp0 = new Ajax.Request(asterisk_rawmanPath, opt0);
+	var uri = build_action('update', 0, specialcontext ,'exten', b+',1,Queue(${EXTEN})', a+',1,Queue(${EXTEN})' ); 
+	makerequest('u','extensions.conf', uri, function(t){return true;} );
 }
 
 function add_extension(a){
 	// add extension 'a' in extensions.conf 
 	// add 'exten => a,1,Queue' to default
-	var opt0 = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() { 
-			return true;	
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-			return false;
-		}
-	};
-	uri0 = build_action('append', 0, specialcontext ,'exten', a+',1,Queue(${EXTEN})'); 
-	opt0.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri0;
-	tmp0 = new Ajax.Request(asterisk_rawmanPath, opt0);
+	var uri = build_action('append', 0, specialcontext ,'exten', a+',1,Queue(${EXTEN})');
+	makerequest('u','extensions.conf',uri, function(t){return true;} );
+
 }
 
 function delete_extension(a){
-	// delete extension 'a' in extensions.conf 
-	var opt0 = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function() { 
-			return true;	
-		},
-		onFailure: function(t) {
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-			return false;
-		}
-	};
-	uri0 = build_action('delete', 0, specialcontext ,'exten', '',a+',1,Queue(${EXTEN})'); 
-	opt0.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri0;
-	tmp0 = new Ajax.Request(asterisk_rawmanPath, opt0);
+	// delete extension 'a' in extensions.conf
+	var uri = build_action('delete', 0, specialcontext ,'exten', '',a+',1,Queue(${EXTEN})'); 

[... 318 lines stripped ...]


More information about the asterisk-gui-commits mailing list