Skip to content
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
11 changes: 10 additions & 1 deletion 01/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
console.log('DOM');
console.log("DOM");

const element = document.querySelector(
".comments__item.comments__item--newest"
);

if (element) {
const dataSetElement = element.querySelectorAll("[data-info]");
console.log(dataSetElement.length);
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

10 changes: 9 additions & 1 deletion 02/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
console.log('DOM');
console.log("DOM");

const dataUrl = document.querySelectorAll("[data-url");
dataUrl.forEach(function (el) {
const url = el.dataset.url;
if (!el.hasAttribute("href")) {
el.setAttribute("href", url);
}
});
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

30 changes: 17 additions & 13 deletions 02/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<!DOCTYPE html>
<html lang="pl">
<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">
<meta name="author" content="Mateusz Bogolubow">
<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" />
<meta name="author" content="Mateusz Bogolubow" />
<title>devmentor.pl - JS DOM Elements - #02</title>
</head>
<body>
</head>
<body>
<h1>Moje ulubione strony:</h1>
<ul>
<li><a data-url="https://devmentor.pl">devmentor.pl</a></li>
<li><a data-url="https://developer.mozilla.org/pl/">eveloper.mozilla.org</a></li>
<li><a data-url="https://stackoverflow.com">stackoverflow.com</a></li>
<li><a>null</a></li>
<li><a data-url="https://devmentor.pl">devmentor.pl</a></li>
<li>
<a data-url="https://developer.mozilla.org/pl/"
>developer.mozilla.org</a
>
</li>
<li><a data-url="https://stackoverflow.com">stackoverflow.com</a></li>
<li><a>null</a></li>
</ul>
<script src="./app.js"></script>
</body>
</html>
</body>
</html>
41 changes: 29 additions & 12 deletions 03/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
console.log('DOM');
console.log("DOM");

const buttonSettings = {
attr: {
className: 'btn',
title: 'super button'
},
css: {
border: '1px solid #336699',
padding: '5px 20px',
color: '#444'
},
text: 'Click me!',
}
attr: {
className: "btn",
title: "super button",
},
css: {
border: "1px solid #336699",
padding: "5px 20px",
color: "#444",
},
text: "Click me!",
};

const buttonParent = document.querySelector(".parent-for-button");
const btn = document.createElement("button");
const buttonText = document.createTextNode(buttonSettings.text);
buttonParent.appendChild(btn);

if (btn) {
btn.appendChild(buttonText);
for (const property in buttonSettings.attr) {
btn.setAttribute(property, buttonSettings.attr[property]);
}

for (const cssProperty in buttonSettings.css) {
console.log(cssProperty);
btn.style.setProperty(cssProperty, buttonSettings.css[cssProperty]);
}
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

46 changes: 41 additions & 5 deletions 04/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
console.log('DOM');
console.log("DOM");

// struktura do wykorzystania w pętli
const menuItems = [
{text: 'start', url: '/'},
{text: 'galeria', url: '/gallery'},
{text: 'kontakt', url: '/contact'},
];
{ text: "start", url: "/" },
{ text: "galeria", url: "/gallery" },
{ text: "kontakt", url: "/contact" },
];

const ulElement = document.createElement("ul");
const navElement = document.querySelector("nav");
navElement.appendChild(ulElement);

// Rozwiązanie bez tablicy
for (let i = 0; i < 3; i++) {
const newLiElement = document.createElement("li");
const newLinkElement = document.createElement("a");
ulElement.appendChild(newLiElement);
newLiElement.appendChild(newLinkElement);
if (i === 0) {
const firstTextNode = document.createTextNode("start");
newLinkElement.appendChild(firstTextNode);
newLinkElement.setAttribute("href", "/");
} else if (i === 1) {
const secondTextNode = document.createTextNode("galeria");
newLinkElement.appendChild(secondTextNode);
newLinkElement.setAttribute("href", "/gallery");
} else if (i === 2) {
const thirdTextNode = document.createTextNode("kontakt");
newLinkElement.appendChild(thirdTextNode);
newLinkElement.setAttribute("href", "/contact");
}
}

// Rozwiązanie z tablicą

menuItems.forEach(function (obj) {
const newLiElement = document.createElement("li");
const newLinkElement = document.createElement("a");
ulElement.appendChild(newLiElement);
newLiElement.appendChild(newLinkElement);
newLinkElement.append(obj.text);
newLinkElement.setAttribute("href", obj.url);
});
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

30 changes: 28 additions & 2 deletions 05/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
console.log('DOM');
console.log("DOM");

const curr = document.querySelector('.js-curr');
const curr = document.querySelector(".js-curr");
const removeBtn = document.createElement("button");
const currParent = curr.parentElement;

currParent.appendChild(removeBtn);
const removeBtnText = document.createTextNode("Usuń z koszyka");
removeBtn.appendChild(removeBtnText);

const siblings = currParent.children;
const siblingsArray = [...siblings];

siblingsArray.forEach(function (el) {
if (!el.classList.contains("js-curr")) {
el.classList.add("sibling");
}
});
if (currParent.nextElementSibling.classList.contains("article")) {
currParent.nextElementSibling.setAttribute("title", "nextElementSibling");
}

const articleParrent = currParent.parentElement;
const p = document.createElement("p");
const lastBtn = articleParrent.lastElementChild.lastElementChild;
articleParrent.lastElementChild.insertBefore(p, lastBtn);

const clonedArticle = currParent.cloneNode(true);
articleParrent.insertBefore(clonedArticle, currParent);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

58 changes: 35 additions & 23 deletions 05/index.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
<!DOCTYPE html>
<html lang="pl">
<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">
<meta name="author" content="Mateusz Bogolubow">
<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" />
<meta name="author" content="Mateusz Bogolubow" />
<title>devmentor.pl - JS DOM Elements - #05</title>
</head>
<body>
</head>
<body>
<section class="articles">
<article class="articles__item article">
<h1 class="article__title">JS - Elementy DOM</h1>
<p class="article__description">Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur quo quibusdam, nemo neque consequuntur pariatur totam? Facere quaerat molestias hic.</p>
<button class="article__btn js-curr">Kupuję!</button>
</article>
<article class="articles__item article">
<h1 class="article__title">JS - Zdarzenia</h1>
<p class="article__description">Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur quo quibusdam, nemo neque consequuntur pariatur totam? Facere quaerat molestias hic.</p>
<button class="article__btn">Kupuję!</button>
</article>
<article class="articles__item article">
<h1 class="article__title">JS - Formularze</h1>
<p class="article__description">Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur quo quibusdam, nemo neque consequuntur pariatur totam? Facere quaerat molestias hic.</p>
<button class="article__btn">Kupuję!</button>
</article>
<article class="articles__item article">
<h1 class="article__title">JS - Elementy DOM</h1>
<p class="article__description">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur
quo quibusdam, nemo neque consequuntur pariatur totam? Facere quaerat
molestias hic.
</p>
<button class="article__btn js-curr">Kupuję!</button>
</article>
<article class="articles__item article">
<h1 class="article__title">JS - Zdarzenia</h1>
<p class="article__description">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur
quo quibusdam, nemo neque consequuntur pariatur totam? Facere quaerat
molestias hic.
</p>
<button class="article__btn">Kupuję!</button>
</article>
<article class="articles__item article">
<h1 class="article__title">JS - Formularze</h1>
<p class="article__description">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur
quo quibusdam, nemo neque consequuntur pariatur totam? Facere quaerat
molestias hic.
</p>
<button class="article__btn">Kupuję!</button>
</article>
</section>
<script src="./app.js"></script>
</body>
</body>
</html>