Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
}
17 changes: 3 additions & 14 deletions 01/app.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
const commentsItemNewest = document.querySelector('.comments__item', '.comments__item--newest');
const childrenOfLi = commentsItemNewest.querySelectorAll('p');

let listOfSpan;
const spanArr = [];

const listOfP = childrenOfLi.forEach((el) => {
listOfSpan = el.querySelectorAll('span');

for (let i = 0; i < listOfSpan.length; i++) {
spanArr.push(listOfSpan[i]);
}
});
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:',
spanArr.length
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.

👍

);
9 changes: 3 additions & 6 deletions 02/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
const aList = document.querySelectorAll('a');
console.log(aList);
const aList = document.querySelectorAll('a[data-url]');

let hasAttribute;

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

👍

});
32 changes: 10 additions & 22 deletions 03/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,19 @@ const buttonSettings = {

const button = document.createElement('button');

for (const key in buttonSettings) {
if (key === 'attr') {
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.attr) {
if (key === 'className') {
button.classList.add(key);
} else {
button.setAttribute(key, buttonSettings.attr[key]);
}
}

key === 'text' ? (button.textContent = buttonSettings.text) : undefined;

if (key === 'css') {
for (const key in buttonSettings.css) {
if (key === 'border') {
button.style[key] = buttonSettings.css[key];
} else if (key === 'padding') {
button.style[key] = buttonSettings.css[key];
} else if (key === 'color') {
button.style[key] = buttonSettings.css[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);
15 changes: 6 additions & 9 deletions 05/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const currParentSibling = currParent.nextElementSibling;
currParentSibling.setAttribute('title', 'nextSiblingElement');

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

const cloneArt = currParent.cloneNode(true);
Expand All @@ -23,13 +22,11 @@ const btn = document.createElement('button');
btn.textContent = 'Usuń z koszyka';
curr.insertAdjacentElement('afterend', btn);

let siblingEl = curr.nextElementSibling;
const siblingsArr = [];
let siblingEl = curr.parentElement.children;
console.log(siblingEl);

while ((curr = curr.nextElementSibling)) {
siblingsArr.push(siblingEl);
}

siblingsArr.forEach((el) => {
el.className = '.siblings';
[...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.

👍

});