mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-09 13:39:42 -05:00
Update noVNC to 1.4.0
This commit is contained in:
@@ -8,7 +8,8 @@
|
||||
|
||||
import * as Log from '../core/util/logging.js';
|
||||
import _, { l10n } from './localization.js';
|
||||
import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold }
|
||||
import { isTouchDevice, isMac, isIOS, isAndroid, isChromeOS, isSafari,
|
||||
hasScrollbarGutter, dragThreshold }
|
||||
from '../core/util/browser.js';
|
||||
import { setCapture, getPointerEvent } from '../core/util/events.js';
|
||||
import KeyTable from "../core/input/keysym.js";
|
||||
@@ -79,13 +80,19 @@ const UI = {
|
||||
// Render default UI and initialize settings menu
|
||||
start() {
|
||||
|
||||
if (urlargs.name) { document.title = urlargs.name + " - noVNC"; }
|
||||
|
||||
UI.initSettings();
|
||||
|
||||
// Translate the DOM
|
||||
l10n.translateDOM();
|
||||
|
||||
// We rely on modern APIs which might not be available in an
|
||||
// insecure context
|
||||
if (!window.isSecureContext) {
|
||||
// FIXME: This gets hidden when connecting
|
||||
UI.showStatus(_("HTTPS is required for full functionality"), 'error');
|
||||
}
|
||||
|
||||
// Try to fetch version number
|
||||
fetch('./package.json')
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
@@ -105,7 +112,6 @@ const UI = {
|
||||
|
||||
// Adapt the interface for touch screen devices
|
||||
if (isTouchDevice) {
|
||||
document.documentElement.classList.add("noVNC_touch");
|
||||
// Remove the address bar
|
||||
setTimeout(() => window.scrollTo(0, 1), 100);
|
||||
}
|
||||
@@ -341,6 +347,10 @@ const UI = {
|
||||
document.getElementById("noVNC_cancel_reconnect_button")
|
||||
.addEventListener('click', UI.cancelReconnect);
|
||||
|
||||
document.getElementById("noVNC_approve_server_button")
|
||||
.addEventListener('click', UI.approveServer);
|
||||
document.getElementById("noVNC_reject_server_button")
|
||||
.addEventListener('click', UI.rejectServer);
|
||||
document.getElementById("noVNC_credentials_button")
|
||||
.addEventListener('click', UI.setCredentials);
|
||||
},
|
||||
@@ -350,8 +360,6 @@ const UI = {
|
||||
.addEventListener('click', UI.toggleClipboardPanel);
|
||||
document.getElementById("noVNC_clipboard_text")
|
||||
.addEventListener('change', UI.clipboardSend);
|
||||
document.getElementById("noVNC_clipboard_clear_button")
|
||||
.addEventListener('click', UI.clipboardClear);
|
||||
},
|
||||
|
||||
// Add a call to save settings when the element changes,
|
||||
@@ -470,6 +478,8 @@ const UI = {
|
||||
// State change closes dialogs as they may not be relevant
|
||||
// anymore
|
||||
UI.closeAllPanels();
|
||||
document.getElementById('noVNC_verify_server_dlg')
|
||||
.classList.remove('noVNC_open');
|
||||
document.getElementById('noVNC_credentials_dlg')
|
||||
.classList.remove('noVNC_open');
|
||||
},
|
||||
@@ -602,10 +612,20 @@ const UI = {
|
||||
|
||||
// Consider this a movement of the handle
|
||||
UI.controlbarDrag = true;
|
||||
|
||||
// The user has "followed" hint, let's hide it until the next drag
|
||||
UI.showControlbarHint(false, false);
|
||||
},
|
||||
|
||||
showControlbarHint(show) {
|
||||
showControlbarHint(show, animate=true) {
|
||||
const hint = document.getElementById('noVNC_control_bar_hint');
|
||||
|
||||
if (animate) {
|
||||
hint.classList.remove("noVNC_notransition");
|
||||
} else {
|
||||
hint.classList.add("noVNC_notransition");
|
||||
}
|
||||
|
||||
if (show) {
|
||||
hint.classList.add("noVNC_active");
|
||||
} else {
|
||||
@@ -979,11 +999,6 @@ const UI = {
|
||||
Log.Debug("<< UI.clipboardReceive");
|
||||
},
|
||||
|
||||
clipboardClear() {
|
||||
document.getElementById('noVNC_clipboard_text').value = "";
|
||||
UI.rfb.clipboardPasteFrom("");
|
||||
},
|
||||
|
||||
clipboardSend() {
|
||||
const text = document.getElementById('noVNC_clipboard_text').value;
|
||||
Log.Debug(">> UI.clipboardSend: " + text.substr(0, 40) + "...");
|
||||
@@ -1039,14 +1054,19 @@ const UI = {
|
||||
|
||||
UI.updateVisualState('connecting');
|
||||
|
||||
|
||||
|
||||
|
||||
UI.rfb = new RFB(document.getElementById('noVNC_container'), urlargs.ws,
|
||||
{ shared: UI.getSetting('shared'),
|
||||
repeaterID: UI.getSetting('repeaterID'),
|
||||
credentials: { password: password } });
|
||||
UI.rfb.addEventListener("connect", UI.connectFinished);
|
||||
UI.rfb.addEventListener("disconnect", UI.disconnectFinished);
|
||||
UI.rfb.addEventListener("serververification", UI.serverVerify);
|
||||
UI.rfb.addEventListener("credentialsrequired", UI.credentials);
|
||||
UI.rfb.addEventListener("securityfailure", UI.securityFailed);
|
||||
UI.rfb.addEventListener("clippingviewport", UI.updateViewDrag);
|
||||
UI.rfb.addEventListener("capabilities", UI.updatePowerButton);
|
||||
UI.rfb.addEventListener("clipboard", UI.clipboardReceive);
|
||||
UI.rfb.addEventListener("bell", UI.bell);
|
||||
@@ -1133,7 +1153,9 @@ const UI = {
|
||||
} else {
|
||||
UI.showStatus(_("Failed to connect to server"), 'error');
|
||||
}
|
||||
} else if (UI.getSetting('reconnect', false) === true && !UI.inhibitReconnect) {
|
||||
}
|
||||
// If reconnecting is allowed process it now
|
||||
if (UI.getSetting('reconnect', false) === true && !UI.inhibitReconnect) {
|
||||
UI.updateVisualState('reconnecting');
|
||||
|
||||
const delay = parseInt(UI.getSetting('reconnect_delay'));
|
||||
@@ -1144,6 +1166,7 @@ const UI = {
|
||||
UI.showStatus(_("Disconnected"), 'normal');
|
||||
}
|
||||
|
||||
|
||||
UI.openControlbar();
|
||||
UI.openConnectPanel();
|
||||
},
|
||||
@@ -1165,6 +1188,37 @@ const UI = {
|
||||
/* ------^-------
|
||||
* /CONNECTION
|
||||
* ==============
|
||||
* SERVER VERIFY
|
||||
* ------v------*/
|
||||
|
||||
async serverVerify(e) {
|
||||
const type = e.detail.type;
|
||||
if (type === 'RSA') {
|
||||
const publickey = e.detail.publickey;
|
||||
let fingerprint = await window.crypto.subtle.digest("SHA-1", publickey);
|
||||
// The same fingerprint format as RealVNC
|
||||
fingerprint = Array.from(new Uint8Array(fingerprint).slice(0, 8)).map(
|
||||
x => x.toString(16).padStart(2, '0')).join('-');
|
||||
document.getElementById('noVNC_verify_server_dlg').classList.add('noVNC_open');
|
||||
document.getElementById('noVNC_fingerprint').innerHTML = fingerprint;
|
||||
}
|
||||
},
|
||||
|
||||
approveServer(e) {
|
||||
e.preventDefault();
|
||||
document.getElementById('noVNC_verify_server_dlg').classList.remove('noVNC_open');
|
||||
UI.rfb.approveServer();
|
||||
},
|
||||
|
||||
rejectServer(e) {
|
||||
e.preventDefault();
|
||||
document.getElementById('noVNC_verify_server_dlg').classList.remove('noVNC_open');
|
||||
UI.disconnect();
|
||||
},
|
||||
|
||||
/* ------^-------
|
||||
* /SERVER VERIFY
|
||||
* ==============
|
||||
* PASSWORD
|
||||
* ------v------*/
|
||||
|
||||
@@ -1288,13 +1342,25 @@ const UI = {
|
||||
|
||||
const scaling = UI.getSetting('resize') === 'scale';
|
||||
|
||||
// Some platforms have overlay scrollbars that are difficult
|
||||
// to use in our case, which means we have to force panning
|
||||
// FIXME: Working scrollbars can still be annoying to use with
|
||||
// touch, so we should ideally be able to have both
|
||||
// panning and scrollbars at the same time
|
||||
|
||||
let brokenScrollbars = false;
|
||||
|
||||
if (!hasScrollbarGutter) {
|
||||
if (isIOS() || isAndroid() || isMac() || isChromeOS()) {
|
||||
brokenScrollbars = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (scaling) {
|
||||
// Can't be clipping if viewport is scaled to fit
|
||||
UI.forceSetting('view_clip', false);
|
||||
UI.rfb.clipViewport = false;
|
||||
} else if (!hasScrollbarGutter) {
|
||||
// Some platforms have scrollbars that are difficult
|
||||
// to use in our case, so we always use our own panning
|
||||
} else if (brokenScrollbars) {
|
||||
UI.forceSetting('view_clip', true);
|
||||
UI.rfb.clipViewport = true;
|
||||
} else {
|
||||
@@ -1325,7 +1391,8 @@ const UI = {
|
||||
|
||||
const viewDragButton = document.getElementById('noVNC_view_drag_button');
|
||||
|
||||
if (!UI.rfb.clipViewport && UI.rfb.dragViewport) {
|
||||
if ((!UI.rfb.clipViewport || !UI.rfb.clippingViewport) &&
|
||||
UI.rfb.dragViewport) {
|
||||
// We are no longer clipping the viewport. Make sure
|
||||
// viewport drag isn't active when it can't be used.
|
||||
UI.rfb.dragViewport = false;
|
||||
@@ -1342,6 +1409,8 @@ const UI = {
|
||||
} else {
|
||||
viewDragButton.classList.add("noVNC_hidden");
|
||||
}
|
||||
|
||||
viewDragButton.disabled = !UI.rfb.clippingViewport;
|
||||
},
|
||||
|
||||
/* ------^-------
|
||||
@@ -1670,9 +1739,9 @@ const UI = {
|
||||
},
|
||||
|
||||
updateDesktopName(e) {
|
||||
//UI.desktopName = e.detail.name;
|
||||
// UI.desktopName = e.detail.name;
|
||||
// Display the desktop name in the document title
|
||||
//document.title = e.detail.name + " - " + PAGE_TITLE;
|
||||
// document.title = e.detail.name + " - " + PAGE_TITLE;
|
||||
},
|
||||
|
||||
bell(e) {
|
||||
@@ -1708,7 +1777,7 @@ const UI = {
|
||||
};
|
||||
|
||||
// Set up translations
|
||||
const LINGUAS = ["cs", "de", "el", "es", "fr", "ja", "ko", "nl", "pl", "pt_BR", "ru", "sv", "tr", "zh_CN", "zh_TW"];
|
||||
const LINGUAS = ["cs", "de", "el", "es", "fr", "it", "ja", "ko", "nl", "pl", "pt_BR", "ru", "sv", "tr", "zh_CN", "zh_TW"];
|
||||
l10n.setup(LINGUAS);
|
||||
if (l10n.language === "en" || l10n.dictionary !== undefined) {
|
||||
UI.prime();
|
||||
|
||||
Reference in New Issue
Block a user