Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

HW submission from new repo. (Week 8) #1037

Open
wants to merge 1 commit into
base: manchester3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions week-8/Homework/mandatory/1-practice/1-practice.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ The following endpoint is publicly available from Github

<!-- Write your answer here -->

`{owner user id} {repo name} {pull request number}`

2. Describe in a sentence what this API endpoint returns when all of the fields are completed?

<!-- Write your answer here -->

Data stored in this endpoint.
17 changes: 10 additions & 7 deletions week-8/Homework/mandatory/2-fetch-exercise/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ 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) {
// Write the code to display the greeting text here
let pEl = document.getElementById("greeting-text");
console.log(pEl);
pEl.innerText = greeting;
});
48 changes: 24 additions & 24 deletions week-8/Homework/mandatory/2-fetch-exercise/index.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<!doctype html>
<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8">
<title>CodeYourFuture - Fetch</title>
<meta name="description" content="Introduction to Fetch">
<meta name="author" content="CodeYourFuture">
<style>
#greeting-text {
font-size: 20px;
border: 1px solid #ccc;
background-color: #ddd;
width: 20%;
text-align: center;
margin: 0 50px;
padding: 30px;
}
</style>
</head>
<head>
<meta charset="utf-8" />
<title>CodeYourFuture - Fetch</title>
<meta name="description" content="Introduction to Fetch" />
<meta name="author" content="CodeYourFuture" />
<style>
#greeting-text {
font-size: 20px;
border: 1px solid #ccc;
background-color: #ddd;
width: 20%;
text-align: center;
margin: 0 50px;
padding: 30px;
}
</style>
</head>

<body>
<h1>A greeting in a random language...</h1>
<p id="greeting-text"></p>
<body>
<h1>A greeting in a random language...</h1>
<p id="greeting-text"></p>

<script src="exercise.js"></script>
</body>
</html>
<script src="exercise.js"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions week-8/Homework/mandatory/3-dog-photo-gallery/index.html
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" />
<title>Document</title>
</head>
<body>
<div id="container"></div>

<script src="script.js"></script>
</body>
</html>
32 changes: 32 additions & 0 deletions week-8/Homework/mandatory/3-dog-photo-gallery/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
let divEl = document.getElementById("container");

let buttonEl = document.createElement("button");
buttonEl.textContent = "Click Me";
let ulEl = document.createElement("ul");
let liEl = document.createElement("li");
let imgEl = document.createElement("img");

divEl.appendChild(buttonEl);
divEl.appendChild(ulEl);

ulEl.appendChild(liEl);
liEl.appendChild(imgEl);

function display() {
fetch("https://dog.ceo/api/breeds/image/random")
.then((response) => {
return response.json();
})
.then(function (data) {
console.log(data);
getImage(data);
});

function getImage(data) {
imgEl.src = data.message;
}
}

buttonEl.addEventListener("click", display);

window.onLoad = display();
12 changes: 12 additions & 0 deletions week-8/Homework/mandatory/4-programmer-humour/index.html
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>
<div id="container"></div>
<script src="script.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions week-8/Homework/mandatory/4-programmer-humour/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let divEl = document.getElementById("container");
let imgEl = document.createElement("img");
divEl.appendChild(imgEl);

fetch("https://xkcd.now.sh/?comic=latest")
.then((response) => {
return response.json();
})
.then((data) => {
console.log(data);
image(data);
});

function image(imageData) {
imgEl.src = imageData.img;
}
Empty file.