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

dz #35

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
17 changes: 17 additions & 0 deletions event-object/dropdown/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function openMenu (){
document.querySelector('.dropdown__list').classList.add('dropdown__list_active')
}
function closeMenu (){
document.querySelector('.dropdown__list').classList.remove('dropdown__list_active')
}
const value = document.querySelector('.dropdown__value')
value.addEventListener('click',openMenu )
let machineCode = Array.from(document.querySelectorAll('.dropdown__item'))
machineCode.forEach((item, index) =>{
item.onclick = () => {
closeMenu()
value.textContent = machineCode[index].textContent
return false
}
}
)
25 changes: 16 additions & 9 deletions event-object/keysolo/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ class Game {
this.lossElement.textContent = 0;
}

registerEvents() {
/*
TODO:
Написать обработчик события, который откликается
на каждый введённый символ.
В случае правильного ввода символа вызываем this.success()
При неправильном вводе символа - this.fail();
DOM-элемент текущего символа находится в свойстве this.currentSymbol.
*/
registerEvents() { // Обработчик нажатия клавиш //
let inputedSymbol;
let current = this;

function setEnteredSymbol() {
let symbol = current.currentSymbol.textContent.toUpperCase();
inputedSymbol = String.fromCharCode(event.keyCode)

if (symbol == inputedSymbol) {
current.success();
} else {
current.fail();
}
}

document.addEventListener('keydown', setEnteredSymbol);
}

success() {
Expand Down
21 changes: 21 additions & 0 deletions event-object/tabs/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let tabs = Array.from(document.getElementsByClassName("tab"));
let tabContent = document.getElementsByClassName("tab__content");

function changeActiveElements() {
for (const tab of tabs) {
tab.className = "tab";
}

for (const cntnt of tabContent) {
cntnt.className = "tab__content";
}

let index = tabs.indexOf(this)

tabs[index].className = "tab tab_active";
tabContent[index].className = "tab__content tab__content_active";
}

for (const tbs of tabs) {
tbs.onclick = changeActiveElements;
}
10 changes: 10 additions & 0 deletions js-features/cookie-clicker/task.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
.clicker__cookie {
width: 200px;
}

.new__clicker__cookie {
width: 250px;
}

*/
1 change: 1 addition & 0 deletions js-features/cookie-clicker/task.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="../../assets/css/style.css" />
<link rel="stylesheet" href="task.css">
<title>Игра-кликер</title>
</head>
<body>
Expand Down
12 changes: 12 additions & 0 deletions js-features/cookie-clicker/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const scoreClicks = document.getElementById(`clicker__counter`);
const cookie = document.getElementById(`cookie`);
let score = 0;

function touchCoocie() {
score += 1;
scoreClicks.textContent = score;
cookie.width = 180;
setTimeout(() => {cookie.width = 200;}, 50);
}

cookie.onclick = touchCoocie;
2 changes: 1 addition & 1 deletion js-features/countdown/task.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1 class="header__title">
<main class="content">
<div class="card">
<div id="status">
До окончания конкурса осталось секунд: <span id="timer">59</span>
До окончания конкурса осталось секунд: <span id="timer">10</span>
</div>
</div>
</main>
Expand Down
15 changes: 15 additions & 0 deletions js-features/countdown/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

const countTime = function(){
const output = document.getElementById("timer");

if (output.textContent >= 1){
output.textContent --;
} else if(output.textContent = '0'){
alert("Вы победили в конкурсе!");
}
}

setInterval(countTime,1000);



36 changes: 36 additions & 0 deletions js-features/mole-game/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const killMole = document.getElementById(`dead`);
const missClick = document.getElementById(`lost`);
let killed = parseInt(killMole.textContent);
let missed = parseInt(missClick.textContent);
let getHole = index => document.getElementById(`hole${index}`);


for (let i = 1; i <= 9; i++) {
getHole(i).onclick = function() {
if (this.className.includes(`hole_has-mole`)) {
killed += 1;
killMole.textContent = killed;
} else {
missed += 1;
missClick.textContent = missed;
}
checkWinner();
}
}

function checkWinner() {
if (killed === 10) {
alert(`Ты выиграл`);
clearScore();
} else if (missed === 5) {
alert(`Ты проиграл`);
clearScore();
}
}

function clearScore() {
killMole.textContent = 0;
killed = 0;
missClick.textContent = 0;
missed = 0;
}