From eb07952fbdb9517bf45da4c0af4c8a162d069259 Mon Sep 17 00:00:00 2001 From: Iman Feisali Date: Wed, 1 Jul 2020 21:07:20 +0100 Subject: [PATCH 1/2] week 8 home work done --- .vscode/launch.json | 15 +++++++++ week-8/.vscode/settings.json | 3 ++ .../mandatory/1-practice/1-practice.md | 8 +++-- .../mandatory/2-fetch-exercise/exercise.js | 15 +++++---- .../mandatory/3-dog-photo-gallery/index.html | 33 +++++++++++++++++++ .../mandatory/3-dog-photo-gallery/script.js | 14 ++++++++ .../mandatory/4-programmer-humour/index.html | 12 +++++++ .../mandatory/4-programmer-humour/script.js | 16 +++++++++ 8 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 week-8/.vscode/settings.json create mode 100644 week-8/Homework/mandatory/3-dog-photo-gallery/index.html create mode 100644 week-8/Homework/mandatory/3-dog-photo-gallery/script.js create mode 100644 week-8/Homework/mandatory/4-programmer-humour/index.html create mode 100644 week-8/Homework/mandatory/4-programmer-humour/script.js diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..7a9dfa044 --- /dev/null +++ b/.vscode/launch.json @@ -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}" + } + ] +} \ No newline at end of file diff --git a/week-8/.vscode/settings.json b/week-8/.vscode/settings.json new file mode 100644 index 000000000..6f3a2913e --- /dev/null +++ b/week-8/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/week-8/Homework/mandatory/1-practice/1-practice.md b/week-8/Homework/mandatory/1-practice/1-practice.md index 02aa34989..154e37dff 100644 --- a/week-8/Homework/mandatory/1-practice/1-practice.md +++ b/week-8/Homework/mandatory/1-practice/1-practice.md @@ -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}`? - + 2. Describe in a sentence what this API endpoint returns when all of the fields are completed? - + diff --git a/week-8/Homework/mandatory/2-fetch-exercise/exercise.js b/week-8/Homework/mandatory/2-fetch-exercise/exercise.js index fb3a39c2a..6b278e2ff 100644 --- a/week-8/Homework/mandatory/2-fetch-exercise/exercise.js +++ b/week-8/Homework/mandatory/2-fetch-exercise/exercise.js @@ -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 - }); \ No newline at end of file +fetch("https://codeyourfuture.herokuapp.com/api/greetings") + .then(function (response) { + return response.text(); + }) + .then(function (greeting) { + let greetingText = document.getElementById("greeting-text"); + greetingText.innerText = greeting; + }); diff --git a/week-8/Homework/mandatory/3-dog-photo-gallery/index.html b/week-8/Homework/mandatory/3-dog-photo-gallery/index.html new file mode 100644 index 000000000..7e545237d --- /dev/null +++ b/week-8/Homework/mandatory/3-dog-photo-gallery/index.html @@ -0,0 +1,33 @@ + + + + + + Document + + + +
+ + +
+ + + diff --git a/week-8/Homework/mandatory/3-dog-photo-gallery/script.js b/week-8/Homework/mandatory/3-dog-photo-gallery/script.js new file mode 100644 index 000000000..59da9e0fd --- /dev/null +++ b/week-8/Homework/mandatory/3-dog-photo-gallery/script.js @@ -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) { + makeImage.src = newLink.message; + }) + .catch((error) => { + console.log(error); + }); +}); diff --git a/week-8/Homework/mandatory/4-programmer-humour/index.html b/week-8/Homework/mandatory/4-programmer-humour/index.html new file mode 100644 index 000000000..7ccdccad6 --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/index.html @@ -0,0 +1,12 @@ + + + + + + Document + + + + + + diff --git a/week-8/Homework/mandatory/4-programmer-humour/script.js b/week-8/Homework/mandatory/4-programmer-humour/script.js new file mode 100644 index 000000000..f2d100791 --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/script.js @@ -0,0 +1,16 @@ +fetch("https://xkcd.now.sh/?comic=latest") + .then(function (data) { + if (data.ok) { + console.log("success"); + } else { + console.log("unsuccessful"); + } + return data.json(); + }) + .then(function (newData) { + const newImage = document.getElementById("image"); + newImage.src = newData.img; + }) + .catch((error) => { + console.log(error); + }); From f93c36acc272c7dbcf49a470532ede40e0e3b775 Mon Sep 17 00:00:00 2001 From: Iman Feisali Date: Fri, 3 Jul 2020 00:06:16 +0100 Subject: [PATCH 2/2] level 350 done --- week-8/Homework/mandatory/4-programmer-humour/script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/week-8/Homework/mandatory/4-programmer-humour/script.js b/week-8/Homework/mandatory/4-programmer-humour/script.js index f2d100791..075d47883 100644 --- a/week-8/Homework/mandatory/4-programmer-humour/script.js +++ b/week-8/Homework/mandatory/4-programmer-humour/script.js @@ -10,6 +10,7 @@ fetch("https://xkcd.now.sh/?comic=latest") .then(function (newData) { const newImage = document.getElementById("image"); newImage.src = newData.img; + newImage = newData.alt; }) .catch((error) => { console.log(error);