Vitalii_Tarantin 4 anos atrás
pai
commit
607a04c3f7
6 arquivos alterados com 316 adições e 57 exclusões
  1. 3 1
      js-01/css/style.css
  2. 9 7
      js-01/index.html
  3. 9 9
      js-01/js/main.js
  4. 39 40
      js-02/js/main.js
  5. 21 0
      js-03/index.html
  6. 235 0
      js-03/js/main.js

+ 3 - 1
js-01/css/style.css

@@ -1,6 +1,8 @@
+.nav {
+    width: 100%;
+}
 .form {
     width: 200px;
     display: flex;
      flex-direction: column;
-    
 }

+ 9 - 7
js-01/index.html

@@ -8,13 +8,15 @@
   <link rel="stylesheet" href="css/style.css">
 </head>
 <body>
-  <div class="form">
-    <!-- Присваевем элементам атрибут id с именами или ключами чтобы можно было получить к нему доступ через document.getElementById(id)  -->
-   <input type="text" placeholder="login" id="login" />
-   <input type="password" placeholder="password" id="pasworld" />
-    <!-- Пощелчку  на кнопку срабатывает событие onklick и идёт вызов функции submit  -->
-   <input type="button" value="login" onclick="submit()" />
- </div>
+  <div class="nav">
+    <div class="form">
+      <!-- Присваевем элементам атрибут id с именами или ключами чтобы можно было получить к нему доступ через document.getElementById(id)  -->
+     <input type="text" placeholder="login" id="login" />
+     <input type="password" placeholder="password" id="pasworld" />
+      <!-- Пощелчку  на кнопку срабатывает событие onklick и идёт вызов функции submit  -->
+     <input type="button" value="login" onclick="submit()" />
+   </div>
+  </div>
 
  
   <script src="js/main.js"></script>

Diferenças do arquivo suprimidas por serem muito extensas
+ 9 - 9
js-01/js/main.js


+ 39 - 40
js-02/js/main.js

@@ -10,9 +10,9 @@ var b, c; // выражение справа вычисляеться его р
 //Number:age
 var  year = 2020;
 var personYears;
-var howOldPerson = prompt('Сколько вам лет');
-var personYears = year - +howOldPerson;
-alert('You born in ' +personYears );
+var howOldPerson = +prompt('Сколько вам лет');
+var personYears = year - howOldPerson;
+alert('You born in ' + personYears );
 
 //--------------------------------------------------------------------
 
@@ -24,8 +24,8 @@ alert ('Hi ' + name + ' have a nice day!');
 
 //Number: temperature
 var farenheit;
-var celsius = prompt('Enter degrees celsius');
-var farenheit =  +celsius * 1.8000 + 32; 
+var celsius = +prompt('Enter degrees celsius');
+var farenheit =  celsius * 1.8000 + 32; 
 alert(farenheit  + ' °F');
 
 
@@ -35,26 +35,26 @@ alert(farenheit  + ' °F');
 //Number: divide
 
         var sum;
-        var numberOne = prompt('Введите первое число');
-        var numberTwo = prompt('Введите второе число');
+        var numberOne = +prompt('Введите первое число');
+        var numberTwo = +prompt('Введите второе число');
         var sum = numberOne / numberTwo
         alert('Возвращает наибольшее целое число, которое меньше или равно аргументу ' + Math.floor(sum));
 
         var sum;
-        var numberOne = prompt('Введите первое число');
-        var numberTwo = prompt('Введите второе число');
+        var numberOne = +prompt('Введите первое число');
+        var numberTwo = +prompt('Введите второе число');
         var sum = numberOne / numberTwo
         alert('Возвращает аргумент, округлённый вверх до ближайшего числа ' + Math.round(sum));
 
         var sum;
-        var numberOne = prompt('Введите первое число');
-        var numberTwo = prompt('Введите второе число');
+        var numberOne = +prompt('Введите первое число');
+        var numberTwo = +prompt('Введите второе число');
         var sum = numberOne / numberTwo
         alert('Возвращает наименьшее целое число, которое больше аргумента ' + Math.ceil(sum));
 
         var sum;
-        var numberOne = prompt('Введите первое число');
-        var numberTwo = prompt('Введите второе число');
+        var numberOne = +prompt('Введите первое число');
+        var numberTwo = +prompt('Введите второе число');
         var sum = numberOne / numberTwo
         alert('Возвращает целую часть числа путём удаления всех дробных ' + Math.trunc(sum));
 
@@ -62,7 +62,7 @@ alert(farenheit  + ' °F');
         
 // Number: odd
 
-        let enterNumber = prompt();
+        let enterNumber = +prompt();
         if (isNaN(enterNumber)) {
             alert('You entered not a number enter a number')
     }else if (enterNumber & 1){
@@ -75,7 +75,7 @@ alert(farenheit  + ' °F');
 
 //String: lexics
 
-let userPushTheWorld = prompt('Ask me a question?\n For exanple\n What is the weather today?\n You watch football this weekend?');
+let userPushTheWorld = +prompt('Ask me a question?\n For exanple\n What is the weather today?\n You watch football this weekend?');
 
     if (userPushTheWorld.includes('weather')){
     alert('The weather is fine, have a nice day')
@@ -120,9 +120,9 @@ alert('Bie Bie')
 
 //Boolean 
 
-let learnJavaScript = confirm('You learn JS?');
-let farAdvanced = confirm('You far advanced?');
-let willYouContinueFurther = confirm('Will you continue further?');
+let learnJavaScript = confirm('You learn JS?') ? (alert("well done, continue on")) : (alert ("you should think about studying it"));
+let farAdvanced = confirm('You far advanced?') ? (alert("well done")) : (alert("it\'s okay, everything will work out"));
+let willYouContinueFurther = confirm('Will you continue further?') ? (alert("Your zeal pleases me")) : (alert("then you need to look for something else for yourself"));
 
 //--------------------------------------------------------------------
 
@@ -176,7 +176,7 @@ alert(borhs);
 
 //Array: boleans/bolean:if
 
-let bolean = ["learnJavaScript", "farAdvanced", "willYouContinueFurther", "theDialoge", "theDialogeCoffee", "goToTheCoofeeShop", "conpanyCoofee"]
+let bolean = ["learnJavaScript", "farAdvanced", "willYouContinueFurther", "theDialoge", "theDialogeCoffee", "goToTheCoofeeShop", "conpanyCoofee"];
 alert(bolean);
 
 
@@ -184,8 +184,8 @@ alert(bolean);
 
 //Array: plus
 
-let sum = [1,2,3,4,5]
-sum[2] = sum[0] + sum[0]
+let sum = [1,2,3,4,5];
+sum[2] = sum[0] + sum[0];
 alert(sum);
 
 
@@ -193,15 +193,15 @@ alert(sum);
 
 //Array: plus string
 
-var bread = prompt('Что нужно купить?', )
-var milk = prompt('а ещё что?')
-var egg = prompt('Список какойто маленикий напиши ещё что нибудь')
+var bread = prompt('Что нужно купить?', );
+var milk = prompt('а ещё что?');
+var egg = prompt('Список какойто маленикий напиши ещё что нибудь');
 var food = []
-food[0] = bread
-food[1] = milk
-food[2] = egg
+food[0] = bread;
+food[1] = milk;
+food[2] = egg;
 //food[3] = food[0] + food[1] + food[2]
-alert('не забудь купить ' + food) 
+alert('не забудь купить ' + food);
 
 //Я думаю что можно сделать напоминалку из этого условно в обед тебе приходят вопросы что нужно купить, а вечером приходит напоминание о покупке.
 
@@ -277,29 +277,28 @@ let ternary = confirm ('You man?') ? alert("You man") : alert("You female");
 
 var stag = + prompt()
     if (stag<3) {
-    alert('allowance 0%')
+    alert("allowance 0%")
 }
 else if (stag>3 && stag<10){
-alert('allowance 10%')
+alert("allowance 10%")
 }
 else if (stag>10 && stag<20) {
-alert('allowance 20%')
+alert("allowance 20%")
 }
 else if (stag < 20){
-alert('allowance 25%')
+alert("allowance 25%")
 }else{
-alert('enter number')
+alert("enter number")
 }
 
 //Найти максимальное из двух чисел. Учтите вариант равенства чисел
-
-var numberOne = + prompt()
-var numberTwo = + prompt()
+var numberOne = + prompt("Enter first number")
+var numberTwo = + prompt("Enter second number")
  if (numberOne > numberTwo) {
-    alert(numberOne)
-}else if (numberOne<numberTwo) {
-    alert(numberTwo)
-}else if (numberOne=numberTwo){alert('numbers are equal')}else {alert('not a number')}
+    alert("First number" + " " + numberOne + " " + "more" + " " + "First number" + " " + numberTwo)
+}else if (numberOne < numberTwo) {
+    alert("Second number" + " " + numberTwo  + " " + "more" + " " + "Second number" + " " + numberOne)
+}else if (numberOne=numberTwo){alert("Numbers are equal" + " " + numberOne + " " + "=" + " " + numberTwo)}else {alert('not a number')}
 
 
 

+ 21 - 0
js-03/index.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <meta http-equiv="X-UA-Compatible" content="ie=edge">
+  <title>Document</title>
+  <link rel="stylesheet" href="css/reset.css">
+  <link rel="stylesheet" href="css/slick.css">
+  <link rel="stylesheet" href="css/jquery.fancybox.css">
+  <link rel="stylesheet" href="css/style.css">
+</head>
+<body>
+  
+
+  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
+  <script src="js/slick.min.js"></script>
+  <script src="js/jquery.fancybox.min.js"></script>
+  <script src="js/main.js"></script>
+</body>
+</html>

+ 235 - 0
js-03/js/main.js

@@ -0,0 +1,235 @@
+// Additional task
+var additionalTask = prompt("switchSizes, switch:if, prompt:or, confirm: or this days, confirm: if this days, triple prompt, default: or, default: if, login and password, currency calc && currency calc: improved, currency calc: two rates, currency calc: if, target, blue belt assignment'")
+switch(additionalTask) {
+
+case 'switch:sizes' :
+
+let size = prompt('Enter your size', " ");
+switch(size) {
+    case '40' :  alert('Your size in Norvay 34 S');
+       break;
+    case '42' : alert('Your size in Norvay 36 M');
+        break;
+    case '44' : alert('Your size in Norvay 38');
+        break;
+    case '46' : alert('Your size in Norvay 40 L');
+        break;
+    case '48' : alert('Your size in Norvay 42');
+        break;
+    case '50' : alert('Your size in Norvay 44 XL');
+        break;
+    case '52' : alert('Your size in Norvay 46');
+        break;
+    case '54' : alert('Your size in Norvay 54 XXL');
+        break;
+    default : alert('Sorry but you size not included in our table');
+}
+
+break;
+
+case 'switch:if' :
+
+var color = prompt("Введите цвет","");
+    if (color == "red") {
+    document.write("<div style='background-color: red;'>красный</div>");
+    document.write("<div style='background-color: black; color: white;'>черный</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>");
+    document.write("<div style='background-color: green;'>зеленый</div>");
+}
+else if (color == "green"){
+
+    document.write("<div style='background-color: green;'>зеленый</div>");
+}
+else{
+    document.write("<div style='background-color: gray;'>Я не понял</div>");
+}
+break;
+
+case 'prompt:or' : 
+
+var  yearNow = 2020;
+var personYears;
+var howOldPerson = +prompt('Сколько вам лет') || alert('Error');
+var personYears = yearNow - howOldPerson;
+ if(howOldPerson!=null) alert('You born in ' +personYears );
+
+ break;
+
+case 'confirm: or this days' :
+
+var shoping = confirm('Shoping?') || alert('You are a caca');
+alert('You are the best');
+
+break;
+
+case 'confirm: if this days' :
+
+let soping = confirm('Shoping?');
+ if (soping==false) {
+alert('You are a caca');
+}
+else {alert('You are the best');
+}
+
+break;
+
+case 'triple prompt' :
+
+var name = prompt("Enter you name", "");
+var surname = prompt("Enter you surname", "");
+var fathername = prompt("Enter you fathername", "");
+alert(name +  ' ' + surname + ' ' + fathername); 
+break;
+
+
+case 'default: or' :
+
+var name = prompt("Enter you name") || "Ivan";
+var surname = prompt("Enter you surname") || "Ivanov";
+var fatherName = prompt("Enter you fathername") || "Ivanovich";
+alert(surname + ' ' + name  + ' ' + fatherName);
+ break;
+
+
+case 'default: if' :
+
+var surnameOne = prompt("Enter you surname");
+var nameOne = prompt("Enter you name");
+var fatherNameOne = prompt("Enter you fathername");
+
+if (!surnameOne) { surnameOne = 'Ivanov'} 
+if (!nameOne) {nameOne = 'Ivan'} 
+if (!fatherNameOne) {fatherNameOne = 'Ivanovich'}
+alert(surnameOne + ' ' +  nameOne +  ' '  +  fatherNameOne);
+break;
+
+case  'login and password' :
+
+var name = 'stas';
+var nameTwo = 'alex';
+var nameThree = 'pety';
+var passworld = 1234;
+var passworldTwo = 777;
+var passworldThree = 'qwerty'
+var loginName = prompt("Enter you name", "") || alert("Enter you name")
+var loginPassworld = prompt("Enter you passworld", "") || alert("Enter you passworld")
+   
+ if (name!==loginName && passworld==loginPassworld || nameTwo!==loginName && passworldTwo==loginPassworld || nameThree!==loginName && passworldThree==loginPassworld){
+alert("Wrong name")
+}
+else if(name==loginName && passworld!==loginPassworld  || nameTwo==loginName && passworldTwo!==loginPassworld || nameThree==loginName && passworldThree!==loginPassworld ){
+alert('Passworld is wrong')
+}
+else if (name==loginName && passworld==loginPassworld || nameTwo==loginName && passworldTwo==loginPassworld || nameThree==loginName && passworldThree==loginPassworld){
+alert("Cam in")
+}
+else if (name!=loginName && passworld!=loginPassworld) {
+    alert('anncorect name and passworld')
+}else {alert('Cansel')}
+break; 
+
+case 'currency calc && currency calc: improved' :
+
+
+var сurrency = prompt("Enter you currency usd or eur").toLowerCase();
+switch(сurrency) {
+    case "usd" : currency = 29
+        break;
+    case "eur" : currency = 33
+}
+var sum = + prompt("Enter the amount you want to transfer to UAH");
+var dubget = sum * currency
+alert(dubget)
+break;
+
+case 'currency calc: two rates' :
+
+var сurrency = prompt("Enter you currency usd or eur").toLowerCase();
+switch(сurrency) {
+    case "usd" : currency = 29
+        break;
+    case "eur" : currency = 33
+}
+var sum = + prompt("Enter the amount you want to transfer");
+var dubget = confirm("Click OK if you want to sell or Cancel if you want to buy") ? dubgett = sum * currency : dubggett = sum / currency;
+alert(dubget)
+break;
+
+
+case 'currency calc: if' :
+
+var currencyUsd = 29;
+var currencyEur = 33
+var currencyOne = prompt("Enter you currency usd or eur").toLowerCase();
+var sum = + prompt("Enter the amount you want to transfer");
+var dubgett = confirm("Click OK if you want to sell or Cancel if you want to buy")
+if (currencyOne === "usd" && sum>0 && dubgett) { var summa = sum * currencyUsd}
+if (currencyOne === "usd" && sum>0 && !dubgett) {var summa = sum / currencyUsd}
+if (currencyOne === "eur" && sum>0 && dubgett) {var summa = sum * currencyEur}
+if (currencyOne === "eur" && sum>0 && !dubgett) {var summa = sum / currencyEur}
+alert(summa)
+break;
+
+case 'scissors' :
+
+var game = prompt("Choose one from rock, scissors, paper").toLowerCase();
+var enemy = Math.floor(Math.random()*3);
+if (enemy == 0) {enemy = "rock"}
+{if (enemy == "rock" && game == "paper") alert("You have won")}
+{if (enemy == "rock" && game == "rock") alert("Draw")}
+{if (enemy == "rock" && game == "scissors") alert("Opponent defeated")}
+if (enemy == 1) {enemy = "paper"}
+{if (enemy == "paper" && game == "paper") alert("Draw")}
+{if (enemy == "paper" && game == "rock") alert("Opponent defeated")}
+{if (enemy == "paper" && game == "scissors") alert("You have won")}
+if (enemy == 2 ) {enemy = "scissors"}
+{if (enemy == "scissors" && game == "paper") alert("Opponent defeated")}
+{if (enemy == "scissors" && game == "rock") alert("You have won")}
+{if (enemy == "scissors" && game == "scissors") alert("Draw")}
+break;
+
+
+case 'blue belt assignment' :
+
+var ratios = {
+    usdSell: 25.6,
+    eurSell: 29,
+    usdBay: 27.8,
+    eurBay: 31,
+}
+var currency = prompt("Enter you currency usd or eur").toLowerCase();
+var sum = +prompt("Enter the amount you want to transfer");
+let cashUsbSell = sum * ratios["usdSell"];
+let cashUsdBay = sum/ratios["usdBay"];
+let cashEurSell = sum * ratios["eurSell"];
+let cashEurBay = sum/ratios["eurBay"];
+    if (currency == 'usd') confirm("Click OK if you want to sell or Cancel if you want to buy") ?alert("Your cash on sale is" + " " + cashUsbSell) : alert("Your cash from the purchase is" + " " + cashUsdBay);
+if (currency == 'eur') confirm("Click OK if you want to sell or Cancel if you want to buy") ?alert("Your cash on sale is" + " " + cashEurSell) : alert("Your cash from the purchase is" + " " + cashEurBay);
+break;
+
+case 'target' :
+// Написать программу которая будет склонять слово товар в зависимости от количества
+// товаров в корзине. Например 1 - товар, 4 - товара, 6 - товаров.
+
+var target = ['товар', 'товаров', 'товара']
+var number = + prompt("Введите количество товаров")
+tipe = Math.abs(number%100)
+var numbers = tipe%10
+    if (tipe>10 && tipe<20 || numbers>4 && numbers<11) {
+        alert(number + ' ' + target[1])
+
+}else if (numbers > 1 && numbers < 5) {
+    alert(number + ' ' + target[2])
+}else if (numbers == 1) {
+alert(number + ' ' + target[0])
+}else if (numbers == 0 ) {alert(number + ' ' + target[1])}else {alert("error")}
+break;
+
+}