package/ui/phpvirtualbox/js/dialogs.js
/**
 * Show the port forwarding configuration dialog
 * @param {Array} rules - list of port forwarding rules to process
 * @returns {Object} deferred promise
 */
Show the port forwarding configuration dialog
@param {Array} rules - list of port forwarding rules to process
@returns {Object} deferred promise
Show the port forwarding configuration dialog @param { Array } rules - list of port forwarding rules to process @returns { Object } deferred promise
function vboxPortForwardConfigDialog(rules) {
	var results = $.Deferred();
	var l = new vboxLoader();
	l.addFileToDOM("panes/settingsPortForwarding.html");
	l.onLoad = function(){
		vboxSettingsPortForwardingInit(rules);
		var resizeTable = function() {
			var h = $('#vboxSettingsPortForwarding').children('table').hide().parent().innerHeight() - 16;
			$('#vboxSettingsPortForwarding').children('table').css({'height':h+'px'}).show();
			$('#vboxSettingsPortForwardingListDiv').css({'height':(h-6)+'px','overflow':'auto'});
		};
		var buttons = {};
		buttons[trans('OK','QIMessageBox')] = function(){
			var rules = $('#vboxSettingsPortForwardingList').children('tr');
			var rulesToPass = new Array();
			for(var i = 0; i < rules.length; i++) {
				if($(rules[i]).data('vboxRule')[3] == 0 || $(rules[i]).data('vboxRule')[5] == 0) {
					vboxAlert(trans("The current port forwarding rules are not valid. " +
				               "None of the host or guest port values may be set to zero.",'UIMessageCenter'));
					return;
				}
				rulesToPass[i] = $(rules[i]).data('vboxRule');
			}
			$(this).trigger('close').empty().remove();
			results.resolve(rulesToPass);
		};
		buttons[trans('Cancel','QIMessageBox')] = function(){
			results.reject();
			$(this).trigger('close').empty().remove();
		};
		$('#vboxSettingsPortForwarding').dialog({'closeOnEscape':true,'width':600,'height':400,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/nw_16px.png" class="vboxDialogTitleIcon" /> ' + trans('Port Forwarding Rules','UIMachineSettingsPortForwardingDlg')}).on("dialogbeforeclose",function(){
	    	$(this).parent().find('span:contains("'+trans('Cancel','QIMessageBox')+'")').trigger('click');
	    }).on('dialogresizestop',resizeTable);
		resizeTable();
	};
	l.run();
	return results.promise();
}
function vboxPortForwardConfigDialog ( rules ) { var results = $ . Deferred ( ) ; var l = new vboxLoader ( ) ; l . addFileToDOM ( "panes/settingsPortForwarding.html" ) ; l . onLoad = function ( ) { vboxSettingsPortForwardingInit ( rules ) ; var resizeTable = function ( ) { var h = $ ( '#vboxSettingsPortForwarding' ) . children ( 'table' ) . hide ( ) . parent ( ) . innerHeight ( ) - 16 ; $ ( '#vboxSettingsPortForwarding' ) . children ( 'table' ) . css ( { 'height' : h + 'px' } ) . show ( ) ; $ ( '#vboxSettingsPortForwardingListDiv' ) . css ( { 'height' : ( h - 6 ) + 'px' , 'overflow' : 'auto' } ) ; } ; var buttons = { } ; buttons [ trans ( 'OK' , 'QIMessageBox' ) ] = function ( ) { var rules = $ ( '#vboxSettingsPortForwardingList' ) . children ( 'tr' ) ; var rulesToPass = new Array ( ) ; for ( var i = 0 ; i < rules . length ; i ++ ) { if ( $ ( rules [ i ] ) . data ( 'vboxRule' ) [ 3 ] == 0 || $ ( rules [ i ] ) . data ( 'vboxRule' ) [ 5 ] == 0 ) { vboxAlert ( trans ( "The current port forwarding rules are not valid. " + "None of the host or guest port values may be set to zero." , 'UIMessageCenter' ) ) ; return ; } rulesToPass [ i ] = $ ( rules [ i ] ) . data ( 'vboxRule' ) ; } $ ( this ) . trigger ( 'close' ) . empty ( ) . remove ( ) ; results . resolve ( rulesToPass ) ; } ; buttons [ trans ( 'Cancel' , 'QIMessageBox' ) ] = function ( ) { results . reject ( ) ; $ ( this ) . trigger ( 'close' ) . empty ( ) . remove ( ) ; } ; $ ( '#vboxSettingsPortForwarding' ) . dialog ( { 'closeOnEscape' : true , 'width' : 600 , 'height' : 400 , 'buttons' : buttons , 'modal' : true , 'autoOpen' : true , 'dialogClass' : 'vboxDialogContent' , 'title' : '<img src="images/vbox/nw_16px.png" class="vboxDialogTitleIcon" /> ' + trans ( 'Port Forwarding Rules' , 'UIMachineSettingsPortForwardingDlg' ) } ) . on ( "dialogbeforeclose" , function ( ) { $ ( this ) . parent ( ) . find ( 'span:contains("' + trans ( 'Cancel' , 'QIMessageBox' ) + '")' ) . trigger ( 'click' ) ; } ) . on ( 'dialogresizestop' , resizeTable ) ; resizeTable ( ) ; } ; l . run ( ) ; return results . promise ( ) ; }
Show the port forwarding configuration dialog
 @param {Array} rules - list of port forwarding rules to process
 @returns {Object} deferred promise
Show the port forwarding configuration dialog @param { Array } rules - list of port forwarding rules to process @returns { Object } deferred promise
// Get rules
