a whole load of work in progress
This commit is contained in:
parent
caec0b8ac9
commit
26ba098183
63 changed files with 3234 additions and 321 deletions
36
static/welcome.js
Normal file
36
static/welcome.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { isUserLoggedIn, registerUser } from "./session.js";
|
||||
|
||||
export class Welcome extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.dialog = this.querySelector("dialog[name='welcome-dialog']");
|
||||
this.form = this.dialog.querySelector("form");
|
||||
this.nicknameField = this.querySelector("input[name='nickname']");
|
||||
this.registerButton = this.querySelector("button[name='register']");
|
||||
this.registerProgress = this.querySelector("rkgk-throbber[name='register-progress']");
|
||||
|
||||
if (!isUserLoggedIn()) {
|
||||
this.dialog.showModal();
|
||||
|
||||
// Require an account to use the website.
|
||||
this.dialog.addEventListener("close", (event) => event.preventDefault());
|
||||
|
||||
this.form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
this.registerProgress.beginLoading();
|
||||
let response = await registerUser(this.nicknameField.value);
|
||||
if (response.status != "ok") {
|
||||
this.registerProgress.showError(response.message);
|
||||
}
|
||||
|
||||
this.dialog.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("rkgk-welcome", Welcome);
|
Loading…
Add table
Add a link
Reference in a new issue