Alyona Brytvina 2 vuotta sitten
vanhempi
commit
801200d7bf
3 muutettua tiedostoa jossa 193 lisäystä ja 0 poistoa
  1. 42 0
      HW00/index.html
  2. 57 0
      HW00/main.js
  3. 94 0
      HW00/style.css

+ 42 - 0
HW00/index.html

@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Hw00</title>
+    <link rel="stylesheet" href="style.css">
+</head>
+<body>
+<form class="container">
+    <h1> Регистрация </h1>
+    <div class="container-for-login">
+        <label class="label-login">Логин </label>
+        <input type="text" class="input-login">
+    </div>
+    <div class="container-for-password">
+        <label class="label-password">Пароль</label>
+        <input type="password" class="input-password">
+    </div>
+    <div class="container-for-buttons">
+        <button class="button">Отправить</button>
+        <button class="button-clear">Сбросить</button>
+    </div>
+
+    <div class="out"></div>
+</form>
+<div class="container-1">
+    <div class="container-for-input">
+        <label class="label-number">Enter a number</label>
+        <input type="text" class="input-1">
+        <div class="container-for-button"><button class="button-push">Push</button></div>
+    </div>
+    <div>Some counter:
+        <span class="number-from-input"></span>
+    </div>
+    <div class="container-for-buttons">
+        <button class="out-1">Add</button>
+        <button class="out-2">Remove</button>
+    </div>
+</div>
+<script src='main.js'></script>
+</body>
+</html>

+ 57 - 0
HW00/main.js

@@ -0,0 +1,57 @@
+// 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;
+    }
+}

+ 94 - 0
HW00/style.css

@@ -0,0 +1,94 @@
+body{
+    margin: 0;
+    font-family: Calibri, sans-serif;
+    padding: 0;
+
+}
+
+.container {
+    height: 350px;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    flex-direction: column;
+    background-color: lightskyblue;
+
+}
+
+.container-for-login, .container-for-password, .container-for-buttons {
+    margin: 5px;
+}
+
+.out {
+    margin-top: 5px;
+    display: flex;
+    width: 200px;
+    text-align: center;
+}
+
+.button, .button-clear, .button-push, .out-1, .out-2{
+    border-radius: 3px;
+    cursor: pointer;
+    background-color: white;
+    height: 25px;
+    width: 80px;
+    font-size: 12px;
+    margin: 5px;
+    border: 0;
+}
+
+.button:hover, .button-clear:hover, .button-push:hover, .out-1:hover, .out-2:hover{
+    border-radius: 3px;
+    cursor: pointer;
+    background-color: white;
+    height: 25px;
+    width: 80px;
+    font-size: 12px;
+    margin: 5px;
+    border: 1px solid black;
+}
+
+
+.button-clear{
+    cursor: pointer;
+    background-color: white;
+}
+
+.input-password, .input-login, .input-1 {
+    border: 1px solid gray;
+    border-radius: 3px;
+    height: 25px;
+    font-size: 16px;
+    display: block;
+    margin-top:5px;
+}
+
+
+
+.label-login, .label-number, .label-password{
+    color: black;
+    font-size: 18px;
+}
+
+.container-1{
+    height: 300px;
+    background-color: pink;
+    display: flex;
+    justify-content: center;
+    flex-direction: column;
+    align-items: center;
+}
+
+
+.container-for-input{
+    margin-bottom: 20px;
+    display: flex;
+    flex-direction: column;
+
+}
+
+.container-for-button{
+    display: flex;
+    justify-content: center;
+}
+