From d8ea781cf6e461f3e2c025bfed62291194a8851f Mon Sep 17 00:00:00 2001 From: Weronika Jankowska Date: Fri, 13 Dec 2024 22:47:39 +0100 Subject: [PATCH 1/5] task 1 --- 01/app.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/01/app.js b/01/app.js index 1c9992ed..439ed43c 100644 --- a/01/app.js +++ b/01/app.js @@ -1 +1,11 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const element = document.querySelector( + '.comments__item.comments__item--newest' +); +console.log(element); + +if (element) { + const element2 = element.querySelectorAll('[data-info]'); + console.log(`Zostały znalezione ${element2.length} elementy`); +} \ No newline at end of file From df5d53c28217e9c895da186b253cd01a8fd74ac7 Mon Sep 17 00:00:00 2001 From: Weronika Jankowska Date: Fri, 13 Dec 2024 22:48:13 +0100 Subject: [PATCH 2/5] task 2 --- 02/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 1c9992ed..893a8c72 100644 --- a/02/app.js +++ b/02/app.js @@ -1 +1,9 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const links = document.querySelectorAll('[data-url]'); +console.log(links); + +links.forEach((el) => { + const attribute = el.getAttribute('data-url'); + el.setAttribute('href', attribute); +}); \ No newline at end of file From c40ffecc97f8416e3e190f6be870985ecbc8beae Mon Sep 17 00:00:00 2001 From: Weronika Jankowska Date: Fri, 13 Dec 2024 22:48:40 +0100 Subject: [PATCH 3/5] task 3 --- 03/app.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/03/app.js b/03/app.js index c299ca32..4b3867a0 100644 --- a/03/app.js +++ b/03/app.js @@ -3,12 +3,25 @@ console.log('DOM'); const buttonSettings = { attr: { className: 'btn', - title: 'super button' + title: 'super button', }, css: { border: '1px solid #336699', padding: '5px 20px', - color: '#444' + color: '#444', }, text: 'Click me!', -} \ No newline at end of file +}; +const container = document.querySelector('.parent-for-button'); +const button = document.createElement('button'); + +for (const key in buttonSettings.attr) { + const value = buttonSettings.attr[key]; + button[key] = value; +} +for (const key in buttonSettings.css) { + const value = buttonSettings.css[key]; + button.style[key] = value; +} +button.innerText = buttonSettings.text; +container.appendChild(button); \ No newline at end of file From 0e2c0ed4598fc79a3281062f8c6a71eb69d78a10 Mon Sep 17 00:00:00 2001 From: Weronika Jankowska Date: Fri, 13 Dec 2024 22:49:12 +0100 Subject: [PATCH 4/5] task 4 --- 04/app.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/04/app.js b/04/app.js index e6411e4e..fe84a2e5 100644 --- a/04/app.js +++ b/04/app.js @@ -1,8 +1,21 @@ console.log('DOM'); -// struktura do wykorzystania w pętli +const nav = document.querySelector('nav'); +const ulElement = document.createElement('ul'); + const menuItems = [ - {text: 'start', url: '/'}, - {text: 'galeria', url: '/gallery'}, - {text: 'kontakt', url: '/contact'}, -]; \ No newline at end of file + { text: 'start', url: '/' }, + { text: 'galeria', url: '/gallery' }, + { text: 'kontakt', url: '/contact' }, +]; +menuItems.forEach((item) => { + const liElement = document.createElement('li'); + const aElement = document.createElement('a'); + + liElement.appendChild(aElement); + ulElement.appendChild(liElement); + aElement.innerText = item.text; + aElement.href = item.url; +}); + +nav.appendChild(ulElement); \ No newline at end of file From 491c0a98a2ccc9ca90366aa2dc624b91e1e6442c Mon Sep 17 00:00:00 2001 From: Weronika Jankowska Date: Fri, 13 Dec 2024 22:50:15 +0100 Subject: [PATCH 5/5] task 5 --- 05/app.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/05/app.js b/05/app.js index 39abe5d5..509a21b2 100644 --- a/05/app.js +++ b/05/app.js @@ -1,3 +1,27 @@ console.log('DOM'); const curr = document.querySelector('.js-curr'); + +const newButton = document.createElement('button'); +newButton.textContent = 'usuń z koszyka'; +curr.parentElement.appendChild(newButton); + +const childElements = Array.from(curr.parentElement.children); + +childElements.forEach((element) => { + if (element !== curr) { + element.classList.add('siblings'); + } +}); + +const siblingElement = curr.parentElement.nextElementSibling; +siblingElement.title = 'nextElementSibling'; + +const lastArticle = curr.parentElement.nextElementSibling.nextElementSibling; +const button = lastArticle.children[lastArticle.children.length - 1]; +const p = document.createElement('p'); +p.textContent = 'lorem ipsum lorem lorem lalala'; +lastArticle.insertBefore(p, button); + +const nextArticle = curr.parentElement.cloneNode(true); +curr.parentElement.parentElement.insertBefore(nextArticle, curr.parentElement); \ No newline at end of file