X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=vnc_lite.html;h=4a96d448fc4a58f042f94b2b2f43ef6da49c9aea;hb=be8580558cceb990c641bbc021b6818b971781c8;hp=95cf286578d4906a487a20533d861e208226fc90;hpb=3d7bb0203619a2787b16b5cc4b68b16e18a4ee68;p=mirror_novnc.git diff --git a/vnc_lite.html b/vnc_lite.html index 95cf286..4a96d44 100644 --- a/vnc_lite.html +++ b/vnc_lite.html @@ -5,7 +5,7 @@ @@ -80,34 +82,17 @@ import RFB from './core/rfb.js'; var rfb; - var doneInitialResize; - var resizeTimeout; var desktopName; - function UIresize() { - if (WebUtil.getConfigVar('resize', false)) { - var innerW = window.innerWidth; - var innerH = window.innerHeight; - var controlbarH = document.getElementById('noVNC_status_bar').offsetHeight; - if (innerW !== undefined && innerH !== undefined) - rfb.requestDesktopSize(innerW, innerH - controlbarH); - } - } - function initialResize() { - if (doneInitialResize) return; - UIresize(); - doneInitialResize = true; + function updateDesktopName(e) { + desktopName = e.detail.name; } - function updateDesktopName(rfb, name) { - desktopName = name; - } - function credentials(rfb, types) { + function credentials(e) { var html; var form = document.createElement('form'); - form.style = 'margin-bottom: 0px'; - form.innerHTML = '' - form.innerHTML += ''; + form.innerHTML = ''; + form.innerHTML += ''; form.onsubmit = setPassword; // bypass status() because it sets text content @@ -145,75 +130,40 @@ default: level = "warn"; } - document.getElementById('noVNC_status_bar').setAttribute("class", "noVNC_status_" + level); + document.getElementById('noVNC_status_bar').className = "noVNC_status_" + level; document.getElementById('noVNC_status').textContent = text; } - function updateState(rfb, state, oldstate) { - var cad = document.getElementById('sendCtrlAltDelButton'); - switch (state) { - case 'connecting': - status("Connecting", "normal"); - break; - case 'connected': - doneInitialResize = false; - if (WebUtil.getConfigVar('encrypt', - (window.location.protocol === "https:"))) { - status("Connected (encrypted) to " + - desktopName, "normal"); - } else { - status("Connected (unencrypted) to " + - desktopName, "normal"); - } - break; - case 'disconnecting': - status("Disconnecting", "normal"); - break; - case 'disconnected': - status("Disconnected", "normal"); - break; - default: - status(state, "warn"); - break; - } - if (state === 'connected') { - cad.disabled = false; + function connected(e) { + document.getElementById('sendCtrlAltDelButton').disabled = false; + if (WebUtil.getConfigVar('encrypt', + (window.location.protocol === "https:"))) { + status("Connected (encrypted) to " + desktopName, "normal"); } else { - cad.disabled = true; - updatePowerButtons(); + status("Connected (unencrypted) to " + desktopName, "normal"); } - } - function disconnected(rfb, reason) { - if (typeof(reason) !== 'undefined') { - status(reason, "error"); + + function disconnected(e) { + document.getElementById('sendCtrlAltDelButton').disabled = true; + updatePowerButtons(); + if (e.detail.clean) { + status("Disconnected", "normal"); + } else { + status("Something went wrong, connection is closed", "error"); } } - function notification(rfb, msg, level, options) { - status(msg, level); - } - - window.onresize = function () { - // When the window has been resized, wait until the size remains - // the same for 0.5 seconds before sending the request for changing - // the resolution of the session - clearTimeout(resizeTimeout); - resizeTimeout = setTimeout(function(){ - UIresize(); - }, 500); - }; function updatePowerButtons() { var powerbuttons; powerbuttons = document.getElementById('noVNC_power_buttons'); - if (rfb.get_capabilities().power) { - powerbuttons.style.display = 'inline'; + if (rfb.capabilities.power) { + powerbuttons.className= "noVNC_shown"; } else { - powerbuttons.style.display = 'none'; + powerbuttons.className = "noVNC_hidden"; } } - document.getElementById('sendCtrlAltDelButton').style.display = "inline"; document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel; document.getElementById('machineShutdownButton').onclick = machineShutdown; document.getElementById('machineRebootButton').onclick = machineReboot; @@ -251,25 +201,12 @@ (function() { + status("Connecting", "normal"); + if ((!host) || (!port)) { status('Must specify host and port in URL', 'error'); } - try { - rfb = new RFB(document.getElementById('noVNC_canvas'), - {'local_cursor': WebUtil.getConfigVar('cursor', true), - 'view_only': WebUtil.getConfigVar('view_only', false), - 'onNotification': notification, - 'onUpdateState': updateState, - 'onDisconnected': disconnected, - 'onCapabilities': function () { updatePowerButtons(); initialResize(); }, - 'onCredentialsRequired': credentials, - 'onDesktopName': updateDesktopName}); - } catch (exc) { - status('Unable to create RFB client -- ' + exc, 'error'); - return; // don't continue trying to connect - } - var url; if (WebUtil.getConfigVar('encrypt', @@ -285,38 +222,38 @@ } url += '/' + path; - rfb.connect(url, { repeaterID: WebUtil.getConfigVar('repeaterID', ''), - shared: WebUtil.getConfigVar('shared', true), - credentials: { password: password } }); + rfb = new RFB(document.body, url, + { repeaterID: WebUtil.getConfigVar('repeaterID', ''), + shared: WebUtil.getConfigVar('shared', true), + credentials: { password: password } }); + rfb.viewOnly = WebUtil.getConfigVar('view_only', false); + rfb.addEventListener("connect", connected); + rfb.addEventListener("disconnect", disconnected); + rfb.addEventListener("capabilities", function () { updatePowerButtons(); }); + rfb.addEventListener("credentialsrequired", credentials); + rfb.addEventListener("desktopname", updateDesktopName); + rfb.scaleViewport = WebUtil.getConfigVar('scale', false); + rfb.resizeSession = WebUtil.getConfigVar('resize', false); })(); - -
-
- - - -
- Loading -
- - - - - - -
-
- - Canvas not supported. - -
- - + +
+
+
Loading
+
+ + + + + + +
+
+