123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //========================================================================================
- // Registration
- //Горячие клавиши
- const registForm = document.forms.registration;
- console.log(registForm)
- if(registForm) {
- registForm.addEventListener("submit", (event) => {
- event.preventDefault(); //Останови дефолтные функции браузера
- //Подключили значения с формы
- const formData = new FormData(registForm)
- const email = formData.get('email');
- const password = formData.get('password');
- const surname = formData.get('surname');
- const name = formData.get('name');
- const address = formData.get('address');
- const user = { name, surname, address, email, password };
- if(email === "" || password === "") return;
- registForm.reset();
- console.log(user);
- registUser(user).then(
- data => {
- console.log(data);
- }
- ).catch(ex => console.log(ex));
- })
- }
- async function registUser(user){
- const url = "http://todo/services/registration.php"
- const response = await fetch(url, {
- method: "POST",
- headers: {
- "Content-Type": "application/json; charset=utf-8"
- },
- body: JSON.stringify(user)
- });
- const info = await response.json();
- return info;
- }
- //========================================================================================
- // Login
- // Modal =================================================================================
- const modals = document.querySelectorAll('[data-name]')
- const modalButtons = document.querySelectorAll('button[data-for]')
- modalButtons.forEach(button => {
- const modalName = button.getAttribute('data-for')
- const modal = Array.from(modals).find(element => element.getAttribute('data-name') === modalName)
- if (!modal) return;
- const closeButton = modal.querySelector('button.task-form__actions_close')
- const confirmButton = modal.querySelector('button.task-form__actions_confirm')
- button.addEventListener('click', () => {
- modal.classList.add('active')
- })
- modal.addEventListener('click', (event) => {
- if (event.target === modal || event.target === closeButton) {
- modal.classList.remove('active')
- }
- })
- confirmButton?.addEventListener('click', sendFormHandler)
- })
- function sendFormHandler(event) {
- }
- function addCategory(form) {
- }
- async function createCategory(task) {
- }
- function addTask(form) {
- }
- async function createTask(task) {
- }
- //========================================================================================
- // Menu links
- //========================================================================================
- // Change category to create a task
|