-
-
Notifications
You must be signed in to change notification settings - Fork 458
week 8 home work done #1009
base: manchester3
Are you sure you want to change the base?
week 8 home work done #1009
Changes from 1 commit
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "pwa-chrome", | ||
"request": "launch", | ||
"name": "Launch Chrome against localhost", | ||
"url": "http://localhost:8080", | ||
"webRoot": "${workspaceFolder}" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"liveServer.settings.port": 5501 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,12 @@ The following endpoint is publicly available from Github | |
|
||
1. What would you put in the following fields? `{owner}`, `{repo}`, `{pull_number}`? | ||
|
||
<!-- Write your answer here --> | ||
<!-- | ||
{owner} = octocat | ||
{repo} = Hello-World | ||
{pull_number} = 1 | ||
--> | ||
|
||
2. Describe in a sentence what this API endpoint returns when all of the fields are completed? | ||
|
||
<!-- Write your answer here --> | ||
<!-- Provides details for a review comment. I havn't catch that much --> | ||
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. Yeah exactly - looks to me like a pull request |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,11 @@ Open index.html in your browser. Every time you refresh the page, | |
a different greeting should be displayed in the box. | ||
*/ | ||
|
||
fetch('*** Write the API address here ***') | ||
.then(function(response) { | ||
return response.text(); | ||
}) | ||
.then(function(greeting) { | ||
// Write the code to display the greeting text here | ||
}); | ||
fetch("https://codeyourfuture.herokuapp.com/api/greetings") | ||
.then(function (response) { | ||
return response.text(); | ||
}) | ||
.then(function (greeting) { | ||
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 variable name. All seems to be working fine to me |
||
let greetingText = document.getElementById("greeting-text"); | ||
greetingText.innerText = greeting; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<style> | ||
#my_pictures_list { | ||
list-style: none; | ||
} | ||
.button { | ||
height: 50px; | ||
width: 85px; | ||
margin: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="main" id="main_container"> | ||
<ul> | ||
<li id="my_pictures_list" class="my_list"> | ||
<img | ||
src="https://images.dog.ceo/breeds/bullterrier-staffordshire/n02093256_4678.jpg" | ||
alt="random dog pictures" | ||
id="dogImages" | ||
/> | ||
</li> | ||
</ul> | ||
<button id="button" class="button">Next Picture</button> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
document.getElementById("button").addEventListener("click", () => { | ||
let makeImage = document.getElementById("dogImages"); | ||
|
||
fetch(`https://dog.ceo/api/breeds/image/random`) | ||
.then(function (data) { | ||
return data.json(); | ||
}) | ||
.then(function (newLink) { | ||
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. Great variable name |
||
makeImage.src = newLink.message; | ||
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. Ensure that any image you append onto the document also has an |
||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
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. Maybe here you could also think about displaying an error message in case something goes wrong |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<img src="" alt="" id="image" /> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
fetch("https://xkcd.now.sh/?comic=latest") | ||
.then(function (data) { | ||
if (data.ok) { | ||
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. Interesting that it has this |
||
console.log("success"); | ||
} else { | ||
console.log("unsuccessful"); | ||
} | ||
return data.json(); | ||
}) | ||
.then(function (newData) { | ||
const newImage = document.getElementById("image"); | ||
newImage.src = newData.img; | ||
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. Again don't forget the |
||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); |
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.
Looks good