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

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Tue May 15 18:22:40 MST 2007


Author: pari
Date: Tue May 15 20:22:39 2007
New Revision: 941

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=941
Log:
I forgot what my original plans were - but just realised there is no point in converting an object to string and then back to an object. So - toJSON (which returned a string)  is replaced by toJSO(which returns an object)

Modified:
    trunk/config/feditor.html
    trunk/config/numberplan.html
    trunk/config/scripts/astman.js
    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=941&r1=940&r2=941
==============================================================================
--- trunk/config/feditor.html (original)
+++ trunk/config/feditor.html Tue May 15 20:22:39 2007
@@ -289,7 +289,7 @@
 
 	//alert(b);
 	var zz = _$('file_output');
-	var c = eval('(' + b + ')');
+	var c = b;
 	var p = "";
 	var rows ;
 

Modified: trunk/config/numberplan.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/numberplan.html?view=diff&rev=941&r1=940&r2=941
==============================================================================
--- trunk/config/numberplan.html (original)
+++ trunk/config/numberplan.html Tue May 15 20:22:39 2007
@@ -567,7 +567,7 @@
 }
 
 function trunks_loaded(b){
-	var c = eval('(' + b + ')');
+	var c = b ;
 	for( var d in c ){
 		if ( c.hasOwnProperty(d) && c[d]['context'] && (c[d]['context'] == asterisk_guiTDPrefix + d ) ) {
 			trunks_desc[d] = new Object();

Modified: trunk/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/scripts/astman.js?view=diff&rev=941&r1=940&r2=941
==============================================================================
--- trunk/config/scripts/astman.js (original)
+++ trunk/config/scripts/astman.js Tue May 15 20:22:39 2007
@@ -135,14 +135,14 @@
 
 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) ; },
+		onSuccess: function(originalRequest) {  var f = toJSO(originalRequest.responseText, b) ;  c(f) ; },
 		onFailure: function(t) { gui_alert("Config Error: " + t.status + ": " + t.statusText); },
 		parameters: "action=getconfig&filename="+a };
 	var tmp = new Ajax.Request(asterisk_rawmanPath , opt);
 }
 
-function toJSON(z, p){
-	// This function converts z,  the asterisk config file as read using 'action=getconfig' to a JSON string 
+function toJSO(z, p){
+	// This function converts z,  the asterisk config file as read using 'action=getconfig' to a JavaScript Object 
 	// where z is originalRequest.responseText of the getconfig on a asterisk format config file, 
 	// and p is 0 or 1, 
 	//	 0 for non unique subfields ( extensions.conf context where there are multiple subfields with same name - -  Ex: 'exten ='   )
@@ -159,59 +159,27 @@
 			var g = t[r].indexOf(":") ; 
 			var catname = t[r].substr(g+1) ; // catogory 
 			catname = catname.replace(/^\s*|\s*$/g,'') ; // trim 
-			a[ catno ] = { };
-			a[ catno ].categoryname = catname  ;
-			if(!p)
-				a[ catno ].subfields = [] ;
-			else
-				a[ catno ].subfields = {} ;
+			if(!p){
+				a[catname] = [];
+			}else{
+				a[catname] = {};
+			}
 		}else if ( h == "line" ){
 			var j = t[r].indexOf(":") ;
 			var subfield = t[r].substr(j+1) ; // subfield
 			subfield = subfield.replace(/^\s*|\s*$/g,'') ; // trim 
-			if( !p){
-				a[ catno ].subfields.push( subfield ) ;
+
+			if(!p){
+				a[catname].push(subfield);
 			}else{
 				var v = subfield.indexOf("=");
-				var subfield_a = subfield.substring(0,v); // subfield variable
-				var subfield_b =  subfield.substr(v+1) ; // subfield variable value
-				a[ catno ].subfields[subfield_a] = subfield_b;
-			}
-		}
-	}
-	// start building the json string
-	json_data = "{" ;
-	if(!p){
-		for( var s=0; s < a.length; s++ ){
-			var b = a[s].subfields ;
-			json_data += '"' + a[s].categoryname + '" : [ ' ;
-			for ( var y = 0 ;  y < b.length ;  y++ ){
-				json_data += '"' + escape(b[y]) + '"' ;
-				if( y < b.length - 1 ){	json_data += ',' ;	}
-			}
-			if( s < a.length - 1 ){ json_data += ' ],' ; }else{ json_data += ' ]}' ; }
-		}
-	}else{
-		for( var s=0; s < a.length; s++ ){
-			var b = a[s].subfields ;
-			json_data += '"' + a[s].categoryname + '" :  {' ;
-			var hascomma = 0;
-			for ( var y in b ){ 
-				if ( b.hasOwnProperty(y) ){ 
-					if(hascomma){
-						json_data += ', "' + y + '":"' + escape(b[y]) + '"' ; 
-					}else{
-						json_data += '"' + y + '":"' + escape(b[y]) + '"' ; 
-						hascomma = 1;
-					}
-				} 
-			}
-			if( s < a.length - 1 ){ json_data += ' },' ; }else{ json_data += ' }}' ; }
-		}
-	}
-	if(json_data == "{"){ return '{}';}
-	// done building the json string
-	return json_data ;
+				var subfield_a = subfield.substring(0,v);//subfield variable
+				var subfield_b =  subfield.substr(v+1) ;//subfield variable value
+				a[catname][subfield_a] = subfield_b;
+			}
+		}
+	}
+	return a ;
 }
 
 function setWindowTitle(a){

Modified: trunk/config/timerules.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/timerules.html?view=diff&rev=941&r1=940&r2=941
==============================================================================
--- trunk/config/timerules.html (original)
+++ trunk/config/timerules.html Tue May 15 20:22:39 2007
@@ -83,7 +83,7 @@
 
 
 function get_users(m){
-	var n = eval('(' + m + ')');
+	var n =  m ;
 	var l;
 
 	for( l in n ){
@@ -107,7 +107,7 @@
 
 function get_timerules(b){
 	var c,d,e,t,p,q;
-	c = eval('(' + b + ')');
+	c =  b ;
 	var found = 0;
 	for( d in c ){
 		if(c.hasOwnProperty(d)){

Modified: trunk/config/users.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/users.html?view=diff&rev=941&r1=940&r2=941
==============================================================================
--- trunk/config/users.html (original)
+++ trunk/config/users.html Tue May 15 20:22:39 2007
@@ -194,7 +194,7 @@
 }
 
 function analoglines_loaded(b){
-	var c = eval('(' + b + ')');
+	var c = b ;
 	var _zapchan = _$('zapchan') ;
 
 	for( var d in c ){
@@ -224,7 +224,7 @@
 }
 
 function dialplans_loaded(b){
-	var c = eval('(' + b + ')');
+	var c =  b ;
 	var _context = _$('context') ;
 
 	for( var d in c ){



More information about the asterisk-gui-commits mailing list