Merge d2cf5ecdf3 into e15950a8ef
This commit is contained in:
commit
e7882e1929
34
app/ui.js
34
app/ui.js
|
|
@ -153,6 +153,38 @@ const UI = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If novnc is hosted at PATHNAME, the default ws path should be at WS:
|
||||||
|
* PATHNAME WS
|
||||||
|
* / /websockify
|
||||||
|
* /foo/myvnc /foo/myvnc/websockify
|
||||||
|
* /foo/myvnc/
|
||||||
|
* /foo/myvnc/vnc.html
|
||||||
|
*/
|
||||||
|
var path = 'websockify';
|
||||||
|
var landing_page = 'vnc.html';
|
||||||
|
// If noVNC is not being served at the root path, prefix
|
||||||
|
// the default websocket path with the server path.
|
||||||
|
var pathName = window.location.pathname.slice(1);
|
||||||
|
if (pathName.length != 0) { // We are not at the root path
|
||||||
|
if (pathName.slice(-1) == '/') {
|
||||||
|
// There's a trailing slash.
|
||||||
|
path = pathName + path;
|
||||||
|
} else {
|
||||||
|
// If there is no trailing slash, we may not be at a directory.
|
||||||
|
var pathElements = pathName.split('/');
|
||||||
|
var pathLast = pathElements.pop();
|
||||||
|
|
||||||
|
// If we are at our landing page, rewind to its parent
|
||||||
|
// directory. Otherwise we assume we are already in a directory.
|
||||||
|
if (pathLast == landing_page) {
|
||||||
|
pathName = pathElements.join('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
path = pathName + '/' + path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Populate the controls if defaults are provided in the URL */
|
/* Populate the controls if defaults are provided in the URL */
|
||||||
UI.initSetting('host', window.location.hostname);
|
UI.initSetting('host', window.location.hostname);
|
||||||
UI.initSetting('port', port);
|
UI.initSetting('port', port);
|
||||||
|
|
@ -161,7 +193,7 @@ const UI = {
|
||||||
UI.initSetting('resize', 'off');
|
UI.initSetting('resize', 'off');
|
||||||
UI.initSetting('shared', true);
|
UI.initSetting('shared', true);
|
||||||
UI.initSetting('view_only', false);
|
UI.initSetting('view_only', false);
|
||||||
UI.initSetting('path', 'websockify');
|
UI.initSetting('path', path);
|
||||||
UI.initSetting('repeaterID', '');
|
UI.initSetting('repeaterID', '');
|
||||||
UI.initSetting('reconnect', false);
|
UI.initSetting('reconnect', false);
|
||||||
UI.initSetting('reconnect_delay', 5000);
|
UI.initSetting('reconnect_delay', 5000);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue