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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
8 changes: 7 additions & 1 deletion 01/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
console.log('DOM');
const commentsItemNewest = document.querySelector('.comments__item.comments__item--newest');
const childrenOfP = commentsItemNewest.querySelectorAll('span');

console.log(
'Zostało znalezionych elementów posiadających atrybut data-info w liczbie:',
childrenOfP.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.

👍

);
54 changes: 37 additions & 17 deletions 01/index.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
<!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 - #01</title>
</head>
<body>
</head>
<body>
<ul class="comments">
<li class="comments__item comments__item--newest">
<p>Lorem ipsum <span data-info="https://devmentor.pl">dolor</span> sit amet consectetur adipisicing elit. Iure, vero! <span data-info="https://devmentor.pl">Lorem</span> ipsum dolor sit amet, consectetur adipisicing elit. Nobis, amet?</p>
<p>Lorem ipsum dolor sit amet consectetur, <span data-info="https://devmentor.pl">adipisicing</span> elit. Magnam temporibus necessitatibus repellendus! Earum fugit distinctio facere iusto nesciunt! Voluptatem, perspiciatis?</p>
</li>
<li class class="comments__item">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. <span data-info="https://devmentor.pl">Iure</span>, vero! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis, amet?</p>
<p>Lorem ipsum dolor <span data-info="https://devmentor.pl">sit</span> amet consectetur, adipisicing elit. Magnam temporibus necessitatibus repellendus! Earum fugit distinctio facere iusto nesciunt! Voluptatem, perspiciatis?</p>
</li>
<li class="comments__item comments__item--newest">
<p>
Lorem ipsum
<span data-info="https://devmentor.pl">dolor</span>
sit amet consectetur adipisicing elit. Iure, vero!
<span data-info="https://devmentor.pl">Lorem</span>
ipsum dolor sit amet, consectetur adipisicing elit. Nobis, amet?
</p>
<p>
Lorem ipsum dolor sit amet consectetur,
<span data-info="https://devmentor.pl">adipisicing</span>
elit. Magnam temporibus necessitatibus repellendus! Earum fugit distinctio facere iusto
nesciunt! Voluptatem, perspiciatis?
</p>
</li>
<li class class="comments__item">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
<span data-info="https://devmentor.pl">Iure</span>
, vero! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis, amet?
</p>
<p>
Lorem ipsum dolor
<span data-info="https://devmentor.pl">sit</span>
amet consectetur, adipisicing elit. Magnam temporibus necessitatibus repellendus! Earum
fugit distinctio facere iusto nesciunt! Voluptatem, perspiciatis?
</p>
</li>
</ul>

<script src="./app.js"></script>
</body>
</html>
</body>
</html>
9 changes: 8 additions & 1 deletion 02/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
console.log('DOM');
const aList = document.querySelectorAll('a[data-url]');

let hasAttribute;

const hasLink = aList.forEach((link) => {
hasAttribute = link.getAttribute('data-url');
link.setAttribute('href', hasAttribute);
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.

👍

});
41 changes: 30 additions & 11 deletions 03/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
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 button = document.createElement('button');

for (const key in buttonSettings.attr) {
if (key === 'className') {
button.classList.add(key);
} else {
button.setAttribute(key, buttonSettings.attr[key]);
}
}

for (const key in buttonSettings.css) {
button.style[key] = buttonSettings.css[key];
}

button.textContent = buttonSettings.text;
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.

👍


const sectionEl = document.querySelector('section');
sectionEl.appendChild(button);
28 changes: 24 additions & 4 deletions 04/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,27 @@ 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 navEl = document.querySelector('nav');

const ulEl = document.createElement('ul');
navEl.appendChild(ulEl);

const arr = [];

const createLinkList = menuItems.forEach((item) => {
const liStartEl = document.createElement('li');
ulEl.appendChild(liStartEl);

arr.push(liStartEl);

const addAEl = document.createElement('a');
liStartEl.appendChild(addAEl);

addAEl.setAttribute('href', item.url);
addAEl.textContent = item.text;
});
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.

👍

31 changes: 30 additions & 1 deletion 05/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
console.log('DOM');

const curr = document.querySelector('.js-curr');
let curr = document.querySelector('.js-curr');
const currParent = curr.parentElement;

const currParentSibling = currParent.nextElementSibling;
currParentSibling.setAttribute('title', 'nextSiblingElement');

const currLastParentSibling = currParentSibling.nextElementSibling;
const newParagraph = document.createElement('p');

const cloneArt = currParent.cloneNode(true);
const art = document.querySelector('.articles');

art.insertAdjacentElement('afterbegin', cloneArt);

newParagraph.textContent = 'Lorem Ipsum dolor sit amet';
const pEl = currLastParentSibling.querySelector('p');
currLastParentSibling.insertBefore(newParagraph, pEl);

const btn = document.createElement('button');
btn.textContent = 'Usuń z koszyka';
curr.insertAdjacentElement('afterend', btn);

let siblingEl = curr.parentElement.children;
console.log(siblingEl);

[...siblingEl].forEach((el) => {
if (el !== curr) {
el.className = 'siblings';
}
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.

👍

});