Browse Source

HW<1> done

Andrey 1 year ago
parent
commit
a57e40db47
4 changed files with 170 additions and 240 deletions
  1. BIN
      Dz 1 js/.DS_Store
  2. 1 0
      Dz 1 js/index.html
  3. 0 49
      Dz 1 js/js01.html
  4. 169 191
      Dz3 js/Dz3js.html

BIN
Dz 1 js/.DS_Store


+ 1 - 0
Dz 1 js/index.html

@@ -18,6 +18,7 @@
             } else {
                 alert ("Ошибка! Обновите и попробуйте снова!")
             } 
+            
 
     </script>
 </body>

+ 0 - 49
Dz 1 js/js01.html

@@ -1,49 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
-    <meta charset="UTF-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Js1</title>
-</head>
-
-<body>
-    <style>
-       .div-two {
-           background: green;
-       }
-       .div {
-           background: red;
-       }
-    </style>
-    <form id="myForm">
-        <input type="login" placeholder="Login"> <br>
-        <input type="password" placeholder="Password"> <br>
-        <input type="submit" value="Login">
-    </form>
-    <script>
-        let credentials = {
-            login: 'admin',
-            password: 'qwerty',
-        };
-        const form = document.querySelector( "myForm" );
-        
-
-        
-        //  if (login && password) {
-        //     let div = document.createElement('div');
-        //         div.className = "div_two";
-        //         div.innerHTML = "<strong>Всё фигня, давай по новой! Попробуй ввести: admin и qwerty!</strong>"
-        //         document.body.append(div);
-        //  }
-        //  else {
-        //     let div = document.createElement('div');
-        //         div.className = "div";
-        //         div.innerHTML = "<strong>Всё фигня, давай по новой! Попробуй ввести: admin и qwerty!</strong>"
-        //         document.body.append(div);
-        //  }
-    </script>
-</body>
-
-</html>

+ 169 - 191
Dz3 js/Dz3js.html

@@ -10,8 +10,8 @@
 
 <body>
     <script>
-        let taskName = prompt ("Введите название задания:")
-        switch(taskName){
+        let taskName = prompt("Введите название задания:")
+        switch (taskName) {
             case "switch: sizes":
                 let country = prompt("Выбирете страну на выбор: Италия, Швейцария")
                 let size = prompt("Введите размер верхней одежды: от 46 - до 50.")
@@ -68,218 +68,196 @@
 
 
                 }
-            
-        case "switch: if":
-        let color = prompt("Введите цвет", "");
-        if (color == "red") {
-            document.write("<div style='background-color: red;'>красный</div>")
-        }
-        else if (color == "black") {
-            document.write("<div style='background-color: black; color: white;'>черный</div>");
-        }
-        else if (color == "blue") {
-            document.write("<div style='background-color: blue;'>синий</div>");
-        }
-        else if (color == "green") {
-            document.write("<div style='background-color: green;'>зеленый</div>");
-        }
-
-        else {
-            document.write("<div style='background-color: gray;'>Я не понял</div>")
-        }
-
-        case "Number: age":
-        let year = 2022;
-        let birthday;
-        let age = +prompt("Сколько вам лет?")
-        if (age) {
-            birthday = year - age;
-            alert(birthday + " г.р.");
-        }
-        else if ((age == null) || (age == "")) {
-                alert("Ошибка!")
-        }else {
-            alert("NO_NO!")
-        }
-
-
-
-        case "confirm: or this days":
-        let shopping = confirm("Шопинг?")
-        alert(shopping || "Ты бяка!")
-
-        case "confirm: if this days":
-        let shopping2 = confirm("Шопинг?")
-        if (shopping2) {
-            alert("Люблю покупки!")
-        }else if((shopping2 == null) || (shopping2 == "")){
-            alert("Ты бяка!")
-        }
-
-
-
-
-        case "triple prompt":
-        let userSurname = prompt("Введите вашу фамилию:")
-        let userName = prompt("Введите ваше имя:") 
-        let userPatronymic = prompt("Введите ваше отчество:") 
-        let fullName = userSurname + ' ' + userName + ' ' +  userPatronymic;
-        alert(fullName)
-
-        case "default: or":
-        let userSurname2 = prompt("Введите вашу фамилию:") || ("Иванов" )
-        let userName2 = prompt("Введите ваше имя:") || ("Иван")
-        let userPatronymic2 = prompt("Введите ваше отчество:") || ("Иваночив")
-        let fullName2 = userSurname2 + ' ' + userName2 + ' ' +  userPatronymic2;
-        alert(fullName)
-
-        case "default: if":
-        
-        let userName3 = prompt("Введите ваше имя");
-            let userSurname3 = prompt("Введите вашу фамилию");
-            let userPatronymic3 = prompt("Введите ваше отчество");
-            if (userName3 == null || "") {
-                userName3 = "Иван";
-            }
-            if (userSurname3 == null || "") {
-                userSurname3 = "Иванов";
-            }
-            if (userPatronymic3 == null || "") {
-                userPatronymic3 = "Иванович";
-            }
-
-            alert(userSurname3 + " " + userName3 + " " + userPatronymic3);
-        
-
-
-        case "login and password":
-        let login = prompt("Введите ваш логин:");
-        if(login === "admin"){
-            let password = prompt("Введите ваш пароль:");
-            if (password === "qwerty"){
-                alert("Поздравляю!");
-            }else if(password === "" || password === null) {
-                alert("Охрана-Отмена!");
-            }else {
-                alert("Неверный пароль!!!")
-            }
-        }else if (login === "" || login === null){
-            alert("Не тут то было!")
-        }else{
-            alert("Вы кто такой? Я вас не звал! Идите за русским кораблем!")
-        }
-
-        case "currency calc":
-        // case "currency calc: improved":
-        // //case "currency calc: two rates":
-        let currency = prompt("Выбирете валюту: usd или eur ").toLowerCase();
-        let UAH = prompt("Введите сумму в гривнах: ");
-        let usdPurchase = 29.2;
-        let usdSale = 29.5;
-        let eurPurchase = 31.4;
-        let eurSale = 32.2;
-        switch (currency) {
-
-            case "usd":  let userExchangeUsd = confirm("Выберите покупка или проадажа? ок-покупка  отмена-продажа") ? (UAH / usdPurchase) : (UAH / usdSale)
-            alert(userExchangeUsd)
-            break;
-
-            case "eur": let userExchangeEur = confirm("Выберите покупка или проадажа? ок-покупка  отмена-продажа") ? (UAH / eurPurchase) : (UAH / eurSale)
-            alert(userExchangeEur)
-            break;
-
-            default: alert("Простите мы закрыты!")
-
-
-        }
-        case "currency calc: if":
-        let currency = prompt("Выбирете валюту: usd или eur ").toLowerCase();
-        let UAH = prompt("Введите сумму в гривнах: ");
-        let usdPurchase = 29.2;
-        let usdSale = 29.5;
-        let eurPurchase = 31.4;
-        let eurSale = 32.2;
-        if (currency === "usd") {
-            let userExchangeUsd = confirm("Выберите покупка или проадажа? ок-покупка  отмена-продажа") ? (UAH / usdPurchase) : (UAH / usdSale)
-            alert(userExchangeUsd)
-        }
-        else if (currency === "eur") {
-            let userExchangeEur = confirm("Выберите покупка или проадажа? ок-покупка  отмена-продажа") ? (UAH / eurPurchase) : (UAH / eurSale)
-            alert(userExchangeEur)
-        }
-        else {
-            alert("Простите мы закрыты!")
-        }
-
-        case "scissors":
-        let userChoice = Number(prompt("Выбирите число от 1 до 3. 1 - камень 2 - ножницы, 3 - бумага"))
-        let compRandom = Math.ceil(Math.random() * 3)
-        alert(`Противник выбрал: ${compRandom} `)
-        if (userChoice === 1 && compRandom === 2 || userChoice === 2 && compRandom === 3 || userChoice === 3 && compRandom === 1) {
-            alert("Ура!!!Вы победили!")
-        }
-        else if (userChoice === 3 && compRandom === 2 || userChoice=== 2 && compRandom === 1 || userChoice === 1 && compRandom === 3) {
-            alert("ОЙ-ОЙ!Вы проиграли!")
-        } else {
-            alert("Победила дружба!!!")
-        }
-
-        case "Задание на синий пояс":
-        let currencySelection = prompt("Выбери одну валюту на выбор: usd или eur").toLowerCase();
-        let enterAmount = prompt ("Введите сумму в гривнах")
-        let ratios = {
-            usd: 25.6,
-            eur: 29
-        }
-        if (currencySelection === "usd"){
-            alert(enterAmount / ratios["usd"])
-        } else if (currencySelection === "eur"){
-            alert(enterAmount / ratios["eur"])
-        }else {
-            alert("Вы ввели не верные данные!")
-        }
-
-        case "real data":
-        let currencySelection2 = prompt("Выбери одну валюту на выбор: usd или eur").toLowerCase();
-        let enterAmount2 = prompt ("Введите сумму в гривнах");       
-        if(currencySelection2 === "usd"){
-            fetch('https://open.er-api.com/v6/latest/USD').then(res => res.json())
-            .then(data => {
-                alert(data.rates.UAH)
-            })}
-        else if (currencySelection2 === "eur"){
-            fetch('https://open.er-api.com/v6/latest/EUR').then(res => res.json())
-            .then(data => {
-                alert(data.rates.UAH)
-            })}
-        else {
-            alert("Что-то пошло не так!")
-        }
-    }
-
 
+            case "switch: if":
+                let color = prompt("Введите цвет", "");
+                if (color == "red") {
+                    document.write("<div style='background-color: red;'>красный</div>")
+                }
+                else if (color == "black") {
+                    document.write("<div style='background-color: black; color: white;'>черный</div>");
+                }
+                else if (color == "blue") {
+                    document.write("<div style='background-color: blue;'>синий</div>");
+                }
+                else if (color == "green") {
+                    document.write("<div style='background-color: green;'>зеленый</div>");
+                }
 
+                else {
+                    document.write("<div style='background-color: gray;'>Я не понял</div>")
+                }
 
+            case "Number: age":
+                let year = 2022;
+                let birthday;
+                let age = +prompt("Сколько вам лет?")
+                if (age) {
+                    birthday = year - age;
+                    alert(birthday + " г.р.");
+                }
+                else if ((age == null) || (age == "")) {
+                    alert("Ошибка!")
+                } else {
+                    alert("NO_NO!")
+                }
 
 
 
+            case "confirm: or this days":
+                let shopping = confirm("Шопинг?")
+                alert(shopping || "Ты бяка!")
 
+            case "confirm: if this days":
+                let shopping2 = confirm("Шопинг?")
+                if (shopping2) {
+                    alert("Люблю покупки!")
+                } else if ((shopping2 == null) || (shopping2 == "")) {
+                    alert("Ты бяка!")
+                }
 
 
 
 
+            case "triple prompt":
+                let userSurname = prompt("Введите вашу фамилию:")
+                let userName = prompt("Введите ваше имя:")
+                let userPatronymic = prompt("Введите ваше отчество:")
+                let fullName = userSurname + ' ' + userName + ' ' + userPatronymic;
+                alert(fullName)
 
+            case "default: or":
+                let userSurname2 = prompt("Введите вашу фамилию:") || ("Иванов")
+                let userName2 = prompt("Введите ваше имя:") || ("Иван")
+                let userPatronymic2 = prompt("Введите ваше отчество:") || ("Иваночив")
+                let fullName2 = userSurname2 + ' ' + userName2 + ' ' + userPatronymic2;
+                alert(fullName)
 
+            case "default: if":
 
+                let userName3 = prompt("Введите ваше имя");
+                let userSurname3 = prompt("Введите вашу фамилию");
+                let userPatronymic3 = prompt("Введите ваше отчество");
+                if (userName3 == null || "") {
+                    userName3 = "Иван";
+                }
+                if (userSurname3 == null || "") {
+                    userSurname3 = "Иванов";
+                }
+                if (userPatronymic3 == null || "") {
+                    userPatronymic3 = "Иванович";
+                }
 
+                alert(userSurname3 + " " + userName3 + " " + userPatronymic3);
+
+
+
+            case "login and password":
+                let login = prompt("Введите ваш логин:");
+                if (login === "admin") {
+                    let password = prompt("Введите ваш пароль:");
+                    if (password === "qwerty") {
+                        alert("Поздравляю!");
+                    } else if (password === "" || password === null) {
+                        alert("Охрана-Отмена!");
+                    } else {
+                        alert("Неверный пароль!!!")
+                    }
+                } else if (login === "" || login === null) {
+                    alert("Не тут то было!")
+                } else {
+                    alert("Вы кто такой? Я вас не звал! Идите за русским кораблем!")
+                }
 
+            case "currency calc":
+                // case "currency calc: improved":
+                // //case "currency calc: two rates":
+                let currency = prompt("Выбирете валюту: usd или eur ").toLowerCase();
+                let UAH = prompt("Введите сумму в гривнах: ");
+                let usdPurchase = 29.2;
+                let usdSale = 29.5;
+                let eurPurchase = 31.4;
+                let eurSale = 32.2;
+                switch (currency) {
+
+                    case "usd": let userExchangeUsd = confirm("Выберите покупка или проадажа? ок-покупка  отмена-продажа") ? (UAH / usdPurchase) : (UAH / usdSale)
+                        alert(userExchangeUsd)
+                        break;
 
+                    case "eur": let userExchangeEur = confirm("Выберите покупка или проадажа? ок-покупка  отмена-продажа") ? (UAH / eurPurchase) : (UAH / eurSale)
+                        alert(userExchangeEur)
+                        break;
 
+                    default: alert("Простите мы закрыты!")
 
 
+                }
+            case "currency calc: if":
+                let currency2 = prompt("Выбирете валюту: usd или eur ").toLowerCase();
+                let UAH2 = prompt("Введите сумму в гривнах: ");
+                let usdPurchase2 = 29.2;
+                let usdSale2 = 29.5;
+                let eurPurchase2 = 31.4;
+                let eurSale2 = 32.2;
+                if (currency2 === "usd") {
+                    let userExchangeUsd2 = confirm("Выберите покупка или проадажа? ок-покупка  отмена-продажа") ? (UAH2 / usdPurchase2) : (UAH2 / usdSale2)
+                    alert(userExchangeUsd2)
+                }
+                else if (currency2 === "eur") {
+                    let userExchangeEur2 = confirm("Выберите покупка или проадажа? ок-покупка  отмена-продажа") ? (UAH2 / eurPurchase2) : (UAH2 / eurSale2)
+                    alert(userExchangeEur2)
+                }
+                else {
+                    alert("Простите мы закрыты!")
+                }
 
+            case "scissors":
+                let userChoice = Number(prompt("Выбирите число от 1 до 3. 1 - камень 2 - ножницы, 3 - бумага"))
+                let compRandom = Math.ceil(Math.random() * 3)
+                alert(`Противник выбрал: ${compRandom} `)
+                if (userChoice === 1 && compRandom === 2 || userChoice === 2 && compRandom === 3 || userChoice === 3 && compRandom === 1) {
+                    alert("Ура!!!Вы победили!")
+                }
+                else if (userChoice === 3 && compRandom === 2 || userChoice === 2 && compRandom === 1 || userChoice === 1 && compRandom === 3) {
+                    alert("ОЙ-ОЙ!Вы проиграли!")
+                } else {
+                    alert("Победила дружба!!!")
+                }
 
+            case "Задание на синий пояс":
+                let currencySelection = prompt("Выбери одну валюту на выбор: usd или eur").toLowerCase();
+                let enterAmount = prompt("Введите сумму в гривнах")
+                let ratios = {
+                    usd: 25.6,
+                    eur: 29
+                }
+                if (currencySelection === "usd") {
+                    alert(enterAmount / ratios["usd"])
+                } else if (currencySelection === "eur") {
+                    alert(enterAmount / ratios["eur"])
+                } else {
+                    alert("Вы ввели не верные данные!")
+                }
 
+            case "real data":
+                let currencySelection2 = prompt("Выбери одну валюту на выбор: usd или eur").toLowerCase();
+                let enterAmount2 = prompt("Введите сумму в гривнах");
+                if (currencySelection2 === "usd") {
+                    fetch('https://open.er-api.com/v6/latest/USD').then(res => res.json())
+                        .then(data => {
+                            alert(data.rates.UAH)
+                        })
+                }
+                else if (currencySelection2 === "eur") {
+                    fetch('https://open.er-api.com/v6/latest/EUR').then(res => res.json())
+                        .then(data => {
+                            alert(data.rates.UAH)
+                        })
+                }
+                else {
+                    alert("Что-то пошло не так!")
+                }
+        }
 
 
     </script>