1
0
mirror of https://github.com/novnc/noVNC.git synced 2025-04-18 23:44:01 +03:00

Load settings from web server

Make it even easier to customize things by loading the settings from
separate configuration files.
This commit is contained in:
Pierre Ossman 2024-08-08 16:20:51 +02:00
parent 438e5b3608
commit 28d4020302
3 changed files with 32 additions and 1 deletions

1
defaults.json Normal file
View File

@ -0,0 +1 @@
{}

1
mandatory.json Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -49,11 +49,40 @@
<script type="module">
import UI from "./app/ui.js";
import * as Log from './core/util/logging.js';
let response;
let defaults = {};
let mandatory = {};
// Override any defaults you need here:
// Default settings will be loaded from defaults.json. Mandatory
// settings will be loaded from mandatory.json, which the user
// cannot change.
try {
response = await fetch('./defaults.json');
if (!response.ok) {
throw Error("" + response.status + " " + response.statusText);
}
defaults = await response.json();
} catch (err) {
Log.Error("Couldn't fetch defaults.json: " + err);
}
try {
response = await fetch('./mandatory.json');
if (!response.ok) {
throw Error("" + response.status + " " + response.statusText);
}
mandatory = await response.json();
} catch (err) {
Log.Error("Couldn't fetch mandatory.json: " + err);
}
// You can also override any defaults you need here:
//
// defaults['host'] = 'vnc.example.com';