-
Notifications
You must be signed in to change notification settings - Fork 172
practice-js-dom-elements #150
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
Open
bartoszdudziak-dev
wants to merge
6
commits into
devmentor-pl:master
Choose a base branch
from
bartoszdudziak-dev:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
42adaa5
Task 01 completed
bartoszdudziak-dev ea92b8e
Task 02 completed
bartoszdudziak-dev bf20587
Task 03 completed
bartoszdudziak-dev 329ab34
Task 04 completed
bartoszdudziak-dev 3eccfaf
Task 05 completed
bartoszdudziak-dev c3d8ae4
Tasks: 02, 03, 05 - improvements
bartoszdudziak-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,11 @@ | ||
| console.log('DOM'); | ||
| console.log("DOM"); | ||
|
|
||
| const element = document.querySelector( | ||
| ".comments__item.comments__item--newest" | ||
| ); | ||
|
|
||
| if (element) { | ||
| const elementsInfoList = element.querySelectorAll(`*[data-info]`); | ||
|
|
||
| console.log(`Found: ${elementsInfoList.length} elements`); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,43 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="pl"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <meta name="author" content="Mateusz Bogolubow"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge" /> | ||
| <meta name="author" content="Mateusz Bogolubow" /> | ||
| <title>devmentor.pl - JS DOM Elements - #01</title> | ||
| </head> | ||
| <body> | ||
| </head> | ||
| <body> | ||
| <ul class="comments"> | ||
| <li class="comments__item comments__item--newest"> | ||
| <p>Lorem ipsum <span data-info="https://devmentor.pl">dolor</span> sit amet consectetur adipisicing elit. Iure, vero! <span data-info="https://devmentor.pl">Lorem</span> ipsum dolor sit amet, consectetur adipisicing elit. Nobis, amet?</p> | ||
| <p>Lorem ipsum dolor sit amet consectetur, <span data-info="https://devmentor.pl">adipisicing</span> elit. Magnam temporibus necessitatibus repellendus! Earum fugit distinctio facere iusto nesciunt! Voluptatem, perspiciatis?</p> | ||
| </li> | ||
| <li class class="comments__item"> | ||
| <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. <span data-info="https://devmentor.pl">Iure</span>, vero! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis, amet?</p> | ||
| <p>Lorem ipsum dolor <span data-info="https://devmentor.pl">sit</span> amet consectetur, adipisicing elit. Magnam temporibus necessitatibus repellendus! Earum fugit distinctio facere iusto nesciunt! Voluptatem, perspiciatis?</p> | ||
| </li> | ||
| <li class="comments__item comments__item--newest"> | ||
| <p> | ||
| Lorem ipsum <span data-info="https://devmentor.pl">dolor</span> sit | ||
| amet consectetur adipisicing elit. Iure, vero! | ||
| <span data-info="https://devmentor.pl">Lorem</span> ipsum dolor sit | ||
| amet, consectetur adipisicing elit. Nobis, amet? | ||
| </p> | ||
| <p> | ||
| Lorem ipsum dolor sit amet consectetur, | ||
| <span data-info="https://devmentor.pl">adipisicing</span> elit. Magnam | ||
| temporibus necessitatibus repellendus! Earum fugit distinctio facere | ||
| iusto nesciunt! Voluptatem, perspiciatis? | ||
| </p> | ||
| </li> | ||
| <li class class="comments__item"> | ||
| <p> | ||
| Lorem ipsum dolor sit amet consectetur adipisicing elit. | ||
| <span data-info="https://devmentor.pl">Iure</span>, vero! Lorem ipsum | ||
| dolor sit amet, consectetur adipisicing elit. Nobis, amet? | ||
| </p> | ||
| <p> | ||
| Lorem ipsum dolor | ||
| <span data-info="https://devmentor.pl">sit</span> amet consectetur, | ||
| adipisicing elit. Magnam temporibus necessitatibus repellendus! Earum | ||
| fugit distinctio facere iusto nesciunt! Voluptatem, perspiciatis? | ||
| </p> | ||
| </li> | ||
| </ul> | ||
|
|
||
| <script src="./app.js"></script> | ||
| </body> | ||
| </html> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,8 @@ | ||
| console.log('DOM'); | ||
| console.log("DOM"); | ||
|
|
||
| const linksList = document.querySelectorAll("a[data-url]"); | ||
|
|
||
| linksList.forEach((link) => { | ||
| const href = link.dataset.url; | ||
| link.setAttribute("href", href); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,28 @@ | ||
| 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 button = document.createElement("button"); | ||
| button.innerText = buttonSettings.text; | ||
|
|
||
| for (const propety in buttonSettings.attr) { | ||
| button.setAttribute(propety, buttonSettings.attr[propety]); | ||
| } | ||
|
|
||
| for (const propety in buttonSettings.css) { | ||
| button.style[propety] = buttonSettings.css[propety]; | ||
| } | ||
|
|
||
| const parent = document.querySelector(".parent-for-button"); | ||
| if (parent) parent.appendChild(button); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,24 @@ | ||
| 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 menuElement = document.createElement("ul"); | ||
|
|
||
| menuItems.forEach((item) => { | ||
| const itemElement = document.createElement("li"); | ||
|
|
||
| const linkElement = document.createElement("a"); | ||
| linkElement.setAttribute("href", item.url); | ||
| linkElement.textContent = item.text; | ||
|
|
||
| itemElement.appendChild(linkElement); | ||
| menuElement.appendChild(itemElement); | ||
| }); | ||
|
|
||
| const navigationElement = document.querySelector("nav"); | ||
| if (navigationElement) navigationElement.appendChild(menuElement); | ||
|
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. 👍 |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,59 @@ | ||
| console.log('DOM'); | ||
| console.log("DOM"); | ||
|
|
||
| const curr = document.querySelector('.js-curr'); | ||
| const curr = document.querySelector(".js-curr"); | ||
|
|
||
| if (curr) { | ||
| // Task 1 | ||
| const newButtonEl = document.createElement("button"); | ||
| newButtonEl.textContent = "Usun z koszyka"; | ||
|
|
||
| curr.parentElement.appendChild(newButtonEl); | ||
|
|
||
| // 2 | ||
| Array.from(curr.parentElement.children).forEach((child) => { | ||
| if (child === curr) return; | ||
| child.classList.add("siblings"); | ||
| }); | ||
|
|
||
| // 3 | ||
| const articleEl = curr.parentElement.nextElementSibling; | ||
| if (articleEl) articleEl.setAttribute("title", "nextElementSibling"); | ||
|
|
||
| // 4 | ||
| const lastArticleEl = curr.parentElement.parentElement.lastElementChild; | ||
| if (lastArticleEl && lastArticleEl.tagName === "ARTICLE") { | ||
| const buttonEl = lastArticleEl.querySelector("button"); | ||
|
|
||
| if (buttonEl) { | ||
| const newParagraphEl = document.createElement("p"); | ||
| newParagraphEl.textContent = "Additional paragraph"; | ||
| lastArticleEl.insertBefore(newParagraphEl, buttonEl); | ||
| } | ||
| } | ||
|
|
||
| // 5 | ||
| const sectionEl = curr.parentElement.parentElement; | ||
| if (sectionEl && sectionEl.tagName === "SECTION") { | ||
| const newArticle = document.createElement("article"); | ||
| newArticle.className = "articles__item article"; | ||
|
|
||
| const heading = document.createElement("h1"); | ||
| heading.classList.add("article__title"); | ||
| heading.textContent = "Heading"; | ||
|
|
||
| const paragraph = document.createElement("p"); | ||
| paragraph.classList.add("article__description"); | ||
| paragraph.textContent = "Paragraph"; | ||
|
|
||
| const button = document.createElement("button"); | ||
| button.classList.add("article__button"); | ||
| button.textContent = "Kupuje!"; | ||
|
|
||
| newArticle.appendChild(heading); | ||
| newArticle.appendChild(paragraph); | ||
| newArticle.appendChild(button); | ||
|
|
||
| const firstArticle = sectionEl.firstChild; | ||
| sectionEl.insertBefore(newArticle, firstArticle); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍