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 elementList = document.querySelector('.comments__item.comments__item--newest');

if(elementList !== null) {
const elementWithAttribute = elementList.querySelectorAll('[data-info]');
console.log("Liczba pasujących elementów:", elementWithAttribute.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.

👍

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

const linkList = document.querySelectorAll('[data-url]');

if(linkList !== null) {
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.

TUtaj to nie zadziała, querySelectorAll zwraca tablicę (pustą lub wypełnioną), więc jak chcemy mieć if to w takiej postaci -> if(linkList.length > 0)

linkList.forEach(link => {
const url = link.getAttribute('data-url');
link.href = url;
console.log("Gotowe url:", link.href);
});
};
19 changes: 18 additions & 1 deletion 03/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,21 @@ const buttonSettings = {
color: '#444'
},
text: 'Click me!',
}
}


const btn = document.createElement('button');
btn.innerText = buttonSettings.text;

for(let key in buttonSettings.attr) {
btn[key] = buttonSettings.attr[key]
}

for(let key in buttonSettings.css) {
btn.style[key] = buttonSettings.css[key];
}

console.log(btn);

const buttonParent = document.querySelector('.parent-for-button');
buttonParent.appendChild(btn);
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.

👍

53 changes: 52 additions & 1 deletion 04/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@

console.log('DOM');

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

/*
const ul = document.createElement('ul');

const liStart = document.createElement('li');
ul.appendChild(liStart);

const startA = document.createElement('a');
startA.innerText = "Start";
startA.href = "/";
liStart.appendChild(startA);


const liGallery = document.createElement('li');
ul.appendChild(liGallery);

const galleryA = document.createElement('a');
galleryA.innerText = "Galeria";
galleryA.href = "/gallery";
liGallery.appendChild(galleryA);


const liContact = document.createElement('li');
ul.appendChild(liContact);

const contactA = document.createElement('a');
contactA.innerText = "Kontakt";
contactA.href = "/contact";
liContact.appendChild(contactA);
console.log(ul);

const nav = document.querySelector('nav');
nav.appendChild(ul);
*/


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

for(let menu of menuItems) {
const li = document.createElement('li');
const a = document.createElement('a');
a.innerText = menu.text;
a.href = menu.url;
li.appendChild(a);
ul.appendChild(li);
}

const nav = document.querySelector('nav');
nav.appendChild(ul);
console.log(ul);
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.

👍

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

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

const newBtn = document.createElement('button');
newBtn.innerText = 'Usuń z koszyka';
curr.after(newBtn);

const parent = curr.parentElement;

for(let child of parent.children) {
if( child !== curr) {
child.classList.add('siblings');
}
}

const nextArticle = parent.nextElementSibling;
nextArticle.setAttribute('title', 'nextElementSibling');

const lastArticle = nextArticle.nextElementSibling;
const nextP = document.createElement('p');
lastArticle.insertBefore(nextP, lastArticle.lastElementChild);


const cloneArticle = parent.cloneNode(true);
const section = parent.parentElement;
section.insertBefore(cloneArticle, section.firstElementChild);

console.log(section);
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.

👍