From 0778836a625ebd496a7549a4b9f75005d9957552 Mon Sep 17 00:00:00 2001 From: PatrickStojek Date: Mon, 26 Aug 2024 19:45:00 +0200 Subject: [PATCH 1/5] task 1 completed --- 01/app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/01/app.js b/01/app.js index 1c9992ed..ab6e587f 100644 --- a/01/app.js +++ b/01/app.js @@ -1 +1,5 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const commentsItem = document.querySelector('.comments__item ', '.comments__item--newest') +const DataInfoElements = commentsItem.querySelectorAll('[data-info]') +console.log(`znaleziono ${DataInfoElements.length} elementów wewnątrz elementu z tagiem ${commentsItem.nodeName}`) \ No newline at end of file From bdb2433c1d14d476e0dcc9c6af5f2b7a33625db9 Mon Sep 17 00:00:00 2001 From: PatrickStojek Date: Mon, 26 Aug 2024 19:59:15 +0200 Subject: [PATCH 2/5] task 2 completed --- 02/app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 1c9992ed..3fb537e0 100644 --- a/02/app.js +++ b/02/app.js @@ -1 +1,7 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); +const allLinks = document.querySelectorAll("[data-url]") +console.log(allLinks) +allLinks.forEach(link => { + const value = link.dataset.url + link.setAttribute('href', value) +}) \ No newline at end of file From 0cb8ba8ea03e185d7a0f3581ff1ac72c835cc5c1 Mon Sep 17 00:00:00 2001 From: PatrickStojek Date: Mon, 26 Aug 2024 20:34:51 +0200 Subject: [PATCH 3/5] task 3 completed --- 03/app.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index c299ca32..e049fda6 100644 --- a/03/app.js +++ b/03/app.js @@ -11,4 +11,33 @@ const buttonSettings = { color: '#444' }, text: 'Click me!', -} \ No newline at end of file +} + +const newBtn = document.createElement('button') +for(const key in buttonSettings) { + const value = buttonSettings[key] + if(typeof value === 'object' && value !== null ) { + if(key == 'attr') { + for(const property in value) { + newBtn.setAttribute(property, value[property]) + console.log(`${property}: ${value[property]}`) + + } + } + if(key == 'css') { + for(const property in value) { + newBtn.style[property] = value[property] + console.log(`${property}: ${value[property]}`) + } + } + + } else { + console.log(`${key}: ${value}`) + newBtn.innerText = value + } +} + +const parent = document.querySelector('.parent-for-button') +console.log(parent) +parent.appendChild(newBtn) + From cf6debb73fa3c2b5da5c61b88557decbe4cdd712 Mon Sep 17 00:00:00 2001 From: PatrickStojek Date: Mon, 26 Aug 2024 21:57:49 +0200 Subject: [PATCH 4/5] task 4 completed --- 04/app.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/04/app.js b/04/app.js index e6411e4e..34b6ce5c 100644 --- a/04/app.js +++ b/04/app.js @@ -2,7 +2,30 @@ 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 + { + text: 'start', + url: '/' + }, + { + text: 'galeria', + url: '/gallery' + }, + { + text: 'kontakt', + url: '/contact' + }, +]; + +const ulList = document.createElement('ul') +menuItems.forEach(item => { + newLi = document.createElement('li') + newA = document.createElement('a') + newA.innerText = item.text + newA.setAttribute('href',item.url) + + newLi.appendChild(newA) + ulList.appendChild(newLi) + +}) +const nav = document.querySelector('nav') +nav.appendChild(ulList) \ No newline at end of file From f38d23d580b4713076f613eba4c7da1e09914bd0 Mon Sep 17 00:00:00 2001 From: PatrickStojek Date: Mon, 26 Aug 2024 22:39:20 +0200 Subject: [PATCH 5/5] task 5 completed --- 05/app.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/05/app.js b/05/app.js index 39abe5d5..1f20346f 100644 --- a/05/app.js +++ b/05/app.js @@ -1,3 +1,34 @@ console.log('DOM'); const curr = document.querySelector('.js-curr'); +const parent = curr.parentElement +const newBtn = document.createElement('button') +newBtn.innerText = "Usuń z koszyka" +parent.appendChild(newBtn) + +const children = Array.from(parent.children) + +const sliblings = children.filter(child => child !== curr) + +console.log(sliblings) +console.log(sliblings) +for(let i = 0; i < sliblings.length; i++){ + sliblings[i].classList.toggle('sliblings') +} + +parent.nextElementSibling.setAttribute('title','nextElementSlibling') + +const lastArticle = parent.parentElement.lastElementChild +const pElement = document.createElement('p') +pElement.innerText = 'new paragraph' +const articlebutton = lastArticle.querySelector('button') +lastArticle.insertBefore(pElement,articlebutton) + +const newArticle = document.createElement('article') +newArticle.classList.add('articles__item', 'article') +newArticle.innerHTML = + `

JS - Elementy DOM2

+

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

+ ` + +parent.parentElement.insertBefore(newArticle,parent) \ No newline at end of file