From 9d9246e07939c1b190904e22a70e6c12dfdd037d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Be=C5=82z?= Date: Sat, 21 Dec 2024 10:14:35 +0000 Subject: [PATCH 1/5] done --- 01/app.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/01/app.js b/01/app.js index 1c9992ed..9f800409 100644 --- a/01/app.js +++ b/01/app.js @@ -1 +1,11 @@ -console.log('DOM'); \ No newline at end of file + +const liElement = document.querySelector('.comments__item.comments__item--newest'); +const dataInfoList = liElement.querySelectorAll('[data-info]'); + +if(liElement && dataInfoList) { + console.log(`Znaleziono ${dataInfoList.length} poniższe elementy z atrybutem data-info :`); + + dataInfoList.forEach(function(element) { + console.log(element) + }); +} \ No newline at end of file From 844b021af03b7004d00666f8273f142f64e17149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Be=C5=82z?= Date: Sat, 21 Dec 2024 12:03:23 +0000 Subject: [PATCH 2/5] done --- 02/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 1c9992ed..8f746491 100644 --- a/02/app.js +++ b/02/app.js @@ -1 +1,10 @@ -console.log('DOM'); \ No newline at end of file +const linkList = document.querySelectorAll('[data-url') + +linkList.forEach(function(link) { + const url = link.getAttribute('data-url'); + + if(url) { + link.setAttribute('href', url) + } +}); + From dd609db9c06352c9aa4fcc568a61c6b73f84140e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Be=C5=82z?= Date: Sat, 21 Dec 2024 12:12:52 +0000 Subject: [PATCH 3/5] done --- 03/app.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/03/app.js b/03/app.js index c299ca32..e7a4c6e2 100644 --- a/03/app.js +++ b/03/app.js @@ -11,4 +11,20 @@ const buttonSettings = { color: '#444' }, text: 'Click me!', +} + +const button = document.createElement('button'); + +for (const attr in buttonSettings.attr) { + button[attr] = buttonSettings.attr[attr]; +} +for (const style in buttonSettings.css) { + button.style[style] = buttonSettings.css[style]; +} + +button.textContent = buttonSettings.text; + +const parentButton = document.querySelector('.parent-for-button'); +if (parentButton) { + parentButton.appendChild(button); } \ No newline at end of file From 639f69bb85da065165c43d61177b9a974b9388c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Be=C5=82z?= Date: Sat, 21 Dec 2024 12:20:31 +0000 Subject: [PATCH 4/5] done --- 04/app.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/04/app.js b/04/app.js index e6411e4e..b4d9cef4 100644 --- a/04/app.js +++ b/04/app.js @@ -1,8 +1,24 @@ -console.log('DOM'); // struktura do wykorzystania w pętli const menuItems = [ {text: 'start', url: '/'}, {text: 'galeria', url: '/gallery'}, {text: 'kontakt', url: '/contact'}, -]; \ No newline at end of file +]; + +const nav = document.querySelector('nav'); +const ul = document.createElement('ul'); + + + +menuItems.forEach(function(item) { + const li = document.createElement('li'); + const a = document.createElement('a'); + a.href = item.url; + a.textContent = item.text; + + li.appendChild(a); + ul.appendChild(li); +}); + +nav.appendChild(ul); \ No newline at end of file From 0b207a30e076adc348653f3ee5a24a66109eafc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Be=C5=82z?= Date: Sat, 21 Dec 2024 14:07:54 +0000 Subject: [PATCH 5/5] done --- 05/app.js | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/05/app.js b/05/app.js index 39abe5d5..90b179fb 100644 --- a/05/app.js +++ b/05/app.js @@ -1,3 +1,45 @@ -console.log('DOM'); - const curr = document.querySelector('.js-curr'); + +// +const newButton = document.createElement('button'); +newButton.classList.add('article__btn'); +newButton.textContent = 'usuń z koszyka' + +curr.parentElement.insertBefore(newButton, curr.nextElementSibling); + + +// +let sibling = curr.parentElement.firstElementChild; +while (sibling) { + if (sibling !== curr) { + sibling.classList.add('siblings'); + } + sibling = sibling.nextElementSibling; +} + + +// +const nextArticle = curr.closest('.article').nextElementSibling; +if(nextArticle && nextArticle.classList.contains('article')) { + nextArticle.setAttribute('title', 'nextElementSibling'); +} + + +// +const lastArticle = document.querySelector('.articles__item:last-child'); +const paragraph = document.createElement('p'); +paragraph.textContent = 'Dodskowy paragraf.'; +const button = lastArticle.querySelector('.article__btn'); +lastArticle.insertBefore(paragraph, button); + +// +const newArticle = document.createElement('article'); +newArticle.classList.add('articles__item', 'article'); +const articlesSection = document.querySelector('.articles'); +articlesSection.insertBefore(newArticle, articlesSection.firstElementChild); + +newArticle.innerHTML = ` +

JS- Nowy Artykuł

+

Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur quo quibusdam, nemo neque consequuntur pariatur totam? Facere quaerat molestias hic.

+ +`; \ No newline at end of file