From 702efab1e165155865a50c5c1942edb6b9ab148b Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 17 Feb 2024 13:57:08 +0000 Subject: [PATCH 1/3] created files and basic function --- programmer-humour/index.html | 13 +++++++++++++ programmer-humour/script.js | 12 ++++++++++++ programmer-humour/style.css | 0 3 files changed, 25 insertions(+) create mode 100644 programmer-humour/index.html create mode 100644 programmer-humour/script.js create mode 100644 programmer-humour/style.css diff --git a/programmer-humour/index.html b/programmer-humour/index.html new file mode 100644 index 00000000..781be47a --- /dev/null +++ b/programmer-humour/index.html @@ -0,0 +1,13 @@ + + + + Programmer humour + + + + + + + + + \ No newline at end of file diff --git a/programmer-humour/script.js b/programmer-humour/script.js new file mode 100644 index 00000000..2803ad84 --- /dev/null +++ b/programmer-humour/script.js @@ -0,0 +1,12 @@ + +function fetchComic() { + return fetch("https://xkcd.now.sh/?comic=latest").then(function (data) { + console.log("getting the data back ..."); + console.log(data, "data"); + return data.json(); + }); +} + +fetchComic().then(function (comic) { + console.log(comic); +}); \ No newline at end of file diff --git a/programmer-humour/style.css b/programmer-humour/style.css new file mode 100644 index 00000000..e69de29b From eb96f125c45e4f44ce0d1680b9021cf116966565 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 17 Feb 2024 15:39:32 +0000 Subject: [PATCH 2/3] rendered the image --- programmer-humour/index.html | 10 ++++++---- programmer-humour/script.js | 17 +++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/programmer-humour/index.html b/programmer-humour/index.html index 781be47a..05343f0f 100644 --- a/programmer-humour/index.html +++ b/programmer-humour/index.html @@ -1,13 +1,15 @@ - - Programmer humour - + + + + + Programmer humour - +
\ No newline at end of file diff --git a/programmer-humour/script.js b/programmer-humour/script.js index 2803ad84..2e791a13 100644 --- a/programmer-humour/script.js +++ b/programmer-humour/script.js @@ -1,12 +1,13 @@ - +const comicImage = document.getElementById("comic-img"); function fetchComic() { - return fetch("https://xkcd.now.sh/?comic=latest").then(function (data) { - console.log("getting the data back ..."); - console.log(data, "data"); - return data.json(); - }); + return fetch("https://xkcd.now.sh/?comic=latest") + .then((data) => data.json()); } -fetchComic().then(function (comic) { +fetchComic().then((comic) => { + comicImage.src = comic.img console.log(comic); -}); \ No newline at end of file +}); + + + From 6415440553916cb1ade02b0837175dd3ebbbae2a Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 17 Feb 2024 15:52:55 +0000 Subject: [PATCH 3/3] reviewed changes from sonarcloud --- programmer-humour/index.html | 7 ++++--- programmer-humour/style.css | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/programmer-humour/index.html b/programmer-humour/index.html index 05343f0f..3e5bce2a 100644 --- a/programmer-humour/index.html +++ b/programmer-humour/index.html @@ -1,6 +1,7 @@ - - + + + @@ -9,7 +10,7 @@ - + image for comic \ No newline at end of file diff --git a/programmer-humour/style.css b/programmer-humour/style.css index e69de29b..363235f8 100644 --- a/programmer-humour/style.css +++ b/programmer-humour/style.css @@ -0,0 +1,10 @@ +body { + background-color: azure; +} + +#comic-img { + display: block; + margin-left: auto; + margin-right: auto; + width: 20%; +} \ No newline at end of file