705 lines
28 KiB
JavaScript
705 lines
28 KiB
JavaScript
function resizeFrameWindow() {
|
|
var $frameDirectory = $("#frameDirectory").get(0);
|
|
$frameDirectory && $frameDirectory.contentWindow.frameResize();
|
|
}
|
|
|
|
function validateVmUrl(arg) {
|
|
var valid = !0;
|
|
return valid && (valid = 0 == arg.indexOf("http://") || 0 == arg.indexOf("https://")),
|
|
valid;
|
|
}
|
|
|
|
var isStandaloneHtml5Irc = location.href.indexOf("irc.html") > -1, startHtml5Irc = function(options) {
|
|
var me = this;
|
|
if (me.renderer && me.renderer.connected) return !1;
|
|
var defaults = {
|
|
session: iLO.getSessionKey(),
|
|
openCommand: 0,
|
|
canvasId: "rc_video",
|
|
host: window.location.host,
|
|
mode: "WINDOW",
|
|
version: 4
|
|
}, settings = $.extend(defaults, options);
|
|
settings.host;
|
|
me.renderer = new Renderer(settings), renderer.onready = function() {
|
|
switch ($("#remote_console_thumbnail_wait").hide(), settings.mode) {
|
|
case "MAXIMIZE":
|
|
htmlIrcMaximizeRestore(!0), toggleStatusBar(show_html5_statbar);
|
|
break;
|
|
|
|
case "FULLSCREEN":
|
|
htmlIrcFullscreen();
|
|
break;
|
|
|
|
case "DOCKED":
|
|
htmlIrcDock();
|
|
break;
|
|
|
|
case "WINDOW":
|
|
default:
|
|
htmlIrcWindowMode();
|
|
}
|
|
}, renderer.onclose = function() {
|
|
htmlIrcClose();
|
|
}, renderer.onsizechange = function(width, height) {
|
|
var ratio = height / width, $thumb = $("#remote_console_thumbnail");
|
|
if (ratio > 0 && ($(".status-resolution").text(width + " x " + height).removeAttr("data-localize"),
|
|
$(".status-text").find('[data-localize="IRC.status.NoVideo"]').length > 0 && clearStatusText(),
|
|
$thumb.length)) {
|
|
var twidth = $thumb.width(), theight = twidth * ratio;
|
|
$("#remote_console_thumbnail, #remote_console_thumbnail_wait").css("height", theight + "px");
|
|
}
|
|
}, renderer.onstatuschange = function(msg, ttl_ms) {
|
|
switch (msg) {
|
|
case "Video Suspended":
|
|
msg = "<span data-localize='IRC.status.NoVideo'>" + iLO.translateString("IRC.status.NoVideo", "No video") + "</span>";
|
|
break;
|
|
|
|
case "Post Complete":
|
|
msg = "<span data-localize='IRC.status.PostComplete'>" + iLO.translateString("IRC.status.PostComplete", "Post complete") + "</span>";
|
|
}
|
|
0 === ttl_ms ? $(".status-text").html(msg) : $(".status-text").html(msg).doTimeout("status-change", ttl_ms || 15e3, clearStatusText);
|
|
}, renderer.onvmactivity = function(stop) {
|
|
renderer.$vmled || (renderer.$vmled = $(".vm-activity"), renderer.vmledcount = 0),
|
|
stop ? (renderer.vmledcount = 0, renderer.$vmled.removeClass("vm-active")) : renderer.vmledcount++ % 10 === 0 && renderer.$vmled.toggleClass("vm-active").doTimeout("vmactivity", 250, function() {
|
|
renderer.onvmactivity(!0);
|
|
});
|
|
}, renderer.onhealthchange = function(state) {
|
|
switch (state) {
|
|
case "OP_STATUS_OK":
|
|
$(".health-state").html(myIcons.ok).attr({
|
|
title: iLO.translateString("appl.healthOK", "Health: OK"),
|
|
langattr: "title",
|
|
langkey: "appl.healthOK"
|
|
});
|
|
break;
|
|
|
|
case "OP_STATUS_WARNING":
|
|
$(".health-state").html(myIcons.warning).attr({
|
|
title: iLO.translateString("appl.healthDegraded", "Health: Degraded"),
|
|
langattr: "title",
|
|
langkey: "appl.healthDegraded"
|
|
});
|
|
break;
|
|
|
|
case "OP_STATUS_CRITICAL":
|
|
$(".health-state").html(myIcons.critical).attr({
|
|
title: iLO.translateString("appl.healthCritical", "Health: Critical"),
|
|
langattr: "title",
|
|
langkey: "appl.healthCritical"
|
|
});
|
|
break;
|
|
|
|
case "OP_STATUS_UNKNOWN":
|
|
default:
|
|
$(".health-state").html(myIcons.unknown).attr({
|
|
title: iLO.translateString("appl.healthUnknown", "Health: Unknown"),
|
|
langattr: "title",
|
|
langkey: "appl.healthUnknown"
|
|
});
|
|
}
|
|
}, renderer.onvmchange = function(state) {}, renderer.onlicensechange = function(lic) {},
|
|
renderer.onpowerchange = function(state) {
|
|
switch (state) {
|
|
case "ON":
|
|
$(".power-state").removeClass("powered-off").addClass("powered-on").attr({
|
|
title: iLO.translateString("appl.pwrOn", "Power: ON"),
|
|
langattr: "title",
|
|
langkey: "appl.pwrOn"
|
|
});
|
|
break;
|
|
|
|
case "OFF":
|
|
$(".power-state").removeClass("powered-on").addClass("powered-off").attr({
|
|
title: iLO.translateString("appl.pwrOff", "Power: OFF"),
|
|
langattr: "title",
|
|
langkey: "appl.pwrOff"
|
|
});
|
|
break;
|
|
|
|
default:
|
|
$(".power-state").removeClass("powered-on").removeClass("powered-off").attr({
|
|
title: iLO.translateString("appl.pwr", "Power"),
|
|
langattr: "title",
|
|
langkey: "appl.pwr"
|
|
});
|
|
}
|
|
}, setupHotKeys(), setupVM(), setupOptions();
|
|
}, show_html5_statbar = "false" !== iLO.getCookie("UserPref", "html5_statbar"), windowOptions = {}, initWindowOptions = function() {
|
|
windowOptions = {
|
|
width: "800px",
|
|
height: "auto",
|
|
position: {
|
|
my: "center",
|
|
at: "center",
|
|
of: window
|
|
},
|
|
maximized: !1
|
|
};
|
|
};
|
|
|
|
initWindowOptions();
|
|
|
|
var updateWindowOptions = function() {
|
|
var $dlg = $(".ui-dialog.hrc-dialog-window");
|
|
$dlg.length > 0 && ($(".control").hasClass("maximized") || (windowOptions.width = $dlg.width(),
|
|
windowOptions.height = $dlg.height(), windowOptions.position = $dlg.position(),
|
|
windowOptions.maximized = !1));
|
|
}, validateWindowOptions = function() {
|
|
var $win = $(window), footHeight = $("#footpanel").height();
|
|
return "auto" === windowOptions.height ? !0 : !(windowOptions.position.left > $win.width() - windowOptions.width || windowOptions.position.top > $win.height() - footHeight - windowOptions.height);
|
|
}, isWindowMaximized = function() {
|
|
var $win = $(window), $dlg = $(".ui-dialog.hrc-dialog-window"), footHeight = $("#footpanel").height(), maximized = !1;
|
|
return $dlg.length > 0 && (maximized = $dlg.width() == $win.width() && $dlg.height() == $win.height() - footHeight && 0 == $dlg.position().top && 0 == $dlg.position().left),
|
|
maximized;
|
|
}, clearStatusText = function() {
|
|
$(".status-text").empty();
|
|
}, toggleStatusBar = function(show) {
|
|
show ? (show_html5_statbar = !0, iLO.setCookie("UserPref", [ "html5_statbar", "true" ]),
|
|
$("#videoContainer .control").hasClass("dockedMode") || $(".videoContainer").removeClass("statusbar--off")) : (show_html5_statbar = !1,
|
|
iLO.setCookie("UserPref", [ "html5_statbar", "false" ]), $(".videoContainer").addClass("statusbar--off"));
|
|
}, screenCapture = function() {
|
|
var win = window.open();
|
|
if (win) try {
|
|
win.document.write('<img src="' + renderer.canvas.toDataURL() + '"/>'), win.document.close();
|
|
} catch (e) {
|
|
$.error("Screen capture failed: " + e.message);
|
|
}
|
|
}, setupHotKeys = function() {
|
|
$(".hotKeysMenu").off().on("click", function(event) {
|
|
if (1 === event.which) {
|
|
try {
|
|
$(".hasmenu", this).empty().menu("destroy");
|
|
} catch (e) {}
|
|
var $kbdMenu = $(".hasmenu", this), data = {
|
|
virtualkeys: [ [ {
|
|
cmd: "ControlLeft",
|
|
label: "CTRL",
|
|
strkey: ""
|
|
}, {
|
|
cmd: "Escape",
|
|
label: "ESC",
|
|
strkey: ""
|
|
}, {
|
|
cmd: "CapsLock",
|
|
label: "CAPS",
|
|
strkey: ""
|
|
}, {
|
|
cmd: "NumLock",
|
|
label: "NUM",
|
|
strkey: ""
|
|
} ], [ {
|
|
cmd: "OSLeft",
|
|
label: "L OS",
|
|
strkey: ""
|
|
}, {
|
|
cmd: "AltLeft",
|
|
label: "L ALT",
|
|
strkey: ""
|
|
}, {
|
|
cmd: "AltRight",
|
|
label: "R ALT",
|
|
strkey: ""
|
|
}, {
|
|
cmd: "OSRight",
|
|
label: "R OS",
|
|
strkey: ""
|
|
} ] ]
|
|
};
|
|
$("#videoContainer .control").hasClass("dockedMode") || (data.keybds = [ {
|
|
type: "en",
|
|
label: "EN 101",
|
|
strkey: ""
|
|
}, {
|
|
type: "ja",
|
|
label: "JP 106/109",
|
|
strkey: ""
|
|
} ]), $kbdMenu.html($("#kbd-menu-template").jqote(data)).translate(), $kbdMenu.menu({
|
|
create: function(event) {
|
|
$kbdMenu.doTimeout("kbdMenuTimer", 1e3, function() {
|
|
$kbdMenu.hide();
|
|
});
|
|
},
|
|
blur: function() {
|
|
$kbdMenu.hide(), $(window, ".hrc-dialog-window #kbd_menu .key-container div").off("keydown keyup", renderer.keyboard.on_key);
|
|
},
|
|
focus: function() {
|
|
$kbdMenu.doTimeout("kbdMenuTimer"), $kbdMenu.show(), $(window, ".hrc-dialog-window #kbd_menu .key-container div").on("keydown keyup", renderer.keyboard.on_key);
|
|
},
|
|
select: function(event, ui) {
|
|
switch (ui.item.attr("data-cmd")) {
|
|
case "none":
|
|
break;
|
|
|
|
case "ctrlaltdel":
|
|
renderer.worker.call_func("ctrlaltdel");
|
|
break;
|
|
|
|
case "kbd_en":
|
|
renderer.keyboard.setKbdLayoutId("en");
|
|
break;
|
|
|
|
case "kbd_ja":
|
|
renderer.keyboard.setKbdLayoutId("ja");
|
|
break;
|
|
|
|
default:
|
|
$.log("Unexpected keyboard menu option: %s", ui.item.attr("data-cmd"));
|
|
}
|
|
return !0;
|
|
}
|
|
}).show();
|
|
}
|
|
return $(document).one("click", function() {
|
|
return $kbdMenu.hide(), !0;
|
|
}), !1;
|
|
});
|
|
}, setupVmMenu = function(obj) {
|
|
try {
|
|
$(".hasmenu", ".vmMenu").empty().menu("destroy");
|
|
} catch (e) {}
|
|
var $vmMenu = $(".hasmenu", ".vmMenu");
|
|
return $vmMenu.html($("#vm_menu_template").jqote(obj.VirtualMedia)).translate(),
|
|
$vmMenu.menu({
|
|
create: function(event) {
|
|
$vmMenu.doTimeout("vmMenuTimer", 1e3, function() {
|
|
$vmMenu.hide();
|
|
});
|
|
},
|
|
blur: function() {
|
|
$vmMenu.hide();
|
|
},
|
|
focus: function() {
|
|
$vmMenu.doTimeout("vmMenuTimer"), $vmMenu.show();
|
|
},
|
|
select: function(event, ui) {
|
|
switch (ui.item.attr("data-cmd")) {
|
|
case "eject":
|
|
ejectVm(ui.item.attr("data-url"));
|
|
break;
|
|
|
|
case "insert":
|
|
insertVm(ui.item.attr("data-url"));
|
|
}
|
|
return event.stopPropagation(), !1;
|
|
}
|
|
}).show(), $(document).one("click", function() {
|
|
return $vmMenu.hide(), !0;
|
|
}), !1;
|
|
}, setupVM = function() {
|
|
renderer && renderer.version < 5 || iLOGlobal.cache.VirtualMediaEnabled ? $(".vmMenu").off().on("click", function(event) {
|
|
if (1 === event.which) {
|
|
event.target = ".hasmenu";
|
|
var $vmMenu = $(".hasmenu", ".vmMenu");
|
|
try {
|
|
$vmMenu.empty().menu("destroy");
|
|
} catch (e) {
|
|
event.stopPropagation(), $vmMenu.empty();
|
|
}
|
|
getVmStatus();
|
|
}
|
|
return !1;
|
|
}) : $(".vmMenu").off().attr("title", iLO.translateString("IRC.message.VmDisabled", "VM is disabled")).attr("langattr", "title").attr("langkey", "IRC.message.VmDisabled").removeClass("btn menu--controlled").on("click", function(event) {
|
|
return 1 === event.which && (event.stopPropagation(), showIrcToast({
|
|
text: iLO.translateString("vm.funcDisabled", "VM is disabled"),
|
|
type: "critical",
|
|
position: "bottom-right"
|
|
})), !1;
|
|
}).find(".btn").removeClass("btn");
|
|
}, setupOptionsMenu = function(obj) {
|
|
try {
|
|
$(".hasmenu", ".optionsMenu").empty().menu("destroy");
|
|
} catch (e) {}
|
|
var $OptionsMenu = $(".hasmenu", ".optionsMenu");
|
|
return $OptionsMenu.html($("#hrc-ilo-menu-template").jqote(obj)).translate(), $OptionsMenu.menu({
|
|
create: function(event) {
|
|
$OptionsMenu.doTimeout("optionsMenuTimer", 1e3, function() {
|
|
$OptionsMenu.hide();
|
|
});
|
|
},
|
|
blur: function() {
|
|
$OptionsMenu.hide();
|
|
},
|
|
focus: function() {
|
|
$OptionsMenu.doTimeout("optionsMenuTimer"), $OptionsMenu.show();
|
|
},
|
|
select: function(event, ui) {
|
|
switch (ui.item.attr("data-cmd")) {
|
|
case "statusbar":
|
|
toggleStatusBar(!show_html5_statbar);
|
|
break;
|
|
|
|
case "no_power_priv":
|
|
showIrcToast({
|
|
text: iLO.translateString("pwr_srv.resetIloPriv"),
|
|
type: "critical",
|
|
position: "bottom-right"
|
|
});
|
|
break;
|
|
|
|
case "momentary":
|
|
hostPwr.momentaryPress();
|
|
break;
|
|
|
|
case "hold":
|
|
hostPwr.pressAndHold();
|
|
break;
|
|
|
|
case "cold":
|
|
hostPwr.ColdBoot();
|
|
break;
|
|
|
|
case "reset":
|
|
hostPwr.systemReset();
|
|
}
|
|
return event.stopPropagation(), !1;
|
|
}
|
|
}).show(), $(document).one("click", function() {
|
|
return $OptionsMenu.hide(), !0;
|
|
}), !1;
|
|
}, setupOptions = function() {
|
|
$(".optionsMenu").off().on("click", function(event) {
|
|
if (1 === event.which) {
|
|
event.target = ".hasmenu";
|
|
var $OptionsMenu = $(".hasmenu", ".optionsMenu");
|
|
try {
|
|
$OptionsMenu.empty().menu("destroy");
|
|
} catch (e) {
|
|
event.stopPropagation(), $OptionsMenu.empty();
|
|
}
|
|
getPowerStatus();
|
|
}
|
|
return !1;
|
|
});
|
|
}, getPowerStatus = function() {
|
|
iLO.sendJsonRequest("host_power", "GET", "json/host_power", null, function(obj, fname, error) {
|
|
var msg = iLO.checkError(obj, fname, error);
|
|
msg || iLO.sendJsonRequest("session_info", "GET", "json/session_info", null, function(obj2, fname, error) {
|
|
obj.reset_priv = 1 === obj2.reset_priv, setupOptionsMenu(obj);
|
|
});
|
|
});
|
|
}, htmlIrcClose = function() {
|
|
$(".control").removeClass("maximized"), initWindowOptions(), "undefined" != typeof renderer && renderer.close && renderer.close(),
|
|
$("#videoContainer").fullScreen(!1);
|
|
var $ircWindow = $("#ircWindow").dialog("instance");
|
|
"undefined" != typeof $ircWindow && $ircWindow.destroy();
|
|
for (var i = 0; i < maxNumVMConn; i++) if ("undefined" != typeof vm_conn[i] && vm_conn[i].getWebsocket() && iLO.isFunction(vm_conn[i].getWebsocket().close)) try {
|
|
vm_conn[i].getWebsocket().close();
|
|
} catch (e) {}
|
|
$(".ui-dialog.irc-dialog .ui-dialog-titlebar-close").trigger("click"), $("#videoContainer .control").removeClass("dockedMode fullscreenMode"),
|
|
$("#thumbnail-wrapper").removeClass("dockedMode"), resizeFrameWindow(), $("#videoOuter, #dockedButtons").hide(),
|
|
$("#remote_console_thumbnail_wait").hide(), $("#remote_console_thumbnail").attr("title", "Click to launch Remote Console").attr("langattr", "title").attr("langkey", "IRC.label.ClickToLaunch");
|
|
}, htmlIrcFullscreen = function() {
|
|
updateWindowOptions();
|
|
var $videoControl = $(".videoContainer .control");
|
|
$("#videoContainer").fullScreen(!0), $(".videoContainer #hover-map").css({
|
|
pointerEvents: "inherit"
|
|
}), $videoControl.show().removeClass("dockedMode windowedMode").addClass("fullscreenMode ui-draggable ui-draggable-handle"),
|
|
$(".irc-canvas").removeClass("windowedMode"), $(".videoContainer").toggleClass("statusbar--off", !show_html5_statbar),
|
|
$(".videoContainer #hover-map, .videoContainer .control").hover(function(e) {
|
|
return $videoControl.stop().animate({
|
|
top: 0
|
|
}, 500), !0;
|
|
}, function(e) {
|
|
return closeFullscreenMenu(), !0;
|
|
}), $(".control .btnPin").hasClass("selected") ? ($(".videoContainer #hover-map, .videoContainer .control").off("mouseleave"),
|
|
$videoControl.css({
|
|
top: 0
|
|
})) : $videoControl.css({
|
|
top: -45
|
|
}), $videoControl.draggable({
|
|
axis: "x"
|
|
});
|
|
var $video = $videoControl.parent(), x1 = (y2 = $videoControl.position().top, $video.offset().left), x2 = $video.width() - $videoControl.outerWidth() + x1;
|
|
$videoControl.draggable("option", "containment", [ x1, 100, x2, 100 ]), setupHotKeys(),
|
|
setupVM();
|
|
}, htmlIrcWindowMode = function() {
|
|
$(".videoContainer #hover-map").css({
|
|
pointerEvents: "none"
|
|
}), $(".control").removeClass("dockedMode fullscreenMode ui-draggable ui-draggable-handle").addClass("windowedMode").css({
|
|
left: 0
|
|
}), $(".irc-canvas").addClass("windowedMode"), windowOptions.maximized || $("#videoOuter, #dockedButtons").hide(),
|
|
$("#thumbnail-wrapper").removeClass("dockedMode"), closeFullscreenMenu(), resizeFrameWindow();
|
|
var options = {
|
|
closeOnEscape: !1,
|
|
iframeFix: !0,
|
|
draggable: !0,
|
|
collision: "none",
|
|
classes: {
|
|
"ui-dialog": "hrc-dialog-window"
|
|
}
|
|
};
|
|
$.extend(options, windowOptions);
|
|
var $dialog = $("#ircWindow").dialog(options), $iloarticle = $("#iloarticle"), $ircWindow = $("#ircWindow"), $title = $ircWindow.prev(".ui-dialog-titlebar").css({
|
|
background: "transparent",
|
|
height: "33px",
|
|
left: "0px",
|
|
top: "0px"
|
|
});
|
|
$("button.ui-button, span.ui-dialog-title", $title).hide(), $("#videoContainer").appendTo($ircWindow),
|
|
$("#videoContainer div.control").clone().appendTo($title).css({
|
|
"z-index": 90
|
|
}), $(".videoContainer").toggleClass("statusbar--off", !show_html5_statbar), $(".control", $title).stop().css({
|
|
top: 0,
|
|
borderRadius: "10px 10px 0 0",
|
|
padding: 0,
|
|
width: "100%"
|
|
}), $(".btnVideoClose", $title).on("click", function() {
|
|
$("#videoContainer", "#ircWindow").appendTo("#videoOuter center"), htmlIrcClose();
|
|
}), $(".btnVideoDocked", $title).on("click", function() {
|
|
updateWindowOptions(), $("#videoContainer", $ircWindow).appendTo("#videoOuter center"),
|
|
$ircWindow.dialog("destroy"), htmlIrcDock();
|
|
}), $(".btnVideoFullScreen", $title).on("click", function() {
|
|
updateWindowOptions(), htmlIrcFullscreen();
|
|
}), $(".btnVideoMaximize, .btnVideoRestore").on("click", function() {
|
|
$(this).hasClass("btnVideoMaximize") && updateWindowOptions(), htmlIrcMaximizeRestore();
|
|
}), validateWindowOptions() || initWindowOptions(), windowOptions.maximized ? htmlIrcMaximizeRestore(!0) : adjustIrcDialog($dialog),
|
|
$dialog.on("dialogdragstart dialogresizestart", function(event, ui) {
|
|
$iloarticle.css("overflow", "hidden");
|
|
}).on("dialogdragstop dialogresizestop", function(event, ui) {
|
|
$iloarticle.css("overflow", "auto");
|
|
}), setupHotKeys(), setupVM(), setupOptions();
|
|
}, adjustIrcDialog = function($dlg) {
|
|
windowOptions.position.my ? $dlg.dialog("option", windowOptions) : ($dlg.dialog("option", {
|
|
width: windowOptions.width,
|
|
height: windowOptions.height
|
|
}), $dlg.parent().css(windowOptions.position));
|
|
}, adjustToResolution = function() {
|
|
var $win = $(window), $dlg = $("#ircWindow"), $cnvs = $("#rc_video");
|
|
initWindowOptions(), windowOptions.width = $cnvs.attr("width") || 800, windowOptions.width >= $win.width() && (windowOptions.width = parseInt(.75 * $win.width())),
|
|
$dlg.dialog("option", windowOptions);
|
|
}, htmlIrcMaximizeRestore = function(forceMax) {
|
|
var $win = $(window), $dlg = $("#ircWindow"), footHeight = $("#footpanel").height(), maximize = function() {
|
|
$dlg.dialog("option", {
|
|
height: $win.height() - footHeight,
|
|
width: $win.width()
|
|
}), windowOptions.maximized = !0, $(".control, .irc-canvas").addClass("maximized"),
|
|
$dlg.parent().css({
|
|
top: 0,
|
|
left: 0
|
|
});
|
|
}, updateMaximize = function() {
|
|
var $ctrl = $(".control");
|
|
!windowOptions.maximized || $ctrl.hasClass("fullscreenMode") || $ctrl.hasClass("dockedMode") ? $win.off("resize", updateMaximize) : maximize();
|
|
};
|
|
windowOptions.maximized && !forceMax ? (windowOptions.maximized = !1, $win.off("resize", updateMaximize),
|
|
$(".control, .irc-canvas").removeClass("maximized"), adjustIrcDialog($dlg)) : (maximize(),
|
|
$win.on("resize", updateMaximize));
|
|
}, htmlIrcDock = function() {
|
|
$(".control").removeClass("windowedMode fullscreenMode ui-draggable ui-draggable-handle").addClass("dockedMode"),
|
|
$(".irc-canvas").removeClass("windowedMode"), $("#thumbnail-wrapper").addClass("dockedMode"),
|
|
resizeFrameWindow(), $("#videoContainer").fullScreen(!1), closeFullscreenMenu(),
|
|
$(".videoContainer #hover-map, .videoContainer .control").off("mouseleave"), $("#videoOuter, #dockedButtons").show(),
|
|
$(".videoContainer").addClass("statusbar--off"), setupHotKeys(), setupVM();
|
|
};
|
|
|
|
$(document).on("fullscreenchange", function(event, data) {
|
|
$("#videoContainer").fullScreen() || exitFullScreen();
|
|
});
|
|
|
|
var closeFullscreenMenu = function() {
|
|
$("#videoContainer .control").hasClass("fullscreenMode") ? $(".videoContainer .control").stop().animate({
|
|
top: -45
|
|
}, 500) : $(".videoContainer .control").stop().css({
|
|
top: isStandaloneHtml5Irc ? 0 : -45
|
|
});
|
|
}, showIrcToast = function(options) {
|
|
$("#videoContainer .control").hasClass("fullscreenMode") && (options.parent = "#videoContainer"),
|
|
iLO.showToast(options);
|
|
}, exitFullScreen = function() {
|
|
var $ircWindow = $("#ircWindow").dialog("instance");
|
|
"undefined" != typeof renderer && renderer.connected && ("undefined" != typeof $ircWindow || isStandaloneHtml5Irc ? htmlIrcWindowMode() : htmlIrcDock()),
|
|
$("#videoContainer .toast-item-wrapper").remove(), $(".ui-dialog.irc-dialog").remove();
|
|
}, getVmStatus = function() {
|
|
iLO.sendJsonRequest("vm_status", "GET", "json/vm_status", null, function(obj, fname, error) {
|
|
var msg = iLO.checkError(obj, fname, error);
|
|
return msg ? void showIrcToast({
|
|
text: msg,
|
|
type: "critical"
|
|
}) : void setupVmMenu(convertVmJsonToRis(obj));
|
|
});
|
|
}, convertVmJsonToRis = function(obj) {
|
|
if (!Array.isArray(obj.options)) return obj;
|
|
var floppy = obj.options[0], cdrom = obj.options[1], vmObjs = [ {
|
|
Id: "1",
|
|
Action: "FLOPPY",
|
|
ConnectedVia: "NotConnected",
|
|
Description: "Virtual Removable Media",
|
|
Image: "",
|
|
Inserted: !1,
|
|
MediaTypes: [ "Floppy", "USBStick" ],
|
|
Name: "VirtualMedia",
|
|
WriteProtected: !1
|
|
}, {
|
|
Id: "2",
|
|
Action: "CDROM",
|
|
ConnectedVia: "NotConnected",
|
|
Description: "Virtual Removable Media",
|
|
Image: "",
|
|
Inserted: !1,
|
|
MediaTypes: [ "CD", "DVD" ],
|
|
Name: "VirtualMedia",
|
|
WriteProtected: !0
|
|
} ];
|
|
return 1 == floppy.vm_connected && (floppy.vm_url_connected ? (vmObjs[0].Inserted = 1 == floppy.image_inserted,
|
|
vmObjs[0].WriteProtected = 1 == floppy.write_protect_flag, vmObjs[0].ConnectedVia = "URI",
|
|
vmObjs[0].Image = floppy.image_url, vmObjs[0].ImageName = floppy.image_url_file) : (vmObjs[0].Inserted = !0,
|
|
vmObjs[0].WriteProtected = 1 == floppy.write_protect_flag, vmObjs[0].Action = "APPLET_FLOPPY",
|
|
vmObjs[0].ConnectedVia = "Applet", vmObjs[0].Image = "irc://")), 1 == cdrom.vm_connected && (cdrom.vm_url_connected ? (vmObjs[1].Inserted = 1 == cdrom.image_inserted,
|
|
vmObjs[1].WriteProtected = 1 == cdrom.write_protect_flag, vmObjs[1].ConnectedVia = "URI",
|
|
vmObjs[1].Image = cdrom.image_url, vmObjs[1].ImageName = cdrom.image_url_file) : (vmObjs[1].Inserted = !0,
|
|
vmObjs[1].WriteProtected = 1 == cdrom.write_protect_flag, vmObjs[1].Action = "APPLET_CDROM",
|
|
vmObjs[1].ConnectedVia = "Applet", vmObjs[1].Image = "irc://")), {
|
|
VirtualMedia: vmObjs
|
|
};
|
|
}, ejectVm = function(url) {
|
|
ejectUrlVm(url);
|
|
}, insertVm = function(url) {
|
|
var dialog, dialogOptions = {
|
|
autoOpen: !0,
|
|
closeOnEscape: !1,
|
|
height: 250,
|
|
width: 600,
|
|
modal: !0,
|
|
collision: "none",
|
|
appendTo: $("#videoContainer .control").hasClass("fullscreenMode") ? "#videoContainer" : null,
|
|
position: {
|
|
my: "center",
|
|
at: "center"
|
|
},
|
|
draggable: !0,
|
|
resizable: !1,
|
|
dialogClass: "irc-dialog",
|
|
buttons: [ {
|
|
text: iLO.translateString("apply"),
|
|
click: function() {
|
|
var vmForm = new InputValidator(null, null, !0);
|
|
return vmForm.clearMessages(), vmForm.allInputsValidate() ? (insertUrlVm($("#disc_upload", dialog).val().trim(), url),
|
|
void $(this).dialog("destroy")) : (vmForm.updateMessages(!0), vmForm.autoFocus(),
|
|
!1);
|
|
}
|
|
}, {
|
|
text: iLO.translateString("cancel"),
|
|
click: function() {
|
|
$(this).dialog("destroy");
|
|
}
|
|
} ],
|
|
open: function() {
|
|
iLOGlobal.ie && $(".irc-dialog").next(".ui-widget-overlay").animate({
|
|
height: "100vh"
|
|
}, 400), $("#disc_upload").val(""), $("span.form-field__error").text(""), $(".form-field").removeClass("form-field--error"),
|
|
$(".ui-dialog-titlebar-close").html(myIcons.close), $(".ui-dialog-titlebar-close").off().on("click", function() {
|
|
$(dialog).dialog("destroy");
|
|
});
|
|
},
|
|
close: function(evt) {
|
|
$(this).dialog("destroy"), dialog = null;
|
|
}
|
|
}, $iloarticle = $("#iloarticle");
|
|
dialog = $("#vm-url-form").dialog(dialogOptions).on("dialogdragstart dialogresizestart", function(event, ui) {
|
|
return $iloarticle.css("overflow", "hidden"), !0;
|
|
}).on("dialogdragstop dialogresizestop", function(event, ui) {
|
|
return $iloarticle.css("overflow", "auto"), !0;
|
|
});
|
|
}, ejectUrlVm = function(type) {
|
|
var ejectObj = {
|
|
method: "set_virtual_media_options",
|
|
device: type,
|
|
command: "EJECT"
|
|
};
|
|
iLO.sendJsonRequest("vm_status", "POST", "json/vm_status", ejectObj, ejectVmCallback);
|
|
}, insertUrlVm = function(url, type) {
|
|
var insertObj = {
|
|
method: "set_virtual_media_options",
|
|
device: type,
|
|
command: "INSERT",
|
|
url: url
|
|
};
|
|
iLO.sendJsonRequest("vm_status", "POST", "json/vm_status", insertObj, function(o, fname, error) {
|
|
var msg = iLO.checkError(o, fname, error);
|
|
msg ? insertVmCallback(o, fname, error) : (insertObj.command = "SET", insertObj.boot_option = "CONNECT",
|
|
iLO.sendJsonRequest("vm_status", "POST", "json/vm_status", insertObj, insertVmCallback));
|
|
});
|
|
}, insertVmCallback = function(o, fname, error) {
|
|
var msg = iLO.checkError(o, fname, error);
|
|
showIrcToast(msg ? o.message && "JS_ERR_NO_PRIV" == o.message || o.MessageId && "InsufficientPrivilege" == o.MessageId ? {
|
|
text: iLO.translateString("vm.usrNotPrivVirtual"),
|
|
type: "critical",
|
|
position: "bottom-right"
|
|
} : o.MessageId && "VirtualMediaIsDisabled" == o.MessageId ? {
|
|
text: iLO.translateString("vm.funcDisabled"),
|
|
type: "critical",
|
|
position: "bottom-right"
|
|
} : o.MessageId && "LicenseKeyRequired" == o.MessageId ? {
|
|
text: iLO.translateString("IRC.error.MediaNotLicensed"),
|
|
type: "critical",
|
|
position: "bottom-right"
|
|
} : {
|
|
text: iLO.translateString("vm.errProcessVMInsert"),
|
|
type: "critical",
|
|
position: "bottom-right",
|
|
sticky: !1
|
|
} : {
|
|
text: iLO.translateString("vm.imgInserted"),
|
|
type: "ok",
|
|
position: "bottom-right"
|
|
});
|
|
}, ejectVmCallback = function(o, fname, error) {
|
|
var msg = iLO.checkError(o, fname, error);
|
|
showIrcToast(msg ? o.MessageId && "InsufficientPrivilege" == o.MessageId ? {
|
|
text: iLO.translateString("vm.usrNotPrivVirtual"),
|
|
type: "critical",
|
|
position: "bottom-right"
|
|
} : {
|
|
text: iLO.translateString("vm.errProcessVMEject"),
|
|
type: "critical",
|
|
position: "bottom-right"
|
|
} : {
|
|
text: iLO.translateString("vm.processVMEject"),
|
|
type: "ok",
|
|
position: "bottom-right"
|
|
});
|
|
};
|
|
|
|
$(document).ready(function() {
|
|
var $control = $(".control"), video = $("#rc_video");
|
|
$("div.btnPin").append(myIcons.pin), $("div.btnOptions").append(myIcons.menu), $("div.btnHotKeys").append(myIcons.keyboard),
|
|
$("div.btnVM").append(myIcons.cd), $("div.btnVideoDocked").append(myIcons.template),
|
|
$("div.btnVideoWindowMode").append(myIcons.desktop), $("div.btnVideoMaximize").append(myIcons.maximize),
|
|
$("div.btnVideoRestore").append(myIcons.restore), $("div.btnVideoFullScreen").append(myIcons.expand),
|
|
$("div.btnVideoContract").append(myIcons.contract), $("div.btnVideoClose").append(myIcons.close),
|
|
$("span.screen-capture").append(myIcons.camera), $("#encryption-icon").append(myIcons.lock),
|
|
$(".power-state").append(myIcons.power), $(".health-state, .vm-activity").append(myIcons.radial),
|
|
$(".status-icons").find(".control-icon").addClass("color-index-ignore"), $(".control div.middleControl").text(window.location.hostname),
|
|
$(".control.fullscreenMode").draggable({
|
|
axis: "x"
|
|
}), $(".control.fullscreenMode").on("mousedown", function() {
|
|
var $video = $control.siblings("canvas"), y1 = y2 = $control.position().top, x1 = $video.offset().left, x2 = $video.width() - $control.outerWidth() + x1;
|
|
return $control.draggable("option", "containment", [ x1, y1, x2, y2 ]), !0;
|
|
}), video[0].removeAttribute("controls"), closeFullscreenMenu(), $(".btnVideoClose").on("click", function() {
|
|
htmlIrcClose();
|
|
}), $(".btnVideoFullScreen").on("click", function() {
|
|
htmlIrcFullscreen();
|
|
}), $(".btnVideoWindowMode").on("click", function() {
|
|
htmlIrcWindowMode();
|
|
}), $(".btnVideoMaximize, .btnVideoRestore").on("click", function() {
|
|
htmlIrcMaximizeRestore();
|
|
}), $(".btnPin").on("click", function() {
|
|
$(this).hasClass("selected") ? ($(".videoContainer #hover-map, .videoContainer .control").on("mouseleave", function() {
|
|
closeFullscreenMenu();
|
|
}), $(".videoContainer #hover-map").css({
|
|
pointerEvents: "inherit"
|
|
}), $(this).removeClass("selected")) : ($(".videoContainer #hover-map, .videoContainer .control").off("mouseleave"),
|
|
$(".videoContainer #hover-map").css({
|
|
pointerEvents: "none"
|
|
}), $(this).addClass("selected"));
|
|
}), $(".screen-capture").on("click", function() {
|
|
screenCapture();
|
|
}), $(document).on("dblclick", "div.middleControl", function(evt) {
|
|
toggleStatusBar(!show_html5_statbar);
|
|
}), $(document).on("dblclick", "div.status-resolution", function(evt) {
|
|
$(".control").hasClass("windowedMode") && !windowOptions.maximized && adjustToResolution();
|
|
}), $(".btnVideoContract").on("click", function() {
|
|
$("#videoContainer").fullScreen(!1);
|
|
});
|
|
}); |