Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework№5.OR-Media.Pre-front #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Exercise1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>

<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="./index.css" />
<title>Request</title>
</head>

<body>
<script src="./script.js"></script>
</body>

</html>
14 changes: 14 additions & 0 deletions Exercise1/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var Name = prompt('Введите ваше имя');
var reg = /\d/g;
if (Name.match(reg) === null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверять на null не нужно это и так false будет значение. можно переписать как !Name.match(reg)

function reverse(Name) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нет смысла написание функции в if, она все равно поднимается вверх, и написание такого функций в if плохая практика

return Name.split("").reverse().join("");
}
alert(reverse(Name));
}
else {
function toUpperCase(Name) {
return Name.split('').map((v, i) => i % 2 == 0 ? v.toLowerCase() : v.toUpperCase()).join('');
}
alert(toUpperCase(Name));
}
47 changes: 47 additions & 0 deletions Exercise2/css/FirstStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.ButtonLink{
height: 100px;
width: 100px;
background-color: blue;
}
.ButtonStyle{
height: 100px;
width: 100px;
background-color: green;
}


.ButtonMaket{
height: 100px;
width: 100px;
background-color: yellow;
}
.container{
display: flex;
justify-content: center;
align-items: center;
flex-flow: wrap;
width: 100%;
height: 1000px;
background-color: wheat;
}
.Top{
display: flex;
justify-content: center;
align-items: center;
height: 100px;
width: 100%;
background-color: brown;
font-weight: 700;
font-size: 50px;
}
.Bottom{
display: flex;
justify-content: center;
align-items: center;
height: 100px;
width: 100%;
background-color: violet;
font-weight: 700;
font-size: 50px;
}

45 changes: 45 additions & 0 deletions Exercise2/css/SecondStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.ButtonLink{
height: 100px;
width: 100px;
background-color: blue;
}
.ButtonStyle{
height: 100px;
width: 100px;
background-color: green;
}
.ButtonMaket{
height: 100px;
width: 100px;
background-color: yellow;
}
.container{
display: flex;
justify-content: center;
align-items: center;
flex-flow: wrap;
width: 100%;
height: 1000px;
background-color: white;
}
.Top{
display: flex;
justify-content: center;
align-items: center;
height: 100px;
width: 100%;
background-color: aqua;
font-weight: 700;
font-size: 50px;
}
.Bottom{
display: flex;
justify-content: center;
align-items: center;
height: 100px;
width: 100%;
background-color: cornflowerblue;
font-weight: 700;
font-size: 50px;
}

72 changes: 72 additions & 0 deletions Exercise2/css/ThirdStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
*{
margin: 0;
}
.Container{
width: 100%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-flow: wrap;
flex-flow: wrap;
-ms-flex-line-pack: start;
align-content: flex-start;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}

.Header{
display: -webkit-box;
display: -ms-flexbox;
display: flex;
width: 100%;
height: 10%;
background-color: rgba(0,0,0,0.7);
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
margin-bottom: 0.9%;
}

.Body{
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 100%;
height: 77%;
background-color: rgba(0,0,0,0.3);
border-radius: 10px;
margin-bottom: 10px;
font-size: 50px;
font-weight: bold;
}


.Footer{
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 100%;
height: 10%;
background-color: black;
color: white;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
24 changes: 24 additions & 0 deletions Exercise2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<html>

<head>
<meta charset="utf-8">
<link name="Link" class="Slava" rel="stylesheet" type="text/css" href="./css/FirstStyle.css" />
<title>Three Buttons</title>
</head>

<body>
<div class="container">
<div class=Top>
<span class="TopText">Top</span>
</div>
<button class="ButtonLink" type="submit">LINK</button>
<button class="ButtonStyle" type="submit">STYLE</button>
<button class="ButtonMaket" type="submit">MAKET</button>
<script src="./js/index.js"></script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

подключение скриптов делается в конце body

<div class="Bottom">
<span class="BottomText">Bottom</span>
</div>
</div>
</body>

</html>
36 changes: 36 additions & 0 deletions Exercise2/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
document.getElementsByClassName("ButtonLink")[0].onclick = function () { window.open("https://vk.com/white_power69", "_blank") }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше использовать addEventListener

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

такого рода строки (https://vk.com/white_power69) лучше выносить в константные переменные, а еще лучше создать файл на подобии config.js или config.json и туда перенести такие переменные в объект, так как такая строка может много где использоваться в проекте, и что бы везде ее не менять при необходимости была возможность сделать это в одном месте

document.getElementsByClassName("ButtonStyle")[0].onclick = function () {
var el = document.querySelector("Link");
if (el.className == "Slava") {
el.href = "./css/SecondStyle.css";
el.className = "NotSlava";
}
else {
el.href = "./css/FirstStyle.css";
el.className = "Slava";
}
}
document.getElementsByClassName("ButtonMaket")[0].onclick = function () {
var Cont = document.querySelector(".container")
Cont.remove();
var el = document.querySelector("Link");
el.href = "./css/ThirdStyle.css";
var Body = document.body;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

повторяющийся код можно вынести в функцию. Отличаться будут только параметры.

var Container = document.createElement("div");
Body.appendChild(Container);
Container.className = "Container";
var Header = document.createElement("div");
Body.appendChild(Header);
Header.className = "Header";
var Telo = document.createElement("div");
Body.appendChild(Telo);
Telo.className = "Body";
var pTelo = document.createElement("p");
pTelo.innerHTML = "Otrisovka maketa flexbox";
Telo.appendChild(pTelo);
var Footer = document.createElement("div");
Body.appendChild(Footer);
Footer.className = "Footer";

}

1 change: 0 additions & 1 deletion README.md

This file was deleted.