forked from matrix/element-web
Show most homeserver options on the mobile guide
This doesn't cover default_server_name because that pulls in a questionable amount of JS. See https://github.com/vector-im/riot-web/issues/9290
This commit is contained in:
parent
886828caa8
commit
559416dcae
|
@ -4,6 +4,11 @@
|
|||
|
||||
<style type="text/css">
|
||||
|
||||
/* By default, hide the custom IS stuff - enabled in JS */
|
||||
#custom_is, #is_url {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #c5e0f7;
|
||||
background: -moz-linear-gradient(top, #c5e0f7 0%, #ffffff 100%);
|
||||
|
@ -109,6 +114,14 @@ body {
|
|||
margin: 20px;
|
||||
}
|
||||
|
||||
.mx_HomePage_errorContainer {
|
||||
display: none; /* shown in JS if needed */
|
||||
margin: 20px;
|
||||
border: 1px solid red;
|
||||
background-color: #ffb9b9;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.mx_HomePage_container h1,
|
||||
.mx_HomePage_container h2,
|
||||
.mx_HomePage_container h3,
|
||||
|
@ -152,6 +165,10 @@ body {
|
|||
|
||||
<body>
|
||||
|
||||
<div class="mx_HomePage_errorContainer">
|
||||
<!-- populated by JS if needed -->
|
||||
</div>
|
||||
|
||||
<div class="mx_HomePage_container">
|
||||
<div class="mx_HomePage_col mx_HomePage_header">
|
||||
<a href="https://riot.im">
|
||||
|
@ -365,7 +382,9 @@ body {
|
|||
<p>Launch the app, and enable <strong>Use custom server options (advanced)</strong>.</p>
|
||||
<p class="mx_Spacer">In the homeserver field, enter:</p>
|
||||
<p><strong id="hs_url"></strong></p>
|
||||
<p class="mx_Spacer"><em>Note: You shouldn't need to modify the identity server field, which by default is set to https://vector.im.</em></p>
|
||||
<p class="mx_Spacer" id="default_is"><em>Note: You shouldn't need to modify the identity server field, which by default is set to https://vector.im.</em></p>
|
||||
<p class="mx_Spacer" id="custom_is">In the identity server field, enter:</p>
|
||||
<p><strong id="is_url"></strong></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -6,19 +6,84 @@ function onBackToRiotClick() {
|
|||
window.location.href = '../';
|
||||
}
|
||||
|
||||
// NEVER pass user-controlled content to this function! Hardcoded strings only please.
|
||||
function renderConfigError(message) {
|
||||
const contactMsg = "If this is unexpected, please contact your system administrator " +
|
||||
"or technical support representative.";
|
||||
message = `<h2>Error loading Riot</h2><p>${message}</p><p>${contactMsg}</p>`;
|
||||
|
||||
const toHide = document.getElementsByClassName("mx_HomePage_container");
|
||||
const errorContainers = document.getElementsByClassName("mx_HomePage_errorContainer");
|
||||
|
||||
for (const e of toHide) {
|
||||
// We have to clear the content because .style.display='none'; doesn't work
|
||||
// due to an !important in the CSS.
|
||||
e.innerHTML = '';
|
||||
}
|
||||
for (const e of errorContainers) {
|
||||
e.style.display = 'block';
|
||||
e.innerHTML = message;
|
||||
}
|
||||
}
|
||||
|
||||
async function initPage() {
|
||||
document.getElementById('back_to_riot_button').onclick = onBackToRiotClick;
|
||||
|
||||
const config = await getVectorConfig('..');
|
||||
let hsUrl;
|
||||
if (config && config['default_hs_url']) {
|
||||
hsUrl = config['default_hs_url'];
|
||||
let config = await getVectorConfig('..');
|
||||
|
||||
// We manually parse the config similar to how validateServerConfig works because
|
||||
// calling that function pulls in roughly 4mb of JS we don't use.
|
||||
|
||||
const wkConfig = config['default_server_config']; // overwritten later under some conditions
|
||||
const serverName = config['default_server_name'];
|
||||
const defaultHsUrl = config['default_hs_url'];
|
||||
const defaultIsUrl = config['default_is_url'];
|
||||
|
||||
const incompatibleOptions = [wkConfig, serverName, defaultHsUrl].filter(i => !!i);
|
||||
if (incompatibleOptions.length > 1) {
|
||||
return renderConfigError(
|
||||
"Invalid configuration: can only specify one of default_server_config, default_server_name, " +
|
||||
"or default_hs_url.",
|
||||
);
|
||||
}
|
||||
if (incompatibleOptions.length < 1) {
|
||||
return renderConfigError("Invalid configuration: no default server specified.");
|
||||
}
|
||||
|
||||
let hsUrl = '';
|
||||
let isUrl = '';
|
||||
|
||||
if (wkConfig && wkConfig['m.homeserver']) {
|
||||
hsUrl = wkConfig['m.homeserver']['base_url'];
|
||||
|
||||
if (wkConfig['m.identity_server']) {
|
||||
isUrl = wkConfig['m.identity_server']['base_url'];
|
||||
}
|
||||
}
|
||||
|
||||
if (serverName) {
|
||||
// TODO: TravisR .well-known lookup
|
||||
}
|
||||
|
||||
if (defaultHsUrl) {
|
||||
hsUrl = defaultHsUrl;
|
||||
isUrl = defaultIsUrl;
|
||||
}
|
||||
|
||||
if (hsUrl && !hsUrl.endsWith('/')) hsUrl += '/';
|
||||
if (isUrl && !isUrl.endsWith('/')) isUrl += '/';
|
||||
|
||||
if (hsUrl && hsUrl !== 'https://matrix.org/') {
|
||||
document.getElementById('step2_container').style.display = 'block';
|
||||
document.getElementById('hs_url').innerHTML = hsUrl;
|
||||
document.getElementById('hs_url').innerText = hsUrl;
|
||||
document.getElementById('step_login_header').innerHTML= 'Step 3: Register or Log in';
|
||||
|
||||
if (isUrl && isUrl !== "https://vector.im/") {
|
||||
document.getElementById('default_is').style.display = 'none';
|
||||
document.getElementById('custom_is').style.display = 'block';
|
||||
document.getElementById('is_url').style.display = 'block';
|
||||
document.getElementById('is_url').innerText = isUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue