markster: trunk r10 - in /trunk/config: numberplan.html scripts/astman.js

asterisk-gui-commits at lists.digium.internal asterisk-gui-commits at lists.digium.internal
Tue Sep 5 13:11:27 CDT 2006


Author: markster
Date: Tue Sep  5 13:11:26 2006
New Revision: 10

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

Modified:
    trunk/config/numberplan.html
    trunk/config/scripts/astman.js

Modified: trunk/config/numberplan.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/numberplan.html?rev=10&r1=9&r2=10&view=diff
==============================================================================
--- trunk/config/numberplan.html (original)
+++ trunk/config/numberplan.html Tue Sep  5 13:11:26 2006
@@ -434,7 +434,8 @@
 		}
 
 		function swap_priorities(a,b){
-				box = document.getElementById('extensions') ;
+				var box = $('extensions') ;
+				var sela, selb;
 				var opt = {
 					method: 'get',
 					asynchronous: true,
@@ -449,6 +450,9 @@
 					},
 				};
 
+				sela = $('extensions').options[a].selected;
+				selb = $('extensions').options[b].selected;
+
 				v = $('extensions').selectedIndex;
 				t_pattern1 = $('extensions').options[a].value.split(']');
 				t_pattern2 = $('extensions').options[b].value.split(']');
@@ -463,14 +467,22 @@
 				value_one =  subfield_value(1,'name')+ "," +   subfield_value(2,'priority') + ","+ subfield_value(1,'app') +"(" + subfield_value(1,'args') +")";
 				match_one =  subfield_value(1,'name')+ "," +   subfield_value(1,'priority') + ","+ subfield_value(1,'app') +"(" + subfield_value(1,'args') +")";
 				uri = build_action('update', 0, subfield_value(1,'context'),'exten', value_one, match_one);
+
+				value_two =  subfield_value(1,'name')+ "," +   subfield_value(1,'priority') + ","+ subfield_value(2,'app') +"(" + subfield_value(2,'args') +")";
+				match_two =  subfield_value(1,'name')+ "," +   subfield_value(2,'priority') + ","+ subfield_value(2,'app') +"(" + subfield_value(2,'args') +")";
+				uri += build_action('update', 1, subfield_value(2,'context'),'exten', value_two, match_two);
 				opt.parameters="action=updateconfig&reload=yes&srcfilename=" + encodeURIComponent(box.config_file) + "&dstfilename=" + encodeURIComponent(box.config_file) + uri;
 				tmp = new Ajax.Request(box.engine.url, opt);
-
-				value_two =  subfield_value(1,'name')+ "," +   subfield_value(1,'priority') + ","+ subfield_value(2,'app') +"(" + subfield_value(2,'args') +")";
-				match_two =  subfield_value(1,'name')+ "," +   subfield_value(2,'priority') + ","+ subfield_value(2,'app') +"(" + subfield_value(2,'args') +")";
-				uri = build_action('update', 0, subfield_value(2,'context'),'exten', value_two, match_two);
-				opt.parameters="action=updateconfig&reload=yes&srcfilename=" + encodeURIComponent(box.config_file) + "&dstfilename=" + encodeURIComponent(box.config_file) + uri;
-				tmp = new Ajax.Request(box.engine.url, opt);
+				box.stored_config.catbyname[t_pattern1[0]].fields[t_pattern1[1]] = value_one;
+				box.stored_config.catbyname[t_pattern2[0]].fields[t_pattern2[1]] = value_two;
+				
+				reformat_option($('extensions'), b);
+				update_option($('extensions'), a);
+				if (sela)
+					$('extensions').options[b].selected = true;
+				else if (selb)
+					$('extensions').options[a].selected = true;
+				select_item($('extensions'));
 
 		}
 </script>

Modified: trunk/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/scripts/astman.js?rev=10&r1=9&r2=10&view=diff
==============================================================================
--- trunk/config/scripts/astman.js (original)
+++ trunk/config/scripts/astman.js Tue Sep  5 13:11:26 2006
@@ -69,11 +69,39 @@
 	}
 }
 
-
-
-
-
-
+function reformat_option(box, index)
+{
+	var v, tmp, res;
+	var cfg = box.stored_config;
+	
+	v = box.options[index].value;
+	tmp = v.split(']');
+	if (tmp.length > 1) {
+		res = box.callbacks.format(cfg.catbyname[tmp[0]], tmp[1]);
+		if (res)
+			box.options[index].innerHTML = res;
+	} else {
+		res = box.callbacks.format(cfg.catbyname[v]);
+		if (res)
+			box.options[index].innerHTML = res;
+	}
+}
+
+function update_option(box, index)
+{
+	var v, tmp;
+	var cfg = box.stored_config;
+	v = box.options[index].value;
+	tmp = v.split(']');
+	box.remove(index);
+	if (tmp.length > 1) {
+		res = box.callbacks.format(cfg.catbyname[tmp[0]], tmp[1]);
+		insert_option(box, res, tmp[0] + "]" + tmp[1], cfg.catbyname[tmp[0]].subfields[tmp[1]]['name']); 
+	} else {
+		res = box.callbacks.format(cfg.catbyname[v]);
+		insert_option(box, res, cfg.catbyname[v].name, cfg.categories[x].name);
+	}
+}
 
 function update_box(box) {
 	var x,y,z;



More information about the asterisk-gui-commits mailing list