Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ function setupConnection(connection, errorMessage) {
hide('#info');
show(errorMessage);
}));

if (Settings.load('skipInfo', false)) {
setTimeout(() => {
document.querySelector('#connect').click()
}, 2000)
}

on(window, 'beforeunload', e =>
connection.disconnect());
Expand Down
18 changes: 18 additions & 0 deletions js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ function setupButton(setting, title) {
}

export function load(setting, defaultValue) {
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.has(setting)) {
const urlValue = urlParams.get(setting)
if (typeof defaultValue == 'boolean') {
defaultValue = JSON.parse(urlValue) // parse true/false
} else if (setting == 'inputMap') {
defaultValue = {
...defaultValue,
...JSON.parse(urlValue)
}
} else {
defaultValue = urlParams.get(setting)
}
}
let value = localStorage[setting];
value = value === undefined ? defaultValue : JSON.parse(value);
values[setting] = value;
Expand All @@ -121,5 +135,9 @@ export function onChange(setting, action) {
}

export function get(setting) {
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.has(setting)) {
return urlParams.get(setting)
}
return values[setting];
}
2 changes: 2 additions & 0 deletions js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export function appendButton(target, title, onClick) {
on(button, 'click', onClick);

if (typeof target === 'string') {

target = document.querySelector(target)

}

target.append(button);
Expand Down