// Task-1. Form for registration const startCredentials = { login: 'admin', password: 'qwerty', }; localStorage.setItem('credentials', JSON.stringify(startCredentials)); const $out = document.querySelector('.out'); const $button = document.querySelector('.button'); $button.onclick = function (e) { e.preventDefault(); const credentials = JSON.parse(localStorage.getItem('credentials')) const loginInputValue = document.querySelector('.input-login').value; const passwordInputValue = document.querySelector('.input-password').value; if (credentials.login === loginInputValue && credentials.password === passwordInputValue) { $button.style.background = 'green'; $out.textContent = 'Поздравляю, вы правильно ввели данные!'; } else { $button.style.background = 'red'; $out.textContent = 'Ошибка, проверьте правильность ввода данных!'; } } document.querySelector('.button-clear').onclick = function () { $button.style.background = 'white'; document.querySelector('.input-login').value = ''; document.querySelector('.input-password').value = ''; $out.textContent = '' } //Task-2.Some counter document.querySelector('.button-push').onclick = function () { const valueFromInput = document.querySelector('.input-1').value; document.querySelector('.number-from-input').textContent = valueFromInput; localStorage.setItem('number', JSON.stringify(valueFromInput)); let number = JSON.parse(localStorage.getItem('number')); document.querySelector('.out-1').onclick = function add() { ++number; document.querySelector('.number-from-input').innerHTML = number; } document.querySelector('.out-2').onclick = function remove() { --number; document.querySelector('.number-from-input').innerHTML = number; } }