pari: trunk r382 - in /trunk/config: numberplan.html scripts/astman.js

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Mon Feb 26 22:47:42 MST 2007


Author: pari
Date: Mon Feb 26 23:47:41 2007
New Revision: 382

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=382
Log:
using toJSON() instead of config2list 

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?view=diff&rev=382&r1=381&r2=382
==============================================================================
--- trunk/config/numberplan.html (original)
+++ trunk/config/numberplan.html Mon Feb 26 23:47:41 2007
@@ -38,14 +38,7 @@
 var iscustom ;
 var pattern_beingedited ;
 var pattern_beingedited_priority ;
-var oldselect;
 var np_oldselect;
-
-function hackenablesave(){
-	if( oldselect != $('trunks').value ){
-		enablesave();
-	}
-}
 
 function ownpattern(){
 		iscustom = true;
@@ -408,7 +401,7 @@
 function editcallingrule(a,b){	// a is pattern, b is priority
 		pattern_beingedited = a ;
 		pattern_beingedited_priority = b ;
-		oldselect = $('trunks').value;
+//		oldselect = $('trunks').value;
 		isnewrule = false ;
 		var m = numberplansdata[$('extensions').value]['npdata'];
 		$('rulename').value = m[a][b].rulename;
@@ -539,28 +532,6 @@
 numplan_callbacks.eachline = true;
 numplan_callbacks.includecats = true;
 
-trunkcallbacks.format = function(t) {
-	//if (t.name.substr(0,6) != 'trunk_')
-	//	return null;
-	if ( t.fieldbyname['context'] != asterisk_guiTDPrefix + t.name ) {
-		return null;
-	}
-	if (t.fieldbyname['trunkname'] && t.fieldbyname['trunkname'].length) {
-		trunks_desc[t.name] = new Object();
-		trunks_desc[t.name].comment = t.fieldbyname['trunkname'] ;
-		return t.fieldbyname['trunkname'];
-	} else{
-		trunks_desc[t.name] = new Object();
-		trunks_desc[t.name].comment = t.name ;
-		return t.name;
-	}
-}
-
-trunkcallbacks.loaded = function(){
-	add_event( $('trunks') , 'click', hackenablesave ) ;
-	parent.astmanEngine.config2list("extensions.conf", $('extensions'), widgets , numplan_callbacks);
-}
-
 function localajaxinit(){
 	showdiv_statusmessage();
 	setWindowTitle("Calling Rules");
@@ -573,7 +544,21 @@
 		$(focus_fields[x]).onblur = function(){this.className = 'input9';}
 	}
 	$('message_text').innerHTML ="Saving Changes...";
-	parent.astmanEngine.config2list("users.conf", $('trunks'), new Array(), trunkcallbacks);
+
+	config2json('users.conf', 1, trunks_loaded ) ;
+	//parent.astmanEngine.config2list("users.conf", $('trunks'), new Array(), trunkcallbacks);
+}
+
+function trunks_loaded(b){
+	var c = eval('(' + b + ')');
+	for( var d in c ){
+		if ( c.hasOwnProperty(d) && c[d]['context'] && (c[d]['context'] == asterisk_guiTDPrefix + d ) ) {
+				trunks_desc[d] = new Object();
+				trunks_desc[d].comment = (c[d]['trunkname']) ? c[d]['trunkname'] : d ;
+				$('trunks').innerHTML += "<option value='" + d + "'>" + trunks_desc[d].comment +"</option>";
+		}
+	}
+	parent.astmanEngine.config2list("extensions.conf", $('extensions'), widgets , numplan_callbacks);
 }
 
 function select_differentplan(){
@@ -696,7 +681,7 @@
 		</TR>
 		<TR>
 			<TD  align="right" height=40> Place this call through :</TD>
-			<TD><select id="trunks"  class="input9"></select></TD>
+			<TD><select id="trunks"  class="input9" onChange="enablesave();"></select></TD>
 		</TR>
 		<TR id="define_usual" height=100>
 			<TD valign="top" align=right>Dialing Rules :</TD>

Modified: trunk/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/scripts/astman.js?view=diff&rev=382&r1=381&r2=382
==============================================================================
--- trunk/config/scripts/astman.js (original)
+++ trunk/config/scripts/astman.js Mon Feb 26 23:47:41 2007
@@ -46,6 +46,14 @@
 	}else if(a.detachEvent){
 		a.detachEvent("on"+b, c);
 	}
+}
+
+function config2json(a, b, c){		// a is filename (string) , b is 0 or 1 , c is callback function
+	var opt = { method: 'get', asynchronous: true,
+		onSuccess: function(originalRequest) {  var f = toJSON(originalRequest.responseText, b) ;  c(f) ; },
+		onFailure: function(t) { alert("Config Error: " + t.status + ": " + t.statusText); },
+		parameters: "action=getconfig&filename="+a };
+	var tmp = new Ajax.Request("../../rawman", opt);
 }
 
 function toJSON(z, p){
@@ -1689,9 +1697,7 @@
 		me.eventcallback(msgs);
 	};
 	this.eventResponse = function(t) {
-		if( t.responseText.match("Message: Authentication Required") ){
-				parent.window.onbeforeunload = function(){ }
-				parent.window.onunload = function(){ }				
+		if( t.responseText.match("Message: Authentication Required") ){		
 				parent.window.location.href = parent.window.location.href ;
 		}
 		if( navigator.userAgent.indexOf("MSIE") != -1 || navigator.userAgent.indexOf("Konqueror") != -1 || navigator.userAgent.indexOf("Safari") != -1 || navigator.userAgent.indexOf("Opera") != -1){



More information about the asterisk-gui-commits mailing list