Skip to content

Commit

Permalink
Load settings from web server
Browse files Browse the repository at this point in the history
Make it even easier to customize things by loading the settings from
separate configuration files.
  • Loading branch information
CendioOssman committed Aug 8, 2024
1 parent 5f3ec21 commit 3bef61e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions mandatory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
31 changes: 30 additions & 1 deletion vnc.html
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 3bef61e

Please sign in to comment.