pari: branch 2.0 r4246 - in /branches/2.0/config/js: astman.js sysinfo.js

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Mon Dec 1 15:32:42 CST 2008


Author: pari
Date: Mon Dec  1 15:32:42 2008
New Revision: 4246

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

 Make SystemCmdWithOutput to write to a random file,
 so that the function can be called asynchronously.

 Make loadHtml take an additional callback function argument in async mode



Modified:
    branches/2.0/config/js/astman.js
    branches/2.0/config/js/sysinfo.js

Modified: branches/2.0/config/js/astman.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/astman.js?view=diff&rev=4246&r1=4245&r2=4246
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Mon Dec  1 15:32:42 2008
@@ -1214,12 +1214,19 @@
 		return a instanceof Array || ( a!= null && typeof a=="object" && typeof a.push == "function" && typeof a.concat == "function" )
 	},
 
-	loadHTML: function(u){
+	loadHTML: function(u , cb){
 		// ASTGUI.loadHTML(url)
 		// loads URL 'url' in synchronus mode. note that 'url' is restricted by same origin policy
 		var r =  Math.round(10000*Math.random());
-		var s = $.ajax({ url: u + '?r=' + r , async: false });
-		return s.responseText;
+
+		if( cb && typeof cb == 'function' ) {
+			$.ajax({ url: u + '?r=' + r , async: true, success: function(msg){
+				cb(msg);
+			}});
+		}else{
+			var s = $.ajax({ url: u + '?r=' + r , async: false });
+			return s.responseText;
+		}
 	},
 
 	listSystemFiles : function( dir , cb ){
@@ -2281,12 +2288,16 @@
 		// usage :: ASTGUI.systemCmdWithOutput( 'uptime' , callback(output){ /* do something with output */ } );
 		// Use this function when you want to execute a specific system command and read the output
 		// output will be sent as a argument to the callback function
-		var fcmd = cmd + ' > ' + top.sessionData.directories.guiInstall + ( top.sessionData.directories.output_SysInfo.afterChar('/') || top.sessionData.directories.output_SysInfo ) ;
+		//var fcmd = cmd + ' > ' + top.sessionData.directories.guiInstall +  ;
+		var tmp_opf = ( top.sessionData.directories.output_SysInfo.afterChar('/') || top.sessionData.directories.output_SysInfo ).rChop('.html') + Math.round( 10000 * Math.random() ) + '.html' ;
+		var fcmd = cmd + ' > ' + top.sessionData.directories.guiInstall + tmp_opf ;
+
 		var after = function(){
 			parent.document.getElementById('ajaxstatus').style.display = 'none';
-			var op = ASTGUI.loadHTML( top.sessionData.directories.output_SysInfo ) ;
-			cb( op ) ;
+			ASTGUI.loadHTML( tmp_opf , cb );
+			ASTGUI.systemCmd( 'rm ' + top.sessionData.directories.guiInstall + tmp_opf, function(){});
 		};
+
 		var delay_cb = function(){ setTimeout(after,500); };
 		if( parent.sessionData.PLATFORM.isAA50 ){
 			parent.document.getElementById('ajaxstatus').style.display = '';

Modified: branches/2.0/config/js/sysinfo.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/sysinfo.js?view=diff&rev=4246&r1=4245&r2=4246
==============================================================================
--- branches/2.0/config/js/sysinfo.js (original)
+++ branches/2.0/config/js/sysinfo.js Mon Dec  1 15:32:42 2008
@@ -49,14 +49,19 @@
 
 function getsysinfohtml(){
 	_$('sysinfohtml').innerHTML = ASTGUI.loadHTML(top.sessionData.directories.output_SysInfo);
-	_$('osversion').innerHTML = _$('si_uname').innerHTML;
-	_$('uptime').innerHTML = _$('si_uptime').innerHTML.replace(/load average/, "<BR>Load Average");
+	ASTGUI.systemCmdWithOutput( 'uname -a' , function(output){ _$('osversion').innerHTML = output; });
+	ASTGUI.systemCmdWithOutput( 'uptime' , function(output){ _$('uptime').innerHTML = output.replace(/load average/, "<BR>Load Average"); });
+	ASTGUI.systemCmdWithOutput( 'date' , function(output){ 
+		_$('today').innerHTML = (parent.sessionData.PLATFORM.isAA50) ? ASTGUI.toLocalTime(output).camelize() : output ;
+		if(parent.sessionData.PLATFORM.isAA50) {
+			_$('today').innerHTML += "&nbsp;&nbsp;<A href='date.html' class='splbutton' title='Click to update Date and Time'><B>Edit</B></A>";
+		}
+	});
+	ASTGUI.systemCmdWithOutput( 'hostname' , function(output){ 
+		_$('hostname').innerHTML = output ;
+	});
+
 	_$('asterisk').innerHTML =  parent.sessionData.AsteriskVersionString + "<BR>" + "Asterisk GUI-version : " + ( parent.sessionData.gui_version || ASTGUI.globals.version ) ;
-	_$('today').innerHTML = (parent.sessionData.PLATFORM.isAA50) ? ASTGUI.toLocalTime(_$('si_date').innerHTML).camelize() : _$('si_date').innerHTML ;
-	if(parent.sessionData.PLATFORM.isAA50) {
-		_$('today').innerHTML += "&nbsp;&nbsp;<A href='date.html' class='splbutton' title='Click to update Date and Time'><B>Edit</B></A>";
-	}
-	_$('hostname').innerHTML =_$('si_hostname').innerHTML;
 	$('#tabbedMenu').find('A:eq(0)').click();
 }
 
@@ -139,5 +144,6 @@
 		}
 		ASTGUI.tabbedOptions( _$('tabbedMenu') , t );
 	})();
-	parent.ASTGUI.systemCmd( top.sessionData.directories.script_SysInfo, function(){ parent.ASTGUI.dialog.hide(); getsysinfohtml(); } );
+	parent.ASTGUI.dialog.hide();
+	getsysinfohtml();
 }




More information about the asterisk-gui-commits mailing list