Add way to set default values short of forking the whole project

This commit is contained in:
Jonas Herzig 2018-10-08 18:10:56 +02:00
parent ae1479368c
commit f739ff9345
8 changed files with 40 additions and 4 deletions

20
app/config.js Normal file
View file

@ -0,0 +1,20 @@
// Note: You probably do not want to change any values in here because this
// file might need to be updated with new default values for new
// configuration options. Use the [config.local.js] file instead!
window.mumbleWebConfig = {
// Default values (can be changed by passing a query parameter of the same name)
'defaults': {
// Connect Dialog
'address': '',
'port': '443',
'token': '',
'username': '',
'password': '',
'joinDialog': false, // replace whole dialog with single "Join Conference" button
'matrix': false, // enable Matrix Widget support (mostly auto-detected; implies 'joinDialog')
'avatarurl': '', // download and set the user's Mumble avatar to the image at this URL
// General
'theme': 'MetroMumbleLight'
}
}

9
app/config.local.js Normal file
View file

@ -0,0 +1,9 @@
// You can overwrite the default configuration values set in [config.js] here.
// There should never be any required changes to this file and you can always
// simply copy it over when updating to a new version.
let config = window.mumbleWebConfig // eslint-disable-line no-unused-vars
// E.g. changing default address and theme:
// config.defaults.address = 'voice.example.com'
// config.defaults.theme = 'MetroMumbleDark'

View file

@ -13,8 +13,9 @@
<meta name="msapplication-config" content="${require('./favicon/browserconfig.xml')}">
<meta name="theme-color" content="#ffffff">
<script src="config.js"></script>
<script src="config.local.js"></script>
<script src="theme.js"></script>
<script src="matrix.js"></script>
</head>
<body>

View file

@ -51,7 +51,7 @@ function ContextMenu () {
function ConnectDialog () {
var self = this
self.address = ko.observable('')
self.port = ko.observable('443')
self.port = ko.observable('')
self.token = ko.observable('')
self.username = ko.observable('')
self.password = ko.observable('')
@ -867,6 +867,7 @@ window.mumbleUi = ui
window.onload = function () {
var queryParams = url.parse(document.location.href, true).query
queryParams = Object.assign({}, window.mumbleWebConfig.defaults, queryParams)
var useJoinDialog = queryParams.joinDialog
if (queryParams.matrix) {
useJoinDialog = true

View file

@ -8,7 +8,7 @@ var themes = {
'light': 'MetroMumbleLight',
'dark': 'MetroMumbleDark'
}
theme = themes[theme] || 'MetroMumbleLight'
theme = themes[theme] || window.mumbleWebConfig.defaults.theme
window.theme = theme
var [loadingTheme, mainTheme] = {