Last active
February 25, 2022 01:55
-
-
Save sylus/cb01e59056780a2161186139b25818fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 20fc988f44c6af8d37913e9d9b9d8d0a0154414f Mon Sep 17 00:00:00 2001 | |
From: sylus <[email protected]> | |
Date: Thu, 24 Feb 2022 20:55:26 -0500 | |
Subject: [PATCH] feat(notebook): Patch noVNC for notebooks | |
Signed-off-by: sylus <[email protected]> | |
--- | |
app/ui.js | 17 ++++++++++++++++- | |
vnc_lite.html | 6 ++++-- | |
2 files changed, 20 insertions(+), 3 deletions(-) | |
diff --git a/app/ui.js b/app/ui.js | |
index cb6a9fd..f14cd50 100644 | |
--- a/app/ui.js | |
+++ b/app/ui.js | |
@@ -991,7 +991,7 @@ const UI = { | |
const host = UI.getSetting('host'); | |
const port = UI.getSetting('port'); | |
- const path = UI.getSetting('path'); | |
+ const path = readQueryVariable('path', window.location.pathname.replace(/[^/]*$/, '').substring(1) + 'websockify'); | |
if (typeof password === 'undefined') { | |
password = WebUtil.getConfigVar('password'); | |
@@ -1712,4 +1712,19 @@ if (l10n.language === "en" || l10n.dictionary !== undefined) { | |
.then(UI.prime); | |
} | |
+function readQueryVariable(name, defaultValue) { | |
+ // A URL with a query parameter can look like this: | |
+ // https://www.example.com?myqueryparam=myvalue | |
+ // | |
+ // Note that we use location.href instead of location.search | |
+ // because Firefox < 53 has a bug w.r.t location.search | |
+ const re = new RegExp('.*[?&]' + name + '=([^&#]*)'), match = document.location.href.match(re); | |
+ if (typeof defaultValue === 'undefined') { defaultValue = null; } | |
+ if (match) { | |
+ // We have to decode the URL since want the cleartext value | |
+ return decodeURIComponent(match[1]); | |
+ } | |
+ return defaultValue; | |
+} | |
+ | |
export default UI; | |
diff --git a/vnc_lite.html b/vnc_lite.html | |
index 8e2f5cb..4e4f969 100644 | |
--- a/vnc_lite.html | |
+++ b/vnc_lite.html | |
@@ -140,7 +140,8 @@ | |
const host = readQueryVariable('host', window.location.hostname); | |
let port = readQueryVariable('port', window.location.port); | |
const password = readQueryVariable('password'); | |
- const path = readQueryVariable('path', 'websockify'); | |
+ // MODIFICATION FROM vnc_lite.html | |
+ const path = readQueryVariable('path', window.location.pathname.replace(/[^/]*$/, '').substring(1) + 'websockify'); | |
// | | | | | | | |
// | | | Connect | | | | |
@@ -173,7 +174,8 @@ | |
// Set parameters that can be changed on an active connection | |
rfb.viewOnly = readQueryVariable('view_only', false); | |
- rfb.scaleViewport = readQueryVariable('scale', false); | |
+ // MODIFICATION FROM vnc_lite.html | |
+ rfb.scaleViewport = readQueryVariable('scale', true); | |
</script> | |
</head> | |
-- | |
2.32.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment