Apply prettier formatting
This commit is contained in:
parent
a32f12c8f3
commit
7921a6cbf8
104 changed files with 12169 additions and 11047 deletions
File diff suppressed because one or more lines are too long
|
@ -1,17 +1,17 @@
|
|||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { getVectorConfig } from '../getconfig';
|
||||
import { getVectorConfig } from "../getconfig";
|
||||
|
||||
function onBackToElementClick(): void {
|
||||
// Cookie should expire in 4 hours
|
||||
document.cookie = 'element_mobile_redirect_to_guide=false;path=/;max-age=14400';
|
||||
window.location.href = '../';
|
||||
document.cookie = "element_mobile_redirect_to_guide=false;path=/;max-age=14400";
|
||||
window.location.href = "../";
|
||||
}
|
||||
|
||||
// NEVER pass user-controlled content to this function! Hardcoded strings only please.
|
||||
function renderConfigError(message: string): void {
|
||||
const contactMsg = "If this is unexpected, please contact your system administrator " +
|
||||
"or technical support representative.";
|
||||
const contactMsg =
|
||||
"If this is unexpected, please contact your system administrator " + "or technical support representative.";
|
||||
message = `<h2>Error loading Element</h2><p>${message}</p><p>${contactMsg}</p>`;
|
||||
|
||||
const toHide = document.getElementsByClassName("mx_HomePage_container");
|
||||
|
@ -22,46 +22,46 @@ function renderConfigError(message: string): void {
|
|||
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 = '';
|
||||
e.innerHTML = "";
|
||||
}
|
||||
for (const e of errorContainers) {
|
||||
e.style.display = 'block';
|
||||
e.style.display = "block";
|
||||
e.innerHTML = message;
|
||||
}
|
||||
}
|
||||
|
||||
async function initPage(): Promise<void> {
|
||||
document.getElementById('back_to_element_button').onclick = onBackToElementClick;
|
||||
document.getElementById("back_to_element_button").onclick = onBackToElementClick;
|
||||
|
||||
const config = await getVectorConfig('..');
|
||||
const 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 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);
|
||||
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.",
|
||||
"or default_hs_url.",
|
||||
);
|
||||
}
|
||||
if (incompatibleOptions.length < 1) {
|
||||
return renderConfigError("Invalid configuration: no default server specified.");
|
||||
}
|
||||
|
||||
let hsUrl = '';
|
||||
let isUrl = '';
|
||||
let hsUrl = "";
|
||||
let isUrl = "";
|
||||
|
||||
if (wkConfig && wkConfig['m.homeserver']) {
|
||||
hsUrl = wkConfig['m.homeserver']['base_url'];
|
||||
if (wkConfig && wkConfig["m.homeserver"]) {
|
||||
hsUrl = wkConfig["m.homeserver"]["base_url"];
|
||||
|
||||
if (wkConfig['m.identity_server']) {
|
||||
isUrl = wkConfig['m.identity_server']['base_url'];
|
||||
if (wkConfig["m.identity_server"]) {
|
||||
isUrl = wkConfig["m.identity_server"]["base_url"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,11 +70,11 @@ async function initPage(): Promise<void> {
|
|||
try {
|
||||
const result = await fetch(`https://${serverName}/.well-known/matrix/client`);
|
||||
const wkConfig = await result.json();
|
||||
if (wkConfig && wkConfig['m.homeserver']) {
|
||||
hsUrl = wkConfig['m.homeserver']['base_url'];
|
||||
if (wkConfig && wkConfig["m.homeserver"]) {
|
||||
hsUrl = wkConfig["m.homeserver"]["base_url"];
|
||||
|
||||
if (wkConfig['m.identity_server']) {
|
||||
isUrl = wkConfig['m.identity_server']['base_url'];
|
||||
if (wkConfig["m.identity_server"]) {
|
||||
isUrl = wkConfig["m.identity_server"]["base_url"];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -92,21 +92,20 @@ async function initPage(): Promise<void> {
|
|||
return renderConfigError("Unable to locate homeserver");
|
||||
}
|
||||
|
||||
if (hsUrl && !hsUrl.endsWith('/')) hsUrl += '/';
|
||||
if (isUrl && !isUrl.endsWith('/')) isUrl += '/';
|
||||
if (hsUrl && !hsUrl.endsWith("/")) hsUrl += "/";
|
||||
if (isUrl && !isUrl.endsWith("/")) isUrl += "/";
|
||||
|
||||
if (hsUrl !== 'https://matrix.org/') {
|
||||
(document.getElementById('configure_element_button') as HTMLAnchorElement).href =
|
||||
"https://mobile.element.io?hs_url=" + encodeURIComponent(hsUrl) +
|
||||
"&is_url=" + encodeURIComponent(isUrl);
|
||||
document.getElementById('step1_heading').innerHTML= '1: Install the app';
|
||||
document.getElementById('step2_container').style.display = 'block';
|
||||
document.getElementById('hs_url').innerText = hsUrl;
|
||||
if (hsUrl !== "https://matrix.org/") {
|
||||
(document.getElementById("configure_element_button") as HTMLAnchorElement).href =
|
||||
"https://mobile.element.io?hs_url=" + encodeURIComponent(hsUrl) + "&is_url=" + encodeURIComponent(isUrl);
|
||||
document.getElementById("step1_heading").innerHTML = "1: Install the app";
|
||||
document.getElementById("step2_container").style.display = "block";
|
||||
document.getElementById("hs_url").innerText = hsUrl;
|
||||
|
||||
if (isUrl) {
|
||||
document.getElementById('custom_is').style.display = 'block';
|
||||
document.getElementById('is_url').style.display = 'block';
|
||||
document.getElementById('is_url').innerText = isUrl;
|
||||
document.getElementById("custom_is").style.display = "block";
|
||||
document.getElementById("is_url").style.display = "block";
|
||||
document.getElementById("is_url").innerText = isUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue