pvvvm505 il y a 3 ans
commit
1b4657a159

+ 46 - 0
HwJs1/index.html

@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html lang="ru,en">
+<head>
+    <meta charset="UTF-8">
+    <title>Document</title>
+    <link rel="preconnect" href="https://fonts.gstatic.com">
+    <link href="https://fonts.googleapis.com/css2?family=Chakra+Petch&display=swap" rel="stylesheet">
+    <style>body{font-family: 'Chakra Petch', sans-serif;};
+           input{font-family: 'Chakra Petch', sans-serif;};
+    </style>
+</head>
+<body>
+<!-- 1 task -->
+<div class="hw1">
+    <h2>calculator :</h2>
+    <input id="numb1"  onkeyup="this.value = this.value.replace(/[A-Za-zА-Яа-яЁё-і]/, '');"/>
+    <select id="act">
+        <option value="plus">+</option>
+        <option value="min">-</option>
+        <option value="multiply">x</option>
+        <option value="division">/</option>
+    </select>
+    <input id="numb2"  onkeyup="this.value = this.value.replace(/[A-Za-zА-Яа-яЁё-і]/, '');"/>
+    <button onclick="calc()">=</button>
+    <p id="result">00.00</p>
+</div>
+<!-- 2 task -->
+<div class="hw2">
+    <h2>array :</h2><h2 id="mass"></h2>
+    <p>add to array</p>
+    <input id="pushInp"/>
+    <button onclick="gets()">add</button>
+    <p>remove from array</p>
+    <input id="setNumb"/>
+    <button onclick="sets()">dell</button>
+</div>
+<!-- 3 task -->
+<div class="hw3">
+    <h2>calculator :</h2>
+    <input id="number" onkeyup="this.value = this.value.replace(/[A-Za-zА-Яа-яЁё-і]/, '');"/>
+    <button onclick="proCalc()">=</button>
+    <p id="resultat">00.00</p>
+</div>
+    <script src="../HwJs1/js/script.js"></script>
+</body>
+</html>

+ 42 - 0
HwJs1/js/script.js

@@ -0,0 +1,42 @@
+function calc(){
+    var result
+    var a = Number(document.getElementById("numb1").value);
+    var b = Number(document.getElementById("numb2").value);
+    var act = String(document.getElementById("act").value);
+    switch (act){
+        case "plus":
+            result = a + b
+        break;
+        case "min":
+            result = a - b
+        break;
+        case "multiply":
+            result = a * b
+        break;
+        case "division":
+            result = a / b
+        break;
+    default:
+            result = 'unknow'
+    }
+    document.getElementById("result").innerHTML = result.toFixed(2);
+    return
+}
+
+let massiv = []
+function gets(){
+   massiv.push(document.getElementById("pushInp").value);
+   document.getElementById("mass").innerHTML = massiv
+   return
+}
+function sets(){
+    var intf = document.getElementById("setNumb").value;
+        massiv.splice(intf,intf+1);
+    document.getElementById("mass").innerHTML = massiv
+    return
+}
+
+function proCalc(){
+    var numb = eval(document.getElementById("number").value);
+    document.getElementById("resultat").innerHTML = numb.toFixed(2);
+}

+ 19 - 0
HwJs2/index.html

@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html lang="ru,en">
+<head>
+    <meta charset="UTF-8">
+    <title>Document</title>
+    <link rel="preconnect" href="https://fonts.gstatic.com">
+    <link href="https://fonts.googleapis.com/css2?family=Chakra+Petch&display=swap" rel="stylesheet">
+    <style>body{font-family: 'Chakra Petch', sans-serif;};
+           input{font-family: 'Chakra Petch', sans-serif;};
+    </style>
+</head>
+<body>
+    <button onclick="classWork1()">classWork1</button>
+	<button onclick="classWork2()">classWork2</button>
+    <button onclick="classWork3()">classWork3</button>
+    <button onclick="homeWork()">homeWork</button>
+    <script src="../HwJs2/js/script.js"></script>
+</body>
+</html>

+ 63 - 0
HwJs2/js/script.js

@@ -0,0 +1,63 @@
+function classWork1 (){
+	let ask = prompt("take a numb").match(/\d+/);
+	for (let i=1; i<=ask ; i++){
+	  console.log(`numb:${i}`)
+	}
+}
+function classWork2 (){
+	const days = {
+	  1:'monday',
+	  2:'tuesday',
+	  3:'wednesday',
+	  4:'thursday',
+	  5:'friday',
+	  6:'saturday',
+	  7:'sunday',
+	  8:'monday',
+	  9:'tuesday',
+	  10:'wednesday',
+	  11:'thursday',
+	  12:'friday',
+	  13:'saturday',
+	  14:'sunday',
+	  15:'monday',
+	  16:'tuesday',
+	  17:'wednesday'
+	}
+	let rec={};
+	for (let day in days){
+	  let wDay = days[day];
+	  if (wDay in rec){
+		rec[wDay]++
+	  }else{
+		rec[wDay]=1
+	  }
+	}
+	for (let week in rec){
+	   console.log(`${week}: ${rec[week]}`)
+	}
+}
+function classWork3 (){
+	let binar = new Array();
+	let num
+	do{
+	  num = prompt("введите 0/1");
+	  binar.push(num)
+	}while(num != null)
+	  var otv = binar.join("");
+	  var assk = parseInt(otv, 2);
+	  alert(assk)
+	  console.log(assk);
+}
+function homeWork(){
+	var str = '';
+	var numb = prompt("numb");
+	var diez = numb
+	var minus = 0
+	for (var i = 0; i < numb; i++) {
+		let m = "-".repeat(diez-- -1)
+		let d = "#".repeat(minus++ + minus)
+		str = m + d + m
+		console.log(str)
+	}
+}

+ 15 - 0
HwJs3/index.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="ru,en">
+<head>
+    <meta charset="UTF-8">
+    <title>Document</title>
+    <link rel="preconnect" href="https://fonts.gstatic.com">
+    <link href="https://fonts.googleapis.com/css2?family=Chakra+Petch&display=swap" rel="stylesheet">
+    <style>body{font-family: 'Chakra Petch', sans-serif;};
+           input{font-family: 'Chakra Petch', sans-serif;};
+    </style>
+</head>
+<body>
+    <script src="../HwJs3/script.js"></script>
+</body>
+</html>

+ 54 - 0
HwJs3/script.js

@@ -0,0 +1,54 @@
+supSolyanka()
+function supSolyanka(){
+  alert("привет сегодня мы приготовим солянку");
+  alert("давай пройдёмся по рецепту");
+  asq("сколько нужно мяса (450 грамм)",450);
+  asq("сколько нужно мясных изделий(300 грамм)",300);
+  asq("растительного масла нужно (2 ст.ложки)",2);
+  ors("чеснока нам нужно (2-4 зубчика)",2,4);
+  asq("луквовиц нам нужно (1 шт)",1)
+  asq("томатной пасты (1 ст.ложка)",1)
+  ors("маринованых огурцов (2-4 шт)",2,4)
+  alert("а также нам понадобится по вкусу : маслины, соль, перец, специи, зелень, лимон и сметана")
+  gotovka ()
+}
+function gotovka (){
+  omp("будем ставить кастрюлю?")
+  omp("зальём водой кастрюлю?")
+  omp("добавим мясо?")
+  omp("добавим лавровый лист?")
+  omp("добавим овощи?")
+  omp("ставим кастрюлю на огонь")
+  asq("сколько варить будем? (2 часа)")
+  omp("мясо сварилось?")
+  alert("достанте его")
+  alert("остудите его")
+  alert("измельчите")
+  alert("процедите бульён и снова отправте на огонь")
+  omp("отправте туда нарезаное мясо")
+  omp("нарежте огурец")
+  alert("полижите огурци в бульён")
+  omp("варите до кипения на медленом огне")
+  alert("Выключите огонь, накройте кастрюлю крышкой и оставьте на полчасика, чтобы солянка настоялась. Подавайте к столу горячей, дополнив лимоном и сметаной по желанию. Приятного аппетита!")
+}
+
+function asq (ask ,nums){
+  let numb
+  do{
+	numb = prompt(ask)
+  }while (numb != nums && nums);
+}
+
+function ors (ask , minNumb , maxNumb){
+	let ass = prompt(ask)
+	while (ass < minNumb || ass > maxNumb)  {  
+		ass = prompt(ask)
+	}
+}
+
+function omp (ask){
+	let ass 
+	do{
+		ass = confirm(ask)
+	}while (ass != true);
+}

+ 15 - 0
HwJs4/index.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="ru,en">
+<head>
+    <meta charset="UTF-8">
+    <title>Document</title>
+    <link rel="preconnect" href="https://fonts.gstatic.com">
+    <link href="https://fonts.googleapis.com/css2?family=Chakra+Petch&display=swap" rel="stylesheet">
+    <style>body{font-family: 'Chakra Petch', sans-serif;};
+           input{font-family: 'Chakra Petch', sans-serif;};
+    </style>
+</head>
+<body>
+    <script src="script.js"></script>
+</body>
+</html>

+ 23 - 0
HwJs4/script.js

@@ -0,0 +1,23 @@
+let quarters = prompt("какую квартиру вы хотите найти")
+var search = function searchHome () {
+  let floors = prompt("количество этажей от 1-25").match(/\d+/);
+    while (floors < 1 || floors > 25)  {  
+		  floors = prompt("количество этажей от 1-25").match(/\d+/);
+	};
+  let entrance = prompt("количество подъездов от 1 до 10").match(/\d+/);
+    while (entrance < 1 || entrance > 10)  {  
+		  entrance = prompt("количество подъездов от 1 до 10").match(/\d+/);
+	};
+  let apartments = prompt("количество квартир на этаже от 1 до 10").match(/\d+/);
+    while (apartments < 1 || apartments > 10)  {  
+		  entrance = prompt("количество квартир на этаже от 1 до 10").match(/\d+/);
+	};
+    return function home (searchForHome){
+      let resFloors = Math.ceil(quarters/apartments);
+      let resEntrance = Math.ceil(resFloors/floors);
+      let resApartments = resEntrance * floors;
+      return alert(`квартира ${searchForHome} находится на ${resApartments} этаже ${resEntrance } подъезда`)
+  }
+}
+const summer = search()
+summer(quarters)

+ 47 - 0
HwJs5/js/script.js

@@ -0,0 +1,47 @@
+
+function chek(){
+	var fName = document.getElementById("fName").value;
+	var lName = document.getElementById('lName').value;
+	var email = document.getElementById("email").value.toLowerCase();
+	var password = document.getElementById('password').value;
+	var error = document.getElementById("error");
+	
+	if(password==""){
+		document.getElementById('password').style.border="1.5px solid red"
+	}else {
+		document.getElementById('password').style.border="1.5px solid #94b0a4"
+	};
+	if(email==""){
+		document.getElementById("email").style.border="1.5px solid red"
+	}else {
+		document.getElementById("email").style.border="1.5px solid #94b0a4"
+	}
+	if(fName==""){
+		document.getElementById("fName").style.border="1.5px solid red"
+	}else {
+		document.getElementById("fName").style.border="1.5px solid #94b0a4"
+	};
+	if(lName==""){
+		document.getElementById('lName').style.border="1.5px solid red"
+	}else{
+		document.getElementById('lName').style.border="1.5px solid #94b0a4"
+	};
+	
+	if(fName.indexOf(" ") != -1){
+		 error.innerHTML = "enter first name without space";
+		 error.style.color="red";
+	}else if(lName.indexOf(" ") != -1){
+		 error.innerHTML = "enter last name without space";
+		 error.style.color="red";
+	}else if(password.length <= 6){
+		 error.innerHTML = "password must be longer than 6 characters";
+		 error.style.color="red";
+	}else if(email.slice(-10) != "@gmail.com"){
+		error.innerHTML = "Enter your email with the domain gmail.com";
+		error.style.color="red";
+    }else{
+		error.innerHTML ='Sing Up for Free';
+		error.style.color="#fff";
+		alert("вы успешно зарегестрировались")
+	};
+}

+ 34 - 0
HwJs5/regestration.html

@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>log</title>
+    <link rel="stylesheet" href="style/style.css">
+    <link rel="preconnect" href="https://fonts.gstatic.com">
+	<link href="https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300&display=swap" rel="stylesheet">
+</head>
+<body>
+    <script src="js/script.js"></script>
+    <div class="form">
+        <div class="tab">
+            <a href="#" class="signup" >Sing Up</a>
+            <a href="#" class="login">Log In</a>
+        </div>
+        <div class="contentSingup">
+            <form class="forsms" onsubmit="return false;">
+                <h2 id="error">Sing Up for Free</h2>
+                <div class="name_block">
+                    <input type="text" placeholder="First Name *" id="fName">
+                    <input type="text" placeholder="Last Name *" id="lName">
+                </div>
+                <div class="e_p_block">
+                    <input type="text" placeholder="Email Addres *" id="email">
+                    <input type="text"  placeholder="Set A Password *" id="password">
+                </div>
+              <input type="submit" class="button-block" onclick="chek(); return false;" value="Get Started"/>
+            </form>
+        </div>
+    </div>
+</body>
+</html>

+ 82 - 0
HwJs5/style/style.css

@@ -0,0 +1,82 @@
+body{
+	background: #c1bdba;
+	font-family: 'Titillium Web', sans-serif;
+}
+
+.form{
+	background: #24333c;
+	padding: 40px;
+  	max-width:600px;
+  	margin:40px auto;
+ 	border-radius:1.5px;
+}
+.tab{
+	background: #435359;
+	display: flex;
+	list-style-type: none;
+	margin-left: 0; 
+    padding-left: 0;
+}
+.signup,.login{
+	width: 50%;
+	text-decoration: none;
+	color: #94b0a4;
+	text-align: center;
+	padding:10px;
+}
+.login:hover{
+	background: rgb(20, 143, 110);
+	color: #fff;
+}
+.signup:hover{
+	background: rgb(20, 143, 110);
+	color: #fff;
+}
+h2{
+	color:#fff;
+	padding: 10px;
+	text-align: center;
+	font-weight: 300;
+}
+.name_block{
+	display: flex;
+	justify-content: space-between
+}
+#fName,#lName{
+	width: 49%;
+	padding: 10px 0;
+	text-align: center;
+	background: #24333c;
+	color: #94b0a4;
+	border: 1.5px solid #94b0a4;
+	margin: 10px 0; 
+}
+#email,#password{
+	display: block;
+	width: 100%;
+	padding: 10px 0;
+	text-align: center;
+	background: #24333c;
+	color: #94b0a4;
+	border: 1.5px solid #94b0a4;
+	margin: 10px 0;
+}
+.button-block {
+	display:block;
+	width:100%;
+	color: #fff;
+	background: #1ab188;
+	font-size: 30px;
+	padding: 10px;
+	font-weight: 600;
+	order: 1.5px solid #1ab188;
+}
+.button-block:hover{
+	color: #fff 0.9;
+	background: rgba(26,177,136,0.8);
+	font-size: 30px;
+	padding: 10px;
+	font-weight: 600;
+	order: 1.5px solid #1ab188;
+	cursor: pointer;
+}

+ 14 - 0
HwJs7/index.html

@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html lang="ru,en">
+<head>
+    <meta charset="UTF-8">
+    <link rel="stylesheet" href="style/style.css">
+    <title>HwJs8</title>
+    <link rel="shortcut icon" href="https://w7.pngwing.com/pngs/73/859/png-transparent-stencil-boeing-ah-64-apache-boeing-ch-47-chinook-art-apache-helicopter-airplane-mural-helicopter.png" type="image/x-icon">
+</head>
+<body>
+    <div id="box"></div>
+    <div id="sex"></div>
+    <script src="script/script.js"></script>
+</body>
+</html>

+ 65 - 0
HwJs7/script/script.js

@@ -0,0 +1,65 @@
+function table (element,info){
+	function clicker (button,el){
+		button.onclick=()=>{
+			fetch(el)
+			.then(res => res.json())
+			.then(luke =>table(sex,luke))
+		};
+	};
+	for(let i in info){
+		let tr = document.createElement('tr');
+		let th = document.createElement('th');
+		let td = document.createElement('td');
+		let button = document.createElement('button');
+		th.innerText=i;
+		tr.appendChild(th);
+		if (typeof info[i]==='string'&&info[i].indexOf("http://swapi.dev/api/")===0){
+			td.appendChild(button);
+			button.classList.add('linkButton');
+			button.innerText='link';
+			clicker(button,info[i]);
+		}else if(typeof info[i]==='object'){
+			for(let key of info[i]){
+				td.appendChild(button)
+				button.innerText='oppen array';
+				clicker(button,key);
+			}
+		}else{
+			td.innerText =info[i];
+		}
+		tr.appendChild(td);
+		element.appendChild(tr);
+	}
+}
+fetch('https://swapi.dev/api/people/1/')
+	.then(res => res.json())
+	.then(luke => table(box,luke))
+
+function myFetch(url){
+	return new Promise(function (resolve, reject){
+        const xhr = new XMLHttpRequest();
+		xhr.open('GET', url, true)
+        xhr.onload =function (){
+			if(xhr.status != 200){
+				reject(`Ошибка ${xhr.status}: ${xhr.statusText}`)
+			}else{
+				resolve(JSON.parse(xhr.responseText));
+			}
+		}
+		xhr.onerror = () => alert("Запрос не удался")
+	    xhr.send();
+    });
+}
+
+myFetch('https://swapi.dev/api/starships/9/')
+.then(luke => console.log(luke))
+
+const promise = new Promise(function (resolve, reject) {
+    myFetch('https://swapi.dev/api/people/1/')
+        .then(() => resolve('Promise'))
+})
+const delay = ms => new Promise(ok => setTimeout(() => ok("delay"), ms))
+
+Promise.race([promise, delay(300)]).then(function (value) {
+    console.log(`${value} win`);
+})

+ 21 - 0
HwJs7/style/style.css

@@ -0,0 +1,21 @@
+body{
+    background: rgb(0, 0, 0);
+}
+td,th,tr{
+    border: 1px solid rgb(224, 37, 131);
+    padding: 5px;
+    color: rgb(224, 37, 131);
+}
+#sex tr {
+    background: rgb(224, 37, 131);
+    border: 1px solid black;
+}
+
+#sex th{
+    color: black;
+    border: 1px solid black;
+}
+#sex td{
+    color: black;
+    border: 1px solid black;
+}