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
9 changes: 8 additions & 1 deletion 01/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
console.log('DOM');
console.log('DOM');
const commentsItem = document.querySelector(".comments__item");
const newWest = document.querySelector(".comments__item--newest");

if (commentsItem && newWest) {
const dataInfo = document.querySelectorAll("[data-info]")
console.log(`Znaleziono ${dataInfo.length}`)
};
8 changes: 7 additions & 1 deletion 02/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
console.log('DOM');
console.log('DOM');

const links = document.querySelectorAll("[data-url]");
links.forEach(link => {
const url = link.getAttribute("data-url");
link.href = url;
});
2 changes: 1 addition & 1 deletion 02/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<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://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>
Expand Down
15 changes: 14 additions & 1 deletion 03/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,17 @@ const buttonSettings = {
color: '#444'
},
text: 'Click me!',
}
};

const button = document.createElement("button");
for (const key in buttonSettings) {
button.setAttribute(key, buttonSettings.attr[key]);
};

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

button.textContent = buttonSettings.text;
const parentElement = document.querySelector(".parent-for-button");
parentElement.appendChild(button);
54 changes: 50 additions & 4 deletions 04/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,53 @@ 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 nav = document.querySelector("nav");
const ul = document.querySelector("ul");

nav.innerHTML = `
<ul>
<li><a href="/">start</a></li>
<li><a href="/gallery">galeria</a></li>
<li><a href="/contact">kontakt</a></li>
</ul>
`
menuItems.forEach(link => {
const ul = document.querySelector("ul");
const li = document.createElement("li");
const a = document.createElement("a");
a.href = link.url;
a.textContent = link.text;
li.appendChild(a);
ul.appendChild(li);
});

nav.appendChild(ul);

// Utwórz poniższą strukturę menu za pomocą JS:

// ```
// <ul>
// <li><a href="/">start</a></li>
// <li><a href="/gallery">galeria</a></li>
// <li><a href="/contact">kontakt</a></li>
// </ul>
// ```

// Całość wstaw do elementu `<nav/>`.

// Początkowo spróbuj wykonać to zadanie bez wykorzystania poniższej struktury:

// ```
// const menuItems = [
// {text: 'start', url: '/'},
// {text: 'galeria', url: '/gallery'},
// {text: 'kontakt', url: '/contact'},
// ]
// ```

// Następnie zrób to samo, ale używając danych wraz z np. [forEach](https://developer.mozilla.org/pl/docs/Web/JavaScript/Referencje/Obiekty/Array/forEach).
31 changes: 31 additions & 0 deletions 05/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
console.log('DOM');

const curr = document.querySelector('.js-curr');
console.log(curr);

const newButton = document.createElement("button");
newButton.innerText = "usuń koszyk";
curr.parentNode.appendChild(newButton);

const siblings = Array.from(curr.parentNode.children);
siblings.forEach(sibling => {
if (sibling !== curr) {
sibling.classList.add("siblings");
};
});

const nextArticle = curr.parentNode.nextElementSibling;
if (nextArticle && nextArticle.classList.contains("article")) {
nextArticle.setAttribute("title", "nextElementSibling");
}

const lastArticle = document.querySelector("article:last-of-type");
const newParagraph = document.createElement("p");
newParagraph.textContent = "To jest nowy paragraf";
const buttonInLastArticle = lastArticle.querySelector("button");
lastArticle.insertBefore(newParagraph, buttonInLastArticle);

const articlesParent = document.querySelector("article").parentNode;
const newArticle = document.createElement('article');
const newArticleContent = document.createElement("p");
newArticleContent.textContent = "Nowy artykuł na początku listy";
newArticle.appendChild(newArticleContent);

articlesParent.insertBefore(newArticle, articlesParent.firstElementChild);