Skip to content

Commit 28d4020

Browse files
committed
Load settings from web server
Make it even easier to customize things by loading the settings from separate configuration files.
1 parent 438e5b3 commit 28d4020

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

defaults.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

mandatory.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

vnc.html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,40 @@
4949

5050
<script type="module">
5151
import UI from "./app/ui.js";
52+
import * as Log from './core/util/logging.js';
53+
54+
let response;
5255

5356
let defaults = {};
5457
let mandatory = {};
5558

56-
// Override any defaults you need here:
59+
// Default settings will be loaded from defaults.json. Mandatory
60+
// settings will be loaded from mandatory.json, which the user
61+
// cannot change.
62+
63+
try {
64+
response = await fetch('./defaults.json');
65+
if (!response.ok) {
66+
throw Error("" + response.status + " " + response.statusText);
67+
}
68+
69+
defaults = await response.json();
70+
} catch (err) {
71+
Log.Error("Couldn't fetch defaults.json: " + err);
72+
}
73+
74+
try {
75+
response = await fetch('./mandatory.json');
76+
if (!response.ok) {
77+
throw Error("" + response.status + " " + response.statusText);
78+
}
79+
80+
mandatory = await response.json();
81+
} catch (err) {
82+
Log.Error("Couldn't fetch mandatory.json: " + err);
83+
}
84+
85+
// You can also override any defaults you need here:
5786
//
5887
// defaults['host'] = 'vnc.example.com';
5988

0 commit comments

Comments
 (0)