summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mannehed <samuel@cendio.se>2018-08-16 11:34:17 +0200
committerSamuel Mannehed <samuel@cendio.se>2018-08-28 10:42:37 +0200
commit25551b6b406a9d2b3164a4f02b0b2325bb0833ac (patch)
tree4f7949b3fccaad2de4aa7f2aed47553aee2e9b04
parent6517c498b9c93e805ead992cc4e5bafa18193fb3 (diff)
downloadnovnc-25551b6b406a9d2b3164a4f02b0b2325bb0833ac.tar.gz
Use let and const instead of var in vnc_lite
The rest of noVNC has been converted already. This allows us to remove the extra scope that was created for the VNC connection.
-rw-r--r--vnc_lite.html72
1 files changed, 35 insertions, 37 deletions
diff --git a/vnc_lite.html b/vnc_lite.html
index 828c5c8..a01e33d 100644
--- a/vnc_lite.html
+++ b/vnc_lite.html
@@ -72,7 +72,7 @@
<script>
window.addEventListener("load", function() {
if (window._noVNC_has_module_support) return;
- var loader = document.createElement("script");
+ const loader = document.createElement("script");
loader.src = "vendor/browser-es-module-loader/dist/browser-es-module-loader.js";
document.head.appendChild(loader);
});
@@ -83,8 +83,8 @@
// RFB holds the API to connect and communicate with a VNC server
import RFB from './core/rfb.js';
- var rfb;
- var desktopName;
+ let rfb;
+ let desktopName;
// When this function is called we have received
// a desktop name from the server
@@ -96,7 +96,7 @@
// credentials to authenticate
function credentials(e) {
// Let's create a password input
- var form = document.createElement('form');
+ const form = document.createElement('form');
form.innerHTML = '<label></label>';
form.innerHTML += '<input type=password size=10 id="password_input">';
form.onsubmit = setPassword;
@@ -168,45 +168,43 @@
// Read parameters specified in the URL query string
// By default, use the host and port of server that served this file
- var host = readQueryVariable('host', window.location.hostname);
- var port = readQueryVariable('port', window.location.port);
- var password = readQueryVariable('password', '');
- var path = readQueryVariable('path', 'websockify');
+ const host = readQueryVariable('host', window.location.hostname);
+ let port = readQueryVariable('port', window.location.port);
+ const password = readQueryVariable('password', '');
+ const path = readQueryVariable('path', 'websockify');
// | | | | | |
// | | | Connect | | |
// v v v v v v
- (function() {
- status("Connecting");
+ status("Connecting");
- // Build the websocket URL used to connect
- var url;
- if (window.location.protocol === "https:") {
- url = 'wss';
- } else {
- url = 'ws';
- }
- url += '://' + host;
- if(port) {
- url += ':' + port;
- }
- url += '/' + path;
-
- // Creating a new RFB object will start a new connection
- rfb = new RFB(document.body, url,
- { credentials: { password: password } });
-
- // Add listeners to important events from the RFB module
- rfb.addEventListener("connect", connected);
- rfb.addEventListener("disconnect", disconnected);
- rfb.addEventListener("credentialsrequired", credentials);
- rfb.addEventListener("desktopname", updateDesktopName);
-
- // Set parameters that can be changed on an active connection
- rfb.viewOnly = readQueryVariable('view_only', false);
- rfb.scaleViewport = readQueryVariable('scale', false);
- })();
+ // Build the websocket URL used to connect
+ let url;
+ if (window.location.protocol === "https:") {
+ url = 'wss';
+ } else {
+ url = 'ws';
+ }
+ url += '://' + host;
+ if(port) {
+ url += ':' + port;
+ }
+ url += '/' + path;
+
+ // Creating a new RFB object will start a new connection
+ rfb = new RFB(document.body, url,
+ { credentials: { password: password } });
+
+ // Add listeners to important events from the RFB module
+ rfb.addEventListener("connect", connected);
+ rfb.addEventListener("disconnect", disconnected);
+ rfb.addEventListener("credentialsrequired", credentials);
+ rfb.addEventListener("desktopname", updateDesktopName);
+
+ // Set parameters that can be changed on an active connection
+ rfb.viewOnly = readQueryVariable('view_only', false);
+ rfb.scaleViewport = readQueryVariable('scale', false);
</script>
</head>