2021-01-05 18:16:23 +00:00
|
|
|
import { Modal } from "./modules/modal.js";
|
2021-05-07 13:32:51 +00:00
|
|
|
import { notificationBox, whichAnimationEvent } from "./modules/common.js";
|
2021-05-29 16:43:11 +00:00
|
|
|
import { _get, _post, toggleLoader, addLoader, removeLoader, toDateString } from "./modules/common.js";
|
2021-01-12 23:43:44 +00:00
|
|
|
import { loadLangSelector } from "./modules/lang.js";
|
2021-06-05 21:17:10 +00:00
|
|
|
import { initValidator } from "./modules/validator.js";
|
2020-10-22 16:50:40 +00:00
|
|
|
|
|
|
|
interface formWindow extends Window {
|
2020-11-04 20:46:06 +00:00
|
|
|
invalidPassword: string;
|
2021-05-07 00:08:12 +00:00
|
|
|
successModal: Modal;
|
|
|
|
telegramModal: Modal;
|
2021-05-21 20:35:25 +00:00
|
|
|
discordModal: Modal;
|
2021-05-29 16:43:11 +00:00
|
|
|
matrixModal: Modal;
|
2021-05-07 00:08:12 +00:00
|
|
|
confirmationModal: Modal
|
2021-01-14 14:22:20 +00:00
|
|
|
code: string;
|
2021-01-25 18:01:18 +00:00
|
|
|
messages: { [key: string]: string };
|
2021-01-30 19:19:12 +00:00
|
|
|
confirmation: boolean;
|
2021-05-07 00:08:12 +00:00
|
|
|
telegramRequired: boolean;
|
|
|
|
telegramPIN: string;
|
2021-05-21 20:35:25 +00:00
|
|
|
discordRequired: boolean;
|
|
|
|
discordPIN: string;
|
|
|
|
discordStartCommand: string;
|
2021-05-23 18:50:03 +00:00
|
|
|
discordInviteLink: boolean;
|
|
|
|
discordServerName: string;
|
2021-05-29 16:43:11 +00:00
|
|
|
matrixRequired: boolean;
|
|
|
|
matrixUserID: string;
|
2021-02-28 15:41:06 +00:00
|
|
|
userExpiryEnabled: boolean;
|
2021-04-08 19:43:01 +00:00
|
|
|
userExpiryMonths: number;
|
2021-02-28 15:41:06 +00:00
|
|
|
userExpiryDays: number;
|
|
|
|
userExpiryHours: number;
|
|
|
|
userExpiryMinutes: number;
|
|
|
|
userExpiryMessage: string;
|
2021-12-20 18:44:31 +00:00
|
|
|
emailRequired: boolean;
|
2022-01-10 01:55:48 +00:00
|
|
|
captcha: boolean;
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 23:43:44 +00:00
|
|
|
loadLangSelector("form");
|
2021-01-11 19:17:43 +00:00
|
|
|
|
2021-05-07 00:08:12 +00:00
|
|
|
window.notifications = new notificationBox(document.getElementById("notification-box") as HTMLDivElement);
|
|
|
|
|
2021-05-07 13:32:51 +00:00
|
|
|
window.animationEvent = whichAnimationEvent();
|
|
|
|
|
2021-05-07 00:08:12 +00:00
|
|
|
window.successModal = new Modal(document.getElementById("modal-success"), true);
|
|
|
|
|
2021-12-20 18:44:31 +00:00
|
|
|
|
2021-05-07 13:32:51 +00:00
|
|
|
var telegramVerified = false;
|
2021-05-07 00:08:12 +00:00
|
|
|
if (window.telegramEnabled) {
|
|
|
|
window.telegramModal = new Modal(document.getElementById("modal-telegram"), window.telegramRequired);
|
2021-05-07 13:32:51 +00:00
|
|
|
const telegramButton = document.getElementById("link-telegram") as HTMLSpanElement;
|
|
|
|
telegramButton.onclick = () => {
|
2021-05-07 00:08:12 +00:00
|
|
|
const waiting = document.getElementById("telegram-waiting") as HTMLSpanElement;
|
|
|
|
toggleLoader(waiting);
|
|
|
|
window.telegramModal.show();
|
2021-05-07 13:32:51 +00:00
|
|
|
let modalClosed = false;
|
2021-05-07 17:20:35 +00:00
|
|
|
window.telegramModal.onclose = () => {
|
|
|
|
modalClosed = true;
|
|
|
|
toggleLoader(waiting);
|
|
|
|
}
|
2021-05-07 00:08:12 +00:00
|
|
|
const checkVerified = () => _get("/invite/" + window.code + "/telegram/verified/" + window.telegramPIN, null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status == 401) {
|
|
|
|
window.telegramModal.close();
|
2021-05-07 13:32:51 +00:00
|
|
|
window.notifications.customError("invalidCodeError", window.messages["errorInvalidCode"]);
|
2021-05-07 00:08:12 +00:00
|
|
|
return;
|
|
|
|
} else if (req.status == 200) {
|
|
|
|
if (req.response["success"] as boolean) {
|
2021-05-07 13:32:51 +00:00
|
|
|
telegramVerified = true;
|
|
|
|
waiting.classList.add("~positive");
|
|
|
|
waiting.classList.remove("~info");
|
2021-05-21 20:35:25 +00:00
|
|
|
window.notifications.customPositive("telegramVerified", "", window.messages["verified"]);
|
2021-05-07 13:32:51 +00:00
|
|
|
setTimeout(window.telegramModal.close, 2000);
|
|
|
|
telegramButton.classList.add("unfocused");
|
|
|
|
document.getElementById("contact-via").classList.remove("unfocused");
|
2022-01-27 16:56:13 +00:00
|
|
|
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
2021-05-07 13:32:51 +00:00
|
|
|
const radio = document.getElementById("contact-via-telegram") as HTMLInputElement;
|
2022-01-27 16:56:13 +00:00
|
|
|
radio.parentElement.classList.remove("unfocused");
|
2021-05-07 13:32:51 +00:00
|
|
|
radio.checked = true;
|
2022-01-27 16:48:46 +00:00
|
|
|
validatorFunc();
|
2021-05-07 13:32:51 +00:00
|
|
|
} else if (!modalClosed) {
|
2021-05-07 00:08:12 +00:00
|
|
|
setTimeout(checkVerified, 1500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
checkVerified();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-23 18:50:03 +00:00
|
|
|
interface DiscordInvite {
|
|
|
|
invite: string;
|
|
|
|
icon: string;
|
|
|
|
}
|
|
|
|
|
2021-05-21 20:35:25 +00:00
|
|
|
var discordVerified = false;
|
|
|
|
if (window.discordEnabled) {
|
|
|
|
window.discordModal = new Modal(document.getElementById("modal-discord"), window.discordRequired);
|
|
|
|
const discordButton = document.getElementById("link-discord") as HTMLSpanElement;
|
2021-05-23 18:50:03 +00:00
|
|
|
if (window.discordInviteLink) {
|
|
|
|
_get("/invite/" + window.code + "/discord/invite", null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status != 200) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const inv = req.response as DiscordInvite;
|
|
|
|
const link = document.getElementById("discord-invite") as HTMLAnchorElement;
|
|
|
|
link.classList.add("subheading", "link-center");
|
|
|
|
link.href = inv.invite;
|
|
|
|
link.target = "_blank";
|
2021-12-31 00:22:28 +00:00
|
|
|
link.innerHTML = `<span class="img-circle lg mr-4"><img class="img-circle" src="${inv.icon}" width="64" height="64"></span>${window.discordServerName}`;
|
2021-05-23 18:50:03 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-05-21 20:35:25 +00:00
|
|
|
discordButton.onclick = () => {
|
|
|
|
const waiting = document.getElementById("discord-waiting") as HTMLSpanElement;
|
|
|
|
toggleLoader(waiting);
|
|
|
|
window.discordModal.show();
|
|
|
|
let modalClosed = false;
|
|
|
|
window.discordModal.onclose = () => {
|
|
|
|
modalClosed = true;
|
|
|
|
toggleLoader(waiting);
|
|
|
|
}
|
|
|
|
const checkVerified = () => _get("/invite/" + window.code + "/discord/verified/" + window.discordPIN, null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status == 401) {
|
|
|
|
window.discordModal.close();
|
|
|
|
window.notifications.customError("invalidCodeError", window.messages["errorInvalidCode"]);
|
|
|
|
return;
|
|
|
|
} else if (req.status == 200) {
|
|
|
|
if (req.response["success"] as boolean) {
|
|
|
|
discordVerified = true;
|
|
|
|
waiting.classList.add("~positive");
|
|
|
|
waiting.classList.remove("~info");
|
|
|
|
window.notifications.customPositive("discordVerified", "", window.messages["verified"]);
|
|
|
|
setTimeout(window.discordModal.close, 2000);
|
|
|
|
discordButton.classList.add("unfocused");
|
|
|
|
document.getElementById("contact-via").classList.remove("unfocused");
|
2022-01-27 16:56:13 +00:00
|
|
|
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
2021-05-21 20:35:25 +00:00
|
|
|
const radio = document.getElementById("contact-via-discord") as HTMLInputElement;
|
2022-01-27 16:56:13 +00:00
|
|
|
radio.parentElement.classList.remove("unfocused")
|
2021-05-21 20:35:25 +00:00
|
|
|
radio.checked = true;
|
2022-01-27 16:48:46 +00:00
|
|
|
validatorFunc();
|
2021-05-21 20:35:25 +00:00
|
|
|
} else if (!modalClosed) {
|
|
|
|
setTimeout(checkVerified, 1500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
checkVerified();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-29 16:43:11 +00:00
|
|
|
var matrixVerified = false;
|
|
|
|
var matrixPIN = "";
|
|
|
|
if (window.matrixEnabled) {
|
|
|
|
window.matrixModal = new Modal(document.getElementById("modal-matrix"), window.matrixRequired);
|
|
|
|
const matrixButton = document.getElementById("link-matrix") as HTMLSpanElement;
|
|
|
|
matrixButton.onclick = window.matrixModal.show;
|
|
|
|
const submitButton = document.getElementById("matrix-send") as HTMLSpanElement;
|
|
|
|
const input = document.getElementById("matrix-userid") as HTMLInputElement;
|
|
|
|
let userID = "";
|
|
|
|
submitButton.onclick = () => {
|
|
|
|
addLoader(submitButton);
|
|
|
|
if (userID == "") {
|
|
|
|
const send = {
|
|
|
|
user_id: input.value
|
|
|
|
};
|
|
|
|
_post("/invite/" + window.code + "/matrix/user", send, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
removeLoader(submitButton);
|
|
|
|
userID = input.value;
|
|
|
|
if (req.status != 200) {
|
|
|
|
window.notifications.customError("errorUnknown", window.messages["errorUnknown"]);
|
|
|
|
window.matrixModal.close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
submitButton.classList.add("~positive");
|
|
|
|
submitButton.classList.remove("~info");
|
|
|
|
setTimeout(() => {
|
|
|
|
submitButton.classList.add("~info");
|
|
|
|
submitButton.classList.remove("~positive");
|
|
|
|
}, 2000);
|
|
|
|
input.placeholder = "PIN";
|
|
|
|
input.value = "";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
_get("/invite/" + window.code + "/matrix/verified/" + userID + "/" + input.value, null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
removeLoader(submitButton)
|
|
|
|
const valid = req.response["success"] as boolean;
|
|
|
|
if (valid) {
|
|
|
|
window.matrixModal.close();
|
|
|
|
window.notifications.customPositive("successVerified", "", window.messages["verified"]);
|
|
|
|
matrixVerified = true;
|
|
|
|
matrixPIN = input.value;
|
|
|
|
matrixButton.classList.add("unfocused");
|
|
|
|
document.getElementById("contact-via").classList.remove("unfocused");
|
2022-01-27 16:56:13 +00:00
|
|
|
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
|
|
|
const radio = document.getElementById("contact-via-matrix") as HTMLInputElement;
|
|
|
|
radio.parentElement.classList.remove("unfocused");
|
2021-05-29 16:43:11 +00:00
|
|
|
radio.checked = true;
|
2022-01-27 16:48:46 +00:00
|
|
|
validatorFunc();
|
2021-05-29 16:43:11 +00:00
|
|
|
} else {
|
|
|
|
window.notifications.customError("errorInvalidPIN", window.messages["errorInvalidPIN"]);
|
|
|
|
submitButton.classList.add("~critical");
|
|
|
|
submitButton.classList.remove("~info");
|
|
|
|
setTimeout(() => {
|
|
|
|
submitButton.classList.add("~info");
|
|
|
|
submitButton.classList.remove("~critical");
|
|
|
|
}, 800);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-30 19:19:12 +00:00
|
|
|
if (window.confirmation) {
|
|
|
|
window.confirmationModal = new Modal(document.getElementById("modal-confirmation"), true);
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
declare var window: formWindow;
|
|
|
|
|
2021-02-28 15:41:06 +00:00
|
|
|
if (window.userExpiryEnabled) {
|
|
|
|
const messageEl = document.getElementById("user-expiry-message") as HTMLElement;
|
2021-02-28 00:44:28 +00:00
|
|
|
const calculateTime = () => {
|
|
|
|
let time = new Date()
|
2021-04-08 19:43:01 +00:00
|
|
|
time.setMonth(time.getMonth() + window.userExpiryMonths);
|
2021-02-28 15:41:06 +00:00
|
|
|
time.setDate(time.getDate() + window.userExpiryDays);
|
|
|
|
time.setHours(time.getHours() + window.userExpiryHours);
|
|
|
|
time.setMinutes(time.getMinutes() + window.userExpiryMinutes);
|
2021-04-07 14:17:15 +00:00
|
|
|
messageEl.textContent = window.userExpiryMessage.replace("{date}", toDateString(time));
|
2021-02-28 00:44:28 +00:00
|
|
|
setTimeout(calculateTime, 1000);
|
|
|
|
};
|
|
|
|
calculateTime();
|
|
|
|
}
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
const form = document.getElementById("form-create") as HTMLFormElement;
|
|
|
|
const submitButton = form.querySelector("input[type=submit]") as HTMLInputElement;
|
|
|
|
const submitSpan = form.querySelector("span.submit") as HTMLSpanElement;
|
2022-01-27 16:48:46 +00:00
|
|
|
const submitText = submitSpan.textContent;
|
2021-01-05 18:16:23 +00:00
|
|
|
let usernameField = document.getElementById("create-username") as HTMLInputElement;
|
|
|
|
const emailField = document.getElementById("create-email") as HTMLInputElement;
|
|
|
|
if (!window.usernameEnabled) { usernameField.parentElement.remove(); usernameField = emailField; }
|
|
|
|
const passwordField = document.getElementById("create-password") as HTMLInputElement;
|
|
|
|
const rePasswordField = document.getElementById("create-reenter-password") as HTMLInputElement;
|
|
|
|
|
2022-01-27 16:48:46 +00:00
|
|
|
let captchaVerified = false;
|
|
|
|
let captchaID = "";
|
|
|
|
let captchaInput = document.getElementById("captcha-input") as HTMLInputElement;
|
|
|
|
const captchaCheckbox = document.getElementById("captcha-success") as HTMLSpanElement;
|
|
|
|
let prevCaptcha = "";
|
|
|
|
|
|
|
|
function baseValidator(oncomplete: (valid: boolean) => void): void {
|
|
|
|
let captchaChecked = false;
|
|
|
|
let captchaChange = false;
|
|
|
|
if (window.captcha) {
|
|
|
|
captchaChange = captchaInput.value != prevCaptcha;
|
|
|
|
if (captchaChange) {
|
|
|
|
prevCaptcha = captchaInput.value;
|
|
|
|
_post("/captcha/verify/" + window.code + "/" + captchaID + "/" + captchaInput.value, null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status == 204) {
|
|
|
|
captchaCheckbox.innerHTML = `<i class="ri-check-line"></i>`;
|
|
|
|
captchaCheckbox.classList.add("~positive");
|
|
|
|
captchaCheckbox.classList.remove("~critical");
|
|
|
|
captchaVerified = true;
|
|
|
|
captchaChecked = true;
|
|
|
|
} else {
|
|
|
|
captchaCheckbox.innerHTML = `<i class="ri-close-line"></i>`;
|
|
|
|
captchaCheckbox.classList.add("~critical");
|
|
|
|
captchaCheckbox.classList.remove("~positive");
|
|
|
|
captchaVerified = false;
|
|
|
|
captchaChecked = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-12-20 18:44:31 +00:00
|
|
|
}
|
2022-01-27 16:48:46 +00:00
|
|
|
}
|
|
|
|
if (window.emailRequired) {
|
|
|
|
if (!emailField.value.includes("@")) {
|
|
|
|
oncomplete(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (window.discordEnabled && window.discordRequired && !discordVerified) {
|
|
|
|
oncomplete(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (window.telegramEnabled && window.telegramRequired && !telegramVerified) {
|
|
|
|
oncomplete(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (window.matrixEnabled && window.matrixRequired && !matrixVerified) {
|
|
|
|
oncomplete(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (window.captcha) {
|
|
|
|
if (!captchaChange) {
|
|
|
|
oncomplete(captchaVerified);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (!captchaChecked) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
oncomplete(captchaVerified);
|
|
|
|
} else {
|
|
|
|
oncomplete(true);
|
|
|
|
}
|
2021-12-20 18:44:31 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 16:48:46 +00:00
|
|
|
let r = initValidator(passwordField, rePasswordField, submitButton, submitSpan, baseValidator);
|
|
|
|
var requirements = r[0];
|
|
|
|
var validatorFunc = r[1] as () => void;
|
|
|
|
|
|
|
|
if (window.emailRequired) {
|
|
|
|
emailField.addEventListener("keyup", validatorFunc)
|
|
|
|
}
|
2020-10-20 22:33:32 +00:00
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
interface respDTO {
|
2021-01-25 18:01:18 +00:00
|
|
|
response: boolean;
|
|
|
|
error: string;
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface sendDTO {
|
|
|
|
code: string;
|
|
|
|
email: string;
|
|
|
|
username: string;
|
|
|
|
password: string;
|
2021-05-07 13:32:51 +00:00
|
|
|
telegram_pin?: string;
|
|
|
|
telegram_contact?: boolean;
|
2021-05-21 20:35:25 +00:00
|
|
|
discord_pin?: string;
|
|
|
|
discord_contact?: boolean;
|
2021-05-29 16:43:11 +00:00
|
|
|
matrix_pin?: string;
|
|
|
|
matrix_contact?: boolean;
|
2022-01-13 20:39:51 +00:00
|
|
|
captcha_id?: string;
|
|
|
|
captcha_text?: string;
|
2022-01-10 01:55:48 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:14:16 +00:00
|
|
|
const genCaptcha = () => {
|
2022-01-10 01:55:48 +00:00
|
|
|
_get("/captcha/gen/"+window.code, null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status == 200) {
|
|
|
|
captchaID = req.response["id"];
|
|
|
|
document.getElementById("captcha-img").innerHTML = `
|
|
|
|
<img class="w-100" src="${window.location.toString().substring(0, window.location.toString().lastIndexOf("/invite"))}/captcha/img/${window.code}/${captchaID}"></img>
|
|
|
|
`;
|
2022-01-26 22:14:16 +00:00
|
|
|
captchaInput.value = "";
|
2022-01-10 01:55:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2022-01-26 22:14:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (window.captcha) {
|
|
|
|
genCaptcha();
|
|
|
|
(document.getElementById("captcha-regen") as HTMLSpanElement).onclick = genCaptcha;
|
2022-01-27 16:48:46 +00:00
|
|
|
captchaInput.onkeyup = validatorFunc;
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const create = (event: SubmitEvent) => {
|
|
|
|
event.preventDefault();
|
2022-01-10 01:55:48 +00:00
|
|
|
if (window.captcha && !captchaVerified) {
|
|
|
|
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
toggleLoader(submitSpan);
|
|
|
|
let send: sendDTO = {
|
2021-01-14 14:22:20 +00:00
|
|
|
code: window.code,
|
2021-01-05 18:16:23 +00:00
|
|
|
username: usernameField.value,
|
|
|
|
email: emailField.value,
|
|
|
|
password: passwordField.value
|
|
|
|
};
|
2021-05-07 13:32:51 +00:00
|
|
|
if (telegramVerified) {
|
|
|
|
send.telegram_pin = window.telegramPIN;
|
|
|
|
const radio = document.getElementById("contact-via-telegram") as HTMLInputElement;
|
|
|
|
if (radio.checked) {
|
|
|
|
send.telegram_contact = true;
|
|
|
|
}
|
|
|
|
}
|
2021-05-21 20:35:25 +00:00
|
|
|
if (discordVerified) {
|
|
|
|
send.discord_pin = window.discordPIN;
|
|
|
|
const radio = document.getElementById("contact-via-discord") as HTMLInputElement;
|
|
|
|
if (radio.checked) {
|
|
|
|
send.discord_contact = true;
|
|
|
|
}
|
|
|
|
}
|
2021-05-29 16:43:11 +00:00
|
|
|
if (matrixVerified) {
|
|
|
|
send.matrix_pin = matrixPIN;
|
|
|
|
const radio = document.getElementById("contact-via-matrix") as HTMLInputElement;
|
|
|
|
if (radio.checked) {
|
|
|
|
send.matrix_contact = true;
|
|
|
|
}
|
|
|
|
}
|
2022-01-10 01:55:48 +00:00
|
|
|
if (window.captcha) {
|
2022-01-13 20:39:51 +00:00
|
|
|
send.captcha_id = captchaID;
|
|
|
|
send.captcha_text = captchaInput.value;
|
2022-01-10 01:55:48 +00:00
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
_post("/newUser", send, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
2021-01-25 18:01:18 +00:00
|
|
|
let vals = req.response as respDTO;
|
2021-01-05 18:16:23 +00:00
|
|
|
let valid = true;
|
|
|
|
for (let type in vals) {
|
|
|
|
if (requirements[type]) { requirements[type].valid = vals[type]; }
|
|
|
|
if (!vals[type]) { valid = false; }
|
|
|
|
}
|
|
|
|
if (req.status == 200 && valid) {
|
2021-05-07 00:08:12 +00:00
|
|
|
window.successModal.show();
|
2021-01-05 18:16:23 +00:00
|
|
|
} else {
|
|
|
|
submitSpan.classList.add("~critical");
|
|
|
|
submitSpan.classList.remove("~urge");
|
2022-01-27 16:48:46 +00:00
|
|
|
if (req.response["error"] as string) {
|
|
|
|
submitSpan.textContent = window.messages[req.response["error"]];
|
|
|
|
} else {
|
|
|
|
submitSpan.textContent = window.messages["errorPassword"];
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
submitSpan.classList.add("~urge");
|
|
|
|
submitSpan.classList.remove("~critical");
|
2022-01-27 16:48:46 +00:00
|
|
|
submitSpan.textContent = submitText;
|
2021-01-05 18:16:23 +00:00
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
}
|
2021-01-25 18:01:18 +00:00
|
|
|
}, true, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
toggleLoader(submitSpan);
|
2021-12-20 18:44:31 +00:00
|
|
|
if (req.status == 401 || req.status == 400) {
|
2021-01-25 18:01:18 +00:00
|
|
|
if (req.response["error"] as string) {
|
2021-01-30 19:19:12 +00:00
|
|
|
if (req.response["error"] == "confirmEmail") {
|
|
|
|
window.confirmationModal.show();
|
|
|
|
return;
|
|
|
|
}
|
2021-01-25 18:01:18 +00:00
|
|
|
if (req.response["error"] in window.messages) {
|
|
|
|
submitSpan.textContent = window.messages[req.response["error"]];
|
|
|
|
} else {
|
|
|
|
submitSpan.textContent = req.response["error"];
|
|
|
|
}
|
2022-01-27 16:48:46 +00:00
|
|
|
setTimeout(() => { submitSpan.textContent = submitText; }, 1000);
|
2021-01-25 18:01:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-01-27 16:48:46 +00:00
|
|
|
validatorFunc();
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
form.onsubmit = create;
|