[go: nahoru, domu]

Skip to content

Commit

Permalink
Use let and const instead of var in vnc_lite
Browse files Browse the repository at this point in the history
The rest of noVNC has been converted already. This allows us to remove
the extra scope that was created for the VNC connection.
  • Loading branch information
samhed committed Aug 28, 2018
1 parent 6517c49 commit 25551b6
Showing 1 changed file with 35 additions and 37 deletions.
72 changes: 35 additions & 37 deletions vnc_lite.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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>

Expand Down

0 comments on commit 25551b6

Please sign in to comment.