lexiconga-lite/src/js/account/setupListeners.js

27 lines
928 B
JavaScript
Raw Normal View History

2019-05-15 01:22:17 +02:00
import { logIn, createAccount } from "./login";
2019-05-23 19:41:49 +02:00
import { setCookie } from "../StackOverflow/cookie";
2019-05-24 01:00:13 +02:00
import { changeDictionary } from "./dictionaryManagement";
2019-05-13 22:02:10 +02:00
export function setupLoginModal(modal) {
const closeElements = modal.querySelectorAll('.modal-background, .close-button');
Array.from(closeElements).forEach(close => {
close.addEventListener('click', () => {
modal.parentElement.removeChild(modal);
});
});
document.getElementById('loginSubmit').addEventListener('click', logIn);
2019-05-15 01:22:17 +02:00
document.getElementById('createAccountSubmit').addEventListener('click', createAccount);
}
export function setupLogoutButton(logoutButton) {
logoutButton.addEventListener('click', () => {
2019-05-23 19:41:49 +02:00
setCookie('token', '', -1);
window.location.reload();
});
2019-05-22 02:57:29 +02:00
}
2019-05-24 01:00:13 +02:00
export function setupChangeDictionary() {
document.getElementById('accountSettingsChangeDictionary').addEventListener('change', changeDictionary);
}