diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9c388d4 Binary files /dev/null and b/.DS_Store differ diff --git a/01/app.js b/01/app.js index 1c9992e..a25d0a8 100644 --- a/01/app.js +++ b/01/app.js @@ -1 +1,4 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const element = document.querySelector('.comments__item.comments__item--newest'); +console.log(element.querySelectorAll('[data-info]').length); \ No newline at end of file diff --git a/02/app.js b/02/app.js index 1c9992e..67de25d 100644 --- a/02/app.js +++ b/02/app.js @@ -1 +1,6 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const linkElements = document.querySelectorAll('[data-url]') +linkElements.forEach(el => { + el.setAttribute('href', el.getAttribute('data-url')); +}); \ No newline at end of file diff --git a/03/app.js b/03/app.js index c299ca3..dc9dd3b 100644 --- a/03/app.js +++ b/03/app.js @@ -11,4 +11,17 @@ const buttonSettings = { color: '#444' }, text: 'Click me!', -} \ No newline at end of file +} + +const parentForButtonElement = document.querySelector('.parent-for-button') +const buttonElement = document.createElement('button', buttonSettings) + +for (attr in buttonSettings.attr) { + buttonElement.setAttribute(attr, buttonSettings.attr[attr]) +} +for (style in buttonSettings.css) { + buttonElement.style[style] = buttonSettings.css[style]; +} +buttonElement.textContent = buttonSettings.text + +parentForButtonElement.appendChild(buttonElement); \ No newline at end of file diff --git a/04/app.js b/04/app.js index e6411e4..0fed2f5 100644 --- a/04/app.js +++ b/04/app.js @@ -2,7 +2,45 @@ 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 navElement = document.querySelector('nav'); +const ulElement = document.createElement('ul'); +const ulElement2 = document.createElement('ul'); + +const link1 = document.createElement('a'); +link1.setAttribute('href', '/') +link1.textContent = 'start'; + +const link2 = document.createElement('a'); +link2.setAttribute('href', '/gallery'); +link2.textContent = 'galeria'; + +const link3 = document.createElement('a'); +link3.setAttribute('href', '/contact'); +link3.textContent = 'kontakt'; + +const li1 = document.createElement('li'); +const li2 = document.createElement('li'); +const li3 = document.createElement('li'); + +li1.appendChild(link1) +li2.appendChild(link2) +li3.appendChild(link3) + +ulElement.appendChild(li1); +ulElement.appendChild(li2); +ulElement.appendChild(li3); + +navElement.appendChild(ulElement); +navElement.appendChild(ulElement2); + +menuItems.forEach(menuItem => { + const li = document.createElement('li') + li.innerHTML = '' + menuItem.text + '' + ulElement2.append(li); +}) + diff --git a/05/app.js b/05/app.js index 39abe5d..5e32656 100644 --- a/05/app.js +++ b/05/app.js @@ -1,3 +1,24 @@ console.log('DOM'); const curr = document.querySelector('.js-curr'); + +const deleteButton = document.createElement('button') +deleteButton.textContent = 'usuń z koszyka' +curr.insertAdjacentElement('afterend', deleteButton) + +curr.parentNode.childNodes.forEach(element => { + element.classList && ![...element.classList].includes('js-curr') && element.classList.add("siblings"); +}); + +curr.parentElement.nextElementSibling.setAttribute('title', 'nextElementSibling'); + +const newPElement = document.createElement('p') +newPElement.textContent = 'To jest nowy paragraf.' + +curr.parentElement.parentElement.lastElementChild.querySelector('.article__btn').insertAdjacentElement('beforebegin', newPElement); + +const newArticleElement = curr.parentElement.nextElementSibling.cloneNode(true); +newArticleElement.querySelector('.article__title').textContent = 'To jest nowy artykuł!' +newArticleElement.querySelector('.article__description').textContent = 'To jest treść nowego artykułu!' + +curr.parentElement.parentElement.prepend(newArticleElement);