package/ui/phpvirtualbox/js/utils.js
/**
 * Display alert Dialog
 * @param {String|Object} e - message to display or object containing error message and details
 * @param {Object} xtraOpts - extra options to apply to alert jquery dialog (optional)
 * @see jQuery.dialog()
 */
Display alert Dialog
@param {String|Object} e - message to display or object containing error message and details
@param {Object} xtraOpts - extra options to apply to alert jquery dialog (optional)
@see jQuery.dialog()
Display alert Dialog @param { String|Object } e - message to display or object containing error message and details @param { Object } xtraOpts - extra options to apply to alert jquery dialog ( optional ) @see jQuery . dialog ()
function vboxAlert(e,xtraOpts) {
    var acknowledged = $.Deferred();
	var msg = '';
	if(typeof e == 'object') msg = e.error;
	else msg = e;
	if(msg[0] != '<') msg = '<p>'+msg+'</p>';
	var div = $('<div />').attr({'class':'vboxDialogContent vboxAlert'}).html('<img src="images/50px-Warning_icon.svg.png" style="float: left; padding: 10px; height: 50px; width: 50px;" height="50" width="50" />'+msg);
	if(typeof e == 'object' && e.details) {
		e.details = $('<div />').html(e.details).text();
		var p = $('<p />').attr({'style':'text-align: center'});
		$('<a />').attr({'href':'#'}).html(trans('Details','QIMessageBox')).click(function(){
			$(this).parent().parent().dialog('option',{'height':400,'position':'center'});
			$(this).parent().siblings(".vboxAlert").css({"display":""});
			$(this).parent().css({'padding':'0px','margin':'0px'});
			$(this).parent().siblings(".vboxAlert").siblings().empty().remove();
			return false;
		}).appendTo(p);
		$(div).append(p);
		var ddet = $('<div />').attr({'style':'display: none; height: 100%; width: auto;','class':'vboxAlert'});	
		$('<textarea />').attr({'spellcheck':'false','wrap':'off','readonly':'true'}).val(e.details).appendTo($('<form />').appendTo(ddet));	
		$(div).append(ddet);
	}
	var buttons = { };
	buttons[trans('OK','QIMessageBox')] = function(f) {
	    $(this).trigger('close').empty().remove();
	    acknowledged.resolve();
	};
	var dialogOpts = {'closeOnEscape':false,'width':600,'height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/OSE/about_16px.png" class="vboxDialogTitleIcon" /> phpVirtualBox'};
	if(typeof xtraOpts == "object") {
		for(var i in xtraOpts) {
			dialogOpts[i] = xtraOpts[i];
		}
	}
	$(div).dialog(dialogOpts);
    return acknowledged;
}
function vboxAlert ( e , xtraOpts ) { var acknowledged = $ . Deferred ( ) ; var msg = '' ; if ( typeof e == 'object' ) msg = e . error ; else msg = e ; if ( msg [ 0 ] != '<' ) msg = '<p>' + msg + '</p>' ; var div = $ ( '<div />' ) . attr ( { 'class' : 'vboxDialogContent vboxAlert' } ) . html ( '<img src="images/50px-Warning_icon.svg.png" style="float: left; padding: 10px; height: 50px; width: 50px;" height="50" width="50" />' + msg ) ; if ( typeof e == 'object' && e . details ) { e . details = $ ( '<div />' ) . html ( e . details ) . text ( ) ; var p = $ ( '<p />' ) . attr ( { 'style' : 'text-align: center' } ) ; $ ( '<a />' ) . attr ( { 'href' : '#' } ) . html ( trans ( 'Details' , 'QIMessageBox' ) ) . click ( function ( ) { $ ( this ) . parent ( ) . parent ( ) . dialog ( 'option' , { 'height' : 400 , 'position' : 'center' } ) ; $ ( this ) . parent ( ) . siblings ( ".vboxAlert" ) . css ( { "display" : "" } ) ; $ ( this ) . parent ( ) . css ( { 'padding' : '0px' , 'margin' : '0px' } ) ; $ ( this ) . parent ( ) . siblings ( ".vboxAlert" ) . siblings ( ) . empty ( ) . remove ( ) ; return false ; } ) . appendTo ( p ) ; $ ( div ) . append ( p ) ; var ddet = $ ( '<div />' ) . attr ( { 'style' : 'display: none; height: 100%; width: auto;' , 'class' : 'vboxAlert' } ) ; $ ( '<textarea />' ) . attr ( { 'spellcheck' : 'false' , 'wrap' : 'off' , 'readonly' : 'true' } ) . val ( e . details ) . appendTo ( $ ( '<form />' ) . appendTo ( ddet ) ) ; $ ( div ) . append ( ddet ) ; } var buttons = { } ; buttons [ trans ( 'OK' , 'QIMessageBox' ) ] = function ( f ) { $ ( this ) . trigger ( 'close' ) . empty ( ) . remove ( ) ; acknowledged . resolve ( ) ; } ; var dialogOpts = { 'closeOnEscape' : false , 'width' : 600 , 'height' : 'auto' , 'buttons' : buttons , 'modal' : true , 'autoOpen' : true , 'dialogClass' : 'vboxDialogContent' , 'title' : '<img src="images/vbox/OSE/about_16px.png" class="vboxDialogTitleIcon" /> phpVirtualBox' } ; if ( typeof xtraOpts == "object" ) { for ( var i in xtraOpts ) { dialogOpts [ i ] = xtraOpts [ i ] ; } } $ ( div ) . dialog ( dialogOpts ) ; return acknowledged ; }
Display alert Dialog
 @param {String|Object} e - message to display or object containing error message and details
 @param {Object} xtraOpts - extra options to apply to alert jquery dialog (optional)
 @see jQuery.dialog()
Display alert Dialog @param { String|Object } e - message to display or object containing error message and details @param { Object } xtraOpts - extra options to apply to alert jquery dialog ( optional ) @see jQuery . dialog ()
// Convert to <p>
 // Details can contain HTML entities
