This repository was archived by the owner on Oct 26, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 453
Altom week-8 #1006
Open
AltomHussain
wants to merge
1
commit into
CodeYourFuture:manchester3
Choose a base branch
from
AltomHussain:Altom-week-8
base: manchester3
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
Altom week-8 #1006
Changes from all commits
Commits
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"liveServer.settings.port": 5501 | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
let getBtn = document.getElementById("random-image"); | ||
function getData() { | ||
fetch("https://dog.ceo/api/breeds/image/random") | ||
.then((response) => { | ||
return response.json(); | ||
}) | ||
.then((data) => { | ||
let printImg = data.message; | ||
myImages(printImg); | ||
console.log(data); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
} | ||
let createUl = document.createElement("ul"); | ||
createUl.className += "ul-size"; | ||
function myImages(image) { | ||
let content = document.getElementById("add-photos"); | ||
let createImg = document.createElement("img"); | ||
createImg.className += "image-size"; | ||
let createList = document.createElement("li"); | ||
createList.className += "img-list"; | ||
createImg.src = image; | ||
createList.appendChild(createImg); | ||
createUl.appendChild(createList); | ||
content.appendChild(createUl); | ||
} | ||
|
||
getBtn.addEventListener("click", getData); | ||
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. Good job Altom, the only thing which is missing error handling when the data is fetched. Try to reorder you these function it looks messy. |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link href="style.css" rel="stylesheet" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<button id="random-image">Press to get image</button> | ||
<div id="add-photos"></div> | ||
<script src="exercise.js"></script> | ||
</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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.image-size { | ||
width: 400px; | ||
display: flex; | ||
} | ||
#container { | ||
display: flex; | ||
} | ||
.ul-size { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
.img-list { | ||
max-width: 400px; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
console.log("Hi"); | ||
function getData(url) { | ||
fetch(url) | ||
.then((response) => { | ||
console.log(response); | ||
return response.json(); | ||
}) | ||
.then((data) => { | ||
let getData = data.img; | ||
displayImg(getData); | ||
console.log(getData); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
} | ||
getData("https://xkcd.now.sh/?comic=latest"); | ||
let content = document.getElementById("container"); | ||
function displayImg(image) { | ||
let createImg = document.createElement("img"); | ||
createImg.src = image; | ||
content.appendChild(createImg); | ||
} | ||
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. Good Work, The missing part is the error handling code on the fetched data |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link href="style.css" rel="stylesheet" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="container"></div> | ||
<script src="exercise.js"></script> | ||
</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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
body { | ||
background-color: cyan; | ||
} | ||
#container { | ||
display: block; | ||
margin-left: 40%; | ||
margin-right: 30%; | ||
width: 60%; | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
You got wrong here, the random greeting should be displayed in the box not to display it in a h2 and you don't have .catch if there is an error. It needs to be fixed.