using const instead of let

This commit is contained in:
2021-05-24 13:40:56 +02:00
parent eea681d435
commit 9987086bf0

View File

@ -14,7 +14,7 @@ export class App {
this.defaultLocation = '/welcome';
this.account = null;
} else {
let session = JSON.parse(localStorage.session);
const session = JSON.parse(localStorage.session);
this.defaultLocation = '/';
this.account = session.account;
}
@ -30,7 +30,7 @@ export class App {
}
setHash(hash) {
let url = new URL(document.URL);
const url = new URL(document.URL);
url.hash = hash;
location.href = url.toString();
}
@ -42,7 +42,7 @@ export class App {
handleHash(hash) {
if (hash[0] === '#') hash = hash.substr(1);
let defaultCase = () => {
const defaultCase = () => {
history.replaceState(null, null, `#${this.defaultLocation}`);
this.handleHash(this.defaultLocation);
}
@ -92,11 +92,11 @@ export class App {
}
}
let session = new USIMP.Session(domain);
let rtt = await session.chooseDomainServer();
const session = new USIMP.Session(domain);
const rtt = await session.chooseDomainServer();
console.log(rtt);
let response = await session.authenticate(accountName, password);
const response = await session.authenticate(accountName, password);
if (response.status === "success") {
this.session = session;
this.defaultLocation = "/";
@ -127,7 +127,7 @@ export class App {
}
addWelcomeWindow() {
let win = document.createElement("div");
const win = document.createElement("div");
win.classList.add("window-welcome");
win.innerHTML = `
@ -138,18 +138,18 @@ export class App {
}
addMessage(message) {
let msg = document.createElement("div");
const msg = document.createElement("div");
msg.classList.add("message");
msg.innerText = message;
let chat = this.main.getElementsByClassName("chat-history")[0];
const chat = this.main.getElementsByClassName("chat-history")[0];
chat.appendChild(msg);
chat.scrollTop = chat.scrollHeight;
}
addLoginWindow() {
let win = document.createElement("div");
const win = document.createElement("div");
win.classList.add("window-login");
win.innerHTML = `
@ -161,17 +161,20 @@ export class App {
<button type="submit">Login</button>
</form>`;
win.getElementsByTagName("form")[0].addEventListener("submit", async (evt) => {
evt.preventDefault();
let form = evt.target;
for (let e of form) e.disabled = true;
win.getElementsByTagName("form")[0].addEventListener("submit", async (event) => {
event.preventDefault();
const form = event.target;
for (const e of form) {
e.disabled = true;
e.removeAttribute("invalid");
}
for (let d of form.getElementsByTagName("div")) {
for (const d of form.getElementsByTagName("div")) {
form.removeChild(d);
}
function formError(msg) {
let div = document.createElement("div");
const div = document.createElement("div");
div.classList.add("error");
div.innerText = msg;
form.appendChild(div);
@ -186,9 +189,8 @@ export class App {
document.getElementsByName("domain")[0].setAttribute("invalid", "invalid");
}
formError(error.toString());
console.error(error);
} finally {
for (let e of form) e.disabled = false;
for (const e of form) e.disabled = false;
}
});
@ -214,7 +216,7 @@ export class App {
</div>
</div>`;
let input = document.getElementsByName("message")[0];
const input = document.getElementsByName("message")[0];
input.addEventListener("keyup", (event) => {
if (event.key === "Enter" && input.value.length > 0) {
this.session.sendEvent("60nc0XXDIYUh6QzX4p0rMpCdzDmxghZLZk8dLuQh628", {