-
Notifications
You must be signed in to change notification settings - Fork 172
add tasks 1-5 #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
add tasks 1-5 #163
Changes from all commits
c8de9bc
5b7bbf2
4b9396f
6d8f2d3
413d05f
10c8aab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,11 @@ | ||
| console.log('DOM'); | ||
| const el = document.querySelector('.comments__item.comments__item--newest'); | ||
|
|
||
| if (el) { | ||
| const items = el.querySelectorAll('[data-info]'); | ||
|
|
||
| console.log(`Liczba elementów z data-info: ${items.length}`); | ||
|
|
||
| items.forEach(el => { | ||
| console.log(el.dataset.info); | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,11 @@ | ||
| console.log('DOM'); | ||
| console.log('DOM'); | ||
| const links = document.querySelectorAll('[data-url]'); | ||
| console.log(links); | ||
|
|
||
| links.forEach(link => { | ||
| const url = link.dataset.url; | ||
|
|
||
| if (url) { | ||
| link.href = url; | ||
| } | ||
| }); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,32 @@ | ||
| console.log('DOM'); | ||
| // console.log('DOM'); | ||
|
|
||
| const buttonSettings = { | ||
| attr: { | ||
| className: 'btn', | ||
| title: 'super button' | ||
| }, | ||
| css: { | ||
| border: '1px solid #336699', | ||
| padding: '5px 20px', | ||
| color: '#444' | ||
| }, | ||
| text: 'Click me!', | ||
| } | ||
| attr: { | ||
| className: 'btn', | ||
| title: 'super button', | ||
| }, | ||
| css: { | ||
| border: '1px solid #336699', | ||
| padding: '5px 20px', | ||
| color: '#444', | ||
| }, | ||
| text: 'Click me!', | ||
| }; | ||
|
|
||
| const btnParent = document.querySelector('.parent-for-button'); | ||
|
|
||
| if (btnParent) { | ||
| const button = document.createElement('button'); | ||
|
|
||
| for (const key in buttonSettings.attr) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Teraz w moim odczuciu jest czytelniej :) |
||
| button[key] = buttonSettings.attr[key]; | ||
| } | ||
|
|
||
| for (const key in buttonSettings.css) { | ||
| button.style[key] = buttonSettings.css[key]; | ||
| } | ||
|
|
||
| button.textContent = buttonSettings.text; | ||
|
|
||
| btnParent.appendChild(button); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,55 @@ | ||
| console.log('DOM'); | ||
| // console.log('DOM'); | ||
|
|
||
| // struktura do wykorzystania w pętli | ||
| const menuItems = [ | ||
| {text: 'start', url: '/'}, | ||
| {text: 'galeria', url: '/gallery'}, | ||
| {text: 'kontakt', url: '/contact'}, | ||
| ]; | ||
| { text: 'start', url: '/' }, | ||
| { text: 'galeria', url: '/gallery' }, | ||
| { text: 'kontakt', url: '/contact' }, | ||
| ]; | ||
|
|
||
| const nav = document.querySelector('nav'); | ||
|
|
||
| if (nav) { | ||
| const menu = document.createElement('ul'); | ||
|
|
||
| const li1 = document.createElement('li'); | ||
| const a1 = document.createElement('a'); | ||
| a1.href = '/'; | ||
| a1.textContent = 'start'; | ||
| li1.appendChild(a1); | ||
|
|
||
| const li2 = document.createElement('li'); | ||
| const a2 = document.createElement('a'); | ||
| a2.href = '/gallery'; | ||
| a2.textContent = 'galeria'; | ||
| li2.appendChild(a2); | ||
|
|
||
| const li3 = document.createElement('li'); | ||
| const a3 = document.createElement('a'); | ||
| a3.href = '/contact'; | ||
| a3.textContent = 'kontakt'; | ||
| li3.appendChild(a3); | ||
|
|
||
| menu.appendChild(li1); | ||
| menu.appendChild(li2); | ||
| menu.appendChild(li3); | ||
|
|
||
| nav.appendChild(menu); | ||
| } | ||
|
|
||
| if (nav) { | ||
| const menu = document.createElement('ul'); | ||
|
|
||
| menuItems.forEach(item => { | ||
| const li = document.createElement('li'); | ||
| const a = document.createElement('a'); | ||
|
|
||
| a.textContent = item.text; | ||
| a.href = item.url; | ||
|
|
||
| li.appendChild(a); | ||
| menu.appendChild(li); | ||
| }); | ||
|
|
||
| nav.appendChild(menu); | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,27 @@ | ||
| console.log('DOM'); | ||
| // console.log('DOM'); | ||
|
|
||
| const curr = document.querySelector('.js-curr'); | ||
|
|
||
| if (curr) { | ||
| const parent = curr.parentElement; | ||
|
|
||
| const deleteBtn = document.createElement('button'); | ||
| deleteBtn.textContent = 'usuń z koszyka'; | ||
| parent.appendChild(deleteBtn); | ||
|
|
||
| [...parent.children].forEach(el => { | ||
| if (el !== curr) el.classList.add('siblings'); | ||
| }); | ||
|
|
||
| parent.nextElementSibling.setAttribute('title', 'nextElementSibling'); | ||
|
|
||
| const lastArticle = parent.parentElement.lastElementChild; | ||
| const p = document.createElement('p'); | ||
| p.textContent = 'Dodatkowy paragraf'; | ||
| lastArticle.insertBefore(p, lastArticle.querySelector('button')); | ||
|
|
||
| const newArticle = parent.cloneNode(true); | ||
| const newCurrBtn = newArticle.querySelector('.js-curr'); | ||
| if (newCurrBtn) newCurrBtn.classList.remove('js-curr'); | ||
| parent.parentElement.insertBefore(newArticle, parent); | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍