rbrindley: branch rbrindley/welcome_revamp r4237 - /team/rbrindley/welcome_re...

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Sat Nov 29 01:08:17 CST 2008


Author: rbrindley
Date: Sat Nov 29 01:08:16 2008
New Revision: 4237

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

- converted loadExtensions function to use jQuery and the new pushRow func


Modified:
    team/rbrindley/welcome_revamp/config/js/welcome2.js

Modified: team/rbrindley/welcome_revamp/config/js/welcome2.js
URL: http://svn.digium.com/view/asterisk-gui/team/rbrindley/welcome_revamp/config/js/welcome2.js?view=diff&rev=4237&r1=4236&r2=4237
==============================================================================
--- team/rbrindley/welcome_revamp/config/js/welcome2.js (original)
+++ team/rbrindley/welcome_revamp/config/js/welcome2.js Sat Nov 29 01:08:16 2008
@@ -162,81 +162,74 @@
 };
 
 var loadExtensions = function() {
-	var TBL = _$('extensions_list');
-	var addCell = ASTGUI.domActions.tr_addCell; // temporarily store the function
-
-	(function(){ // List all User Extensions
-		var ul = parent.astgui_manageusers.listOfUsers();
-		ul = ul.sortNumbers( );
-		ul.each(function(user){ // list each user in table
-			var ud = parent.sessionData.pbxinfo.users[user];
-			//var newRow = TBL.insertRow(-1);
-
-			var tmp_usertype_a = [];
-
-			if( ud.getProperty('hassip').isAstTrue() ){ tmp_usertype_a.push( ' SIP User' ) ; }
-			if( ud.getProperty('hasiax').isAstTrue() ){ tmp_usertype_a.push( ' IAX User' ) ; }
-			if( ud.getProperty('hassip').isAstTrue() && ud.getProperty('hasiax').isAstTrue() ){ tmp_usertype_a = [ 'SIP/IAX User' ] ; }
-			if( ud.getProperty('zapchan') ){
-				tmp_usertype_a.push( 'Analog User (Port ' + ud['zapchan'] + ')' ) ;
-			}
-
-			var tmp_mails = ASTGUI.mailboxCount(user);
-			if( tmp_mails.count_new > 0 ){
-				var tmp_mails_str = '<font color=#888B8D> Messages : <B><font color=red>' + tmp_mails.count_new + '</font>/' + tmp_mails.count_old + '</B></font>' ;
-			}else{
-				var tmp_mails_str = '<font color=#888B8D> Messages : ' + tmp_mails.count_new + '/' + tmp_mails.count_old + '</font>' ;
-			}
-
-			//newRow.className = (( TBL.rows.length)%2==1)?'odd':'even';
-			$("<tr></tr>").appendTo("#extensions_list tbody");
-
-				if( !ud.getProperty('context') || ! parent.sessionData.pbxinfo.callingPlans[ud.getProperty('context')] ){
-					var tmp_userstring = '<u>' + user + '</u> <font color=red>*No DialPlan assigned</font>' ;
-				}else{
-					var tmp_userstring = '<u>' + user + '</u>' ;
-				}
-
-				//addCell( newRow , { html: ASTGUI.getUser_DeviceStatus_Image(user) , id : 'TD_USER_DEVICE_STATUS_' + user } );
-				$("<td></td>").appendTo("#extensions_list tbody tr:last").html(ASTGUI.getUser_DeviceStatus_Image(user)).attr("id","TD_USER_DEVICE_STATUS_"+user);
-				$("<td></td>").appendTo("#extensions_list tbody tr:last").html(tmp_userstring);
-				//addCell( newRow ,
-				//	{	html: tmp_userstring ,
-				//		onclickFunction: function(){
-				//			parent.miscFunctions.click_panel( 'users.html', 'users.html?EXTENSION_EDIT=' + user );
-				//		}
-				//	}
-				//);
-
-				//addCell( newRow , { html: ud.getProperty('fullname') } );
-				$("<td></td>").appendTo("#extensions_list tbody tr:last").html(ud.getProperty('fullname'));
-				//addCell( newRow , { html: tmp_mails_str } );
-				$("<td></td>").appendTo("#extensions_list tbody tr:last").html(tmp_mails_str);
-				//addCell( newRow , { html: tmp_usertype_a.join(',&nbsp;') } );
-				$("<td></td>").appendTo("#extensions_list tbody tr:last").html(tmp_usertype_a.join(',&nbsp;'));
-		});
-	})();
+
+	/* List all User Extensions */
+	var exten_tbody = $("#extensions_list > tbody");
+	var ul = parent.astgui_manageusers.listOfUsers();
+	ul = ul.sortNumbers( );
+	ul.each(function(user){ // list each user in table
+		var ud = parent.sessionData.pbxinfo.users[user];
+		var tmp_usertype_a = [];
+
+		if( ud.getProperty('hassip').isAstTrue() && ud.getProperty('hasiax').isAstTrue() ) {
+			tmp_usertype_a.push( 'SIP/IAX User' );
+		} else if ( ud.getProperty('hasiax').isAstTrue() ) {
+			tmp_usertype_a.push( '&nbsp;IAX User' );
+		} else if ( ud.getProperty('hassip').isAstTrue() ) {
+			tmp_usertype_a.push( '&nbsp;SIP User' );
+		} else if( ud.getProperty('zapchan') ) {
+			tmp_usertype_a.push( 'Analog User (Port ' + ud['zapchan'] + ')' ) ;
+		}
+
+		var tmp_mails = ASTGUI.mailboxCount(user);
+		if( tmp_mails.count_new > 0 ){
+			var tmp_mails_str = '<font color=#888B8D> Messages : <B><font color=red>' + tmp_mails.count_new + '</font>/' + tmp_mails.count_old + '</B></font>' ;
+		}else{
+			var tmp_mails_str = '<font color=#888B8D> Messages : ' + tmp_mails.count_new + '/' + tmp_mails.count_old + '</font>' ;
+		}
+
+		if( !ud.getProperty('context') || ! parent.sessionData.pbxinfo.callingPlans[ud.getProperty('context')] ){
+			var tmp_userstring = '<u>' + user + '</u> <font color=red>*No DialPlan assigned</font>' ;
+		}else{
+			var tmp_userstring = '<u>' + user + '</u>' ;
+		}
+
+		pushRow(exten_tbody, [
+			$("<td></td>").html(ASTGUI.getUser_DeviceStatus_Image(user)).attr("id","TD_USER_DEVICE_STATUS_"+user),
+			$("<td></td>").html(tmp_userstring),
+			$("<td></td>").html(ud.getProperty('fullname')),
+			$("<td></td>").html(tmp_mails_str),
+			$("<td></td>").html(tmp_usertype_a.join(',&nbsp;'))
+		]);
+		//addCell( newRow ,
+		//	{	html: tmp_userstring ,
+		//		onclickFunction: function(){
+		//			parent.miscFunctions.click_panel( 'users.html', 'users.html?EXTENSION_EDIT=' + user );
+		//		}
+		//	}
+		//);
+	});
 
 	(function(){ // List all Queue Extensions
 		var QUEUES_CONF = config2json({filename:'queues.conf', usf:1});
 		var m = parent.sessionData.pbxinfo.queues ;
 		for( l in m ){
 			if( m.hasOwnProperty(l) ){
-				var newRow = TBL.insertRow(-1);
-				newRow.className = (( TBL.rows.length)%2==1)?'odd':'even';
-				addCell( newRow , { html:''} );
-				addCell( newRow , { html: l } );
-				addCell( newRow , { html: QUEUES_CONF[l] && QUEUES_CONF[l]['fullname'] || '--' }); // Label
 				if( m[l]['configLine'].contains(',1,agentlogin()') ){
-					addCell( newRow , { html: '' } );
-					addCell( newRow , { html: '<B>Agent Login</B>' });
+					var exten = "<b>Agent Login</b>";
 				}else if( m[l]['configLine'].contains(',1,agentcallbacklogin()') ){
-					addCell( newRow , { html: '' } );
-					addCell( newRow , { html: '<B>Agent CallBack Login</B>' });	
+					var exten = "<b>Agent CallBack Login</b>";
 				}else{
-					addCell( newRow , { html: '' } );
-					addCell( newRow , { html: 'Call Queue' } );
+					var exten = "Call Queue";
 				}
+
+				pushRow(exten_tbody, [
+					$("<td></td>").html(''),
+					$("<td></td>").html(l),
+					$("<td></td>").html( QUEUES_CONF[l] && QUEUES_CONF[l]['fullname'] || '--' ),
+					$("<td></td>").html(''),
+					$("<td></td>").html( exten )
+				]);
 			}
 		}
 	})();
@@ -244,26 +237,26 @@
 	(function(){ // List all RingGroup Extensions
 		var c = parent.sessionData.pbxinfo.ringgroups ;
 		for(var d in c){if(c.hasOwnProperty(d)){
-			var newRow = TBL.insertRow(-1);
-			newRow.className = (( TBL.rows.length)%2==1)?'odd':'even';
-			addCell( newRow , { html: '' } );
-			addCell( newRow , { html: c[d]['extension'] || '--' } );
-			addCell( newRow , { html: c[d]['NAME'] || d } );
-			addCell( newRow , { html: '' } );
-			addCell( newRow , { html: 'Ring Group' } );
+			pushRow(exten_tbody, [
+				$("<td></td>").html(''),
+				$("<td></td>").html(c[d]['extensions'] || '--'),
+				$("<td></td>").html(c[d]['NAME'] || d),
+				$("<td></td>").html(''),
+				$("<td></td>").html('Ring Group')
+			]);
 		}}
 	})();
 
 	(function(){ // List all VoiceMenu Extensions
 		var c = parent.sessionData.pbxinfo.voicemenus ;
 		for(var d in c){if(c.hasOwnProperty(d)){
-			var newRow = TBL.insertRow(-1);
-			newRow.className = (( TBL.rows.length)%2==1)?'odd':'even';
-			addCell( newRow , { html: '' } );
-			addCell( newRow , { html: ASTGUI.parseContextLine.getExten(c[d].getProperty('alias_exten')) || '--' } );
-			addCell( newRow , { html: c[d]['comment'] || d } );
-			addCell( newRow , { html: '' } );
-			addCell( newRow , { html: 'Voice Menu' } );
+			pushRow(exten_tbody, [
+				$("<td></td>").html(''),
+				$("<td></td>").html(ASTGUI.parseContextLine.getExten(c[d].getProperty('alias_exten')) || '--'),
+				$("<td></td>").html(c[d]['comment'] || d),
+				$("<td></td>").html(''),
+				$("<td></td>").html('Voice Menu'),
+			]);
 		}}
 	})();
 
@@ -272,9 +265,6 @@
 		if( parent.sessionData.pbxinfo['localextensions'].hasOwnProperty('VoiceMailMain') ){
 			tmp = ASTGUI.parseContextLine.getExten( parent.sessionData.pbxinfo['localextensions']['VoiceMailMain'] ) ;
 		}
-		var newRow = TBL.insertRow(-1);
-		newRow.className = (( TBL.rows.length)%2==1)?'odd':'even';
-		addCell( newRow , { html: '' } );
 
 		if( tmp ){
 			var tmp_voicemails = '<u>' + tmp + '</u>' ;
@@ -282,50 +272,55 @@
 			var tmp_voicemails = '-- <font color=red>*No Extension assigned</font>' ;
 		}
 
-		addCell( newRow ,
-			{	html: tmp_voicemails ,
-				onclickFunction: function(){
-					parent.miscFunctions.click_panel( 'voicemail.html');
-				}
-			}
-		);
-		addCell( newRow , { html: '<B>Check Voicemails</B>' } );
-		addCell( newRow , { html: '' } );
-		addCell( newRow , { html: 'VoiceMailMain' } );
-	})();
+		pushRow(exten_tbody, [
+			$("<td></td>").html(''),
+			$("<td></td>").html(tmp_voicemails),
+			$("<td></td>").html('<b>Check Voicemails</b>'),
+			$("<td></td>").html(''),
+			$("<td></td>").html('VoiceMailMain'),
+		]);
+	//	addCell( newRow ,
+	//		{	html: tmp_voicemails ,
+	//			onclickFunction: function(){
+	//				parent.miscFunctions.click_panel( 'voicemail.html');
+	//			}
+	//		}
+	//	);
+	})();
+
 	(function(){ // VoiceMail Groups
 		var vmgroups = parent.sessionData.pbxinfo.vmgroups.getOwnProperties();
 		vmgroups.each(function( this_vmg_exten ){
-			var newRow = TBL.insertRow(-1);
-			newRow.className = (( TBL.rows.length)%2==1)?'odd':'even';
-			addCell( newRow , { html: '' } );
-			addCell( newRow , { html: this_vmg_exten });
-			addCell( newRow , { html: parent.sessionData.pbxinfo.vmgroups[this_vmg_exten].getProperty('label')  });
-			addCell( newRow , { html: '' } );
-			addCell( newRow , { html: 'VoiceMail Group' } );
+			pushRow(exten_tbody, [
+				$("<td></td>").html(''),
+				$("<td></td>").html(this_vmg_exten),
+				$("<td></td>").html(parent.sessionDate.pbxinfo.vmgroups[this_vmg_exten].getProperty('label')),
+				$("<td></td>").html(''),
+				$("<td></td>").html('VoiceMail Group')
+			]);
 		});
 	})();
 
 	(function(){
-		var newRow = TBL.insertRow(-1);
-		newRow.className = (( TBL.rows.length)%2==1)?'odd':'even';
-		addCell( newRow , { html: '' });
-
 		var tmp = parent.sessionData.pbxinfo['localextensions'].getProperty('defaultDirectory') ;
 		if( tmp ){
 			var tmp_dirExten = '<u>' + tmp + '</u>' ;
 		}else{
 			var tmp_dirExten = '-- <font color=red>*No Extension assigned</font>' ;
 		}
-
-		addCell( newRow ,
-			{	html: tmp_dirExten ,
-				onclickFunction: function(){ parent.miscFunctions.click_panel( 'directory.html'); }
-			}
-		);
-		addCell( newRow , { html: '<B>Dial by Names</B>' } );
-		addCell( newRow , { html: '' } );
-		addCell( newRow , { html: 'Directory' } );
+		
+		pushRow(exten_tbody, [
+			$("<td></td>").html(''),
+			$("<td></td>").html(tmp_dirExten),
+			$("<td></td>").html('<b>Dial by Names</b>'),
+			$("<td></td>").html(''),
+			$("<td></td>").html('Directory')
+		]);
+	//	addCell( newRow ,
+	//		{	html: tmp_dirExten ,
+	//			onclickFunction: function(){ parent.miscFunctions.click_panel( 'directory.html'); }
+	//		}
+	//	);
 	})();
 
 	$("#extensions_list tbody tr:odd").removeClass("even").addClass("odd"); 	//removing classes to
@@ -356,15 +351,17 @@
 				return;
 			}
 
-			pushRow( plot_tbody, array {
-				chunk.CallerID,
-				chunk.Channel,
-				chunk.Exten
-			});
+			pushRow(plot_tbody, [
+				$("<td></td>").html(chunk.CallerID),
+				$("<td></td>").html(chunk.Channel),
+				$("<td></td>").html(chunk.Exten)
+			]);
 		});
 
 		if( $("#parking_lot_list > tbody > tr").length < 1 ) {
-			pushRow( plot_tbody, array {"No Parked Calls"});
+			pushRow(plot_tbody, [
+				$("<td></td>").html("No Parked Calls")
+			]);
 		}
 	});
 };
@@ -372,9 +369,8 @@
 var pushRow = function(tbody, cells) {
 	var new_row = $("<tr></tr>");
 	for (var i=0; i < cells.length; i++) {
-		$("<td></td>").html(cells[i]).appendTo(new_row);
+		cells[i].appendTo(new_row);
 	}
-
 	new_row.appendTo(tbody);
 };
 




More information about the asterisk-gui-commits mailing list