From 9cd7edfe0fd53b1ec4be884e4106541038525b6d Mon Sep 17 00:00:00 2001 From: marrcelp Date: Tue, 10 Dec 2024 17:39:28 +0100 Subject: [PATCH 1/6] resolved exercise 1 --- 01/app.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/01/app.js b/01/app.js index 1c9992ed..ee47c2a8 100644 --- a/01/app.js +++ b/01/app.js @@ -1 +1,12 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const element = document.querySelector('.comments__item.comments__item--newest'); + +if (element){ + const elementsWithAtribute = element.querySelectorAll('[data-info]'); + console.log(elementsWithAtribute); + console.log(`Znaleziono ${elementsWithAtribute.length} elementy z podanym atrybutem`); + +} else { + console.log(`Nie znaleziono elementu o podanej klasie`); +} From eefeec1e5ee86562f49eb980c7dd41bb9a3c8238 Mon Sep 17 00:00:00 2001 From: marrcelp Date: Tue, 10 Dec 2024 18:08:22 +0100 Subject: [PATCH 2/6] resolved exercise 2 --- 02/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 1c9992ed..bf33138b 100644 --- a/02/app.js +++ b/02/app.js @@ -1 +1,10 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const linksWithUrl = document.querySelectorAll('[data-url]'); +console.log(linksWithUrl); + + +linksWithUrl.forEach((element) => { + const elementUrl = element.getAttribute('data-url'); + element.setAttribute('href', elementUrl) +}) \ No newline at end of file From dbe0fb8bc3c3aaf263249699ed7b72618322a7c3 Mon Sep 17 00:00:00 2001 From: marrcelp Date: Tue, 10 Dec 2024 18:28:44 +0100 Subject: [PATCH 3/6] resolved exercise no 3 --- 03/app.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index c299ca32..36e17df6 100644 --- a/03/app.js +++ b/03/app.js @@ -11,4 +11,18 @@ const buttonSettings = { color: '#444' }, text: 'Click me!', -} \ No newline at end of file +} + +const newButton = document.createElement('button'); +for (const property in buttonSettings.attr){ + newButton.setAttribute(property, buttonSettings.attr[property]); +} + +for (const property in buttonSettings.css){ + newButton.style[property] = buttonSettings.css[property]; +} + +newButton.textContent = buttonSettings.text; + +const element = document.querySelector('.parent-for-button'); +element.appendChild(newButton); \ No newline at end of file From 52f4936d9d98100d3f1b5107a1d4cd5fe42693bf Mon Sep 17 00:00:00 2001 From: marrcelp Date: Thu, 19 Dec 2024 20:24:25 +0100 Subject: [PATCH 4/6] resolved exercise 4 --- 04/app.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/04/app.js b/04/app.js index e6411e4e..bc083266 100644 --- a/04/app.js +++ b/04/app.js @@ -5,4 +5,34 @@ const menuItems = [ {text: 'start', url: '/'}, {text: 'galeria', url: '/gallery'}, {text: 'kontakt', url: '/contact'}, -]; \ No newline at end of file +]; + + +// const navElement = document.querySelector('nav'); + +// if (navElement){ +// const ulElement = document.createElement('ul'); +// navElement.appendChild(ulElement); +// } + +// const ulElement = document.querySelector('ul'); +// if(ulElement){ +// const liElement1 = document.createElement('li'); +// const liElement2 = document.createElement('li'); +// const liElement3 = document.createElement('li'); +// ulElement.appendChild(liElement1); +// ulElement.appendChild(liElement2); +// ulElement.appendChild(liElement3); +// } + +const navElement = document.querySelector('nav'); + +menuItems.forEach((el => { + const liElement = document.createElement('li'); + const aElement = document.createElement('a'); + + aElement.innerText = el.text; + aElement.setAttribute('href', el.url) + navElement.appendChild(liElement); + liElement.appendChild(aElement); +})) \ No newline at end of file From fe0321d1db27b301ff4f716878d1d00a4f524647 Mon Sep 17 00:00:00 2001 From: marrcelp Date: Thu, 19 Dec 2024 22:21:54 +0100 Subject: [PATCH 5/6] resolved exercise 5 --- 05/app.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/05/app.js b/05/app.js index 39abe5d5..ea38439d 100644 --- a/05/app.js +++ b/05/app.js @@ -1,3 +1,50 @@ console.log('DOM'); const curr = document.querySelector('.js-curr'); + +// 1 +const currParent = curr.parentElement; +const newButton = document.createElement('button'); +newButton.innerText = 'usuĊ„ z koszyka' +currParent.appendChild(newButton); + +// 2 +const currSiblings = Array.from(currParent.children); +currSiblings.forEach(el => el.classList.add('siblings')); + +// 3 +currParent.nextElementSibling.setAttribute('title', 'nextElementSibling'); + +// 4 +const lastSibling = currParent.parentElement.lastElementChild; +const pElement = document.createElement('p'); + +lastSibling.insertBefore(pElement, lastSibling.lastElementChild); + + +// 5 +const newArticle = document.createElement('article'); + +const articles = currParent.parentElement; +console.log(articles); + +articles.insertBefore(newArticle, currParent); +newArticle.classList.add('articles__item', 'article'); + +const newTitle = document.createElement('h1') +const newParagraph = document.createElement('p'); +const newBtn = document.createElement('button'); + +newTitle.innerText = 'JS - New Article'; +newParagraph.innerText = 'Lorem test'; +newBtn.innerText = 'new btn' + +newTitle.classList.add('article__title'); +newParagraph.classList.add('article__description'); +newBtn.classList.add('article__btn'); + +newArticle.appendChild(newTitle); +newArticle.appendChild(newParagraph); +newArticle.appendChild(newBtn); + + From 80f84e4b179707acf5058e63a92dc8be6ee26d5e Mon Sep 17 00:00:00 2001 From: marrcelp Date: Fri, 3 Jan 2025 14:49:04 +0100 Subject: [PATCH 6/6] add filter to currsiblings --- .DS_Store | Bin 0 -> 6148 bytes 05/app.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..21dc07c97503793be3f93b56315ccc144e8a8696 GIT binary patch literal 6148 zcmeHKIS#@=4733uB$||z`vrcmLhu4Uz}X>D1o~9Gi>EO@goFYO5)B$h_Ut;IjWR_X zi-<0+hq*{2A``fw+${9X?wj{)kQoKSamGd3L%Toi&gWCF`hCK-Yu#{i)1S z0V+TRr~nn90-qGH-V2*d0~x6R6`%r71?>A!;D$A^3-nJ1f{y^e5z=m0`z!%0mH^ho zE)W@*1{D}o%@IR`j(o|wn%D&fT{MRe%_nP4DC$qg`NhjcYak;PpaQQ73}f3^|6jpB z%>S<>?x+A2_$vi;v|KM2c%|&Ey_d6ITi_eG)!gA`SUUy5+cD7FF*eqYXI>O_#n!lA V6T3jCBkyz|e+En!8Ws4p0uNok6|w*T literal 0 HcmV?d00001 diff --git a/05/app.js b/05/app.js index ea38439d..f8d58b9c 100644 --- a/05/app.js +++ b/05/app.js @@ -10,7 +10,7 @@ currParent.appendChild(newButton); // 2 const currSiblings = Array.from(currParent.children); -currSiblings.forEach(el => el.classList.add('siblings')); +currSiblings.filter((el) => !el.classList.contains('js-curr')).forEach(el => el.classList.add('siblings')); // 3 currParent.nextElementSibling.setAttribute('title', 'nextElementSibling');