diff --git a/app/ui.js b/app/ui.js
index 316042911..df3425d86 100644
--- a/app/ui.js
+++ b/app/ui.js
@@ -24,6 +24,8 @@ const LINGUAS = ["cs", "de", "el", "es", "fr", "it", "ja", "ko", "nl", "pl", "pt
const UI = {
+ userSettings: {},
+
connected: false,
desktopName: "",
@@ -44,7 +46,15 @@ const UI = {
reconnectCallback: null,
reconnectPassword: null,
- async start() {
+ async start(options={}) {
+ UI.userSettings = options.settings || {};
+ if (UI.userSettings.defaults === undefined) {
+ UI.userSettings.defaults = {};
+ }
+ if (UI.userSettings.forced === undefined) {
+ UI.userSettings.forced = {};
+ }
+
// Set up translations
try {
await l10n.setup(LINGUAS, "app/locale/");
@@ -159,6 +169,8 @@ const UI = {
UI.initSetting('logging', 'warn');
UI.updateLogging();
+ UI.setupSettingLabels();
+
/* Populate the controls if defaults are provided in the URL */
UI.initSetting('encrypt', (window.location.protocol === "https:"));
UI.initSetting('password');
@@ -175,8 +187,6 @@ const UI = {
UI.initSetting('repeaterID', '');
UI.initSetting('reconnect', false);
UI.initSetting('reconnect_delay', 5000);
-
- UI.setupSettingLabels();
},
// Adds a link to the label elements on the corresponding input elements
setupSettingLabels() {
@@ -738,6 +748,10 @@ const UI = {
// Initial page load read/initialization of settings
initSetting(name, defVal) {
+ // Has the user overridden the default value?
+ if (name in UI.userSettings.defaults) {
+ defVal = UI.userSettings.defaults[name];
+ }
// Check Query string followed by cookie
let val = WebUtil.getConfigVar(name);
if (val === null) {
@@ -745,6 +759,11 @@ const UI = {
}
WebUtil.setSetting(name, val);
UI.updateSetting(name);
+ // Has the user forced a value?
+ if (name in UI.userSettings.forced) {
+ val = UI.userSettings.forced[name];
+ UI.forceSetting(name, val);
+ }
return val;
},
@@ -817,17 +836,21 @@ const UI = {
// disable the labels that belong to disabled input elements.
disableSetting(name) {
const ctrl = document.getElementById('noVNC_setting_' + name);
- ctrl.disabled = true;
- if (ctrl.label !== undefined) {
- ctrl.label.classList.add('noVNC_disabled');
+ if (ctrl !== null) {
+ ctrl.disabled = true;
+ if (ctrl.label !== undefined) {
+ ctrl.label.classList.add('noVNC_disabled');
+ }
}
},
enableSetting(name) {
const ctrl = document.getElementById('noVNC_setting_' + name);
- ctrl.disabled = false;
- if (ctrl.label !== undefined) {
- ctrl.label.classList.remove('noVNC_disabled');
+ if (ctrl !== null) {
+ ctrl.disabled = false;
+ if (ctrl.label !== undefined) {
+ ctrl.label.classList.remove('noVNC_disabled');
+ }
}
},
@@ -1771,6 +1794,4 @@ const UI = {
*/
};
-UI.start();
-
export default UI;
diff --git a/vnc.html b/vnc.html
index 89ee11e36..54ac2e48c 100644
--- a/vnc.html
+++ b/vnc.html
@@ -46,7 +46,25 @@
-
+
+