From 4792d9ec54cfc63fed9ab51c775c961f73110d88 Mon Sep 17 00:00:00 2001 From: Sabella-8 Date: Wed, 14 Feb 2024 17:38:26 +0000 Subject: [PATCH 1/2] comic image --- programmer-humour/index.html | 22 ++++++++++++++++++++++ programmer-humour/script.js | 19 +++++++++++++++++++ programmer-humour/style.css | 23 +++++++++++++++++++++++ 3 files changed, 64 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..24fb0080 --- /dev/null +++ b/programmer-humour/index.html @@ -0,0 +1,22 @@ + + + + + + + + + +
+

Comic Viewer

+
+ +
+
+ + + diff --git a/programmer-humour/script.js b/programmer-humour/script.js new file mode 100644 index 00000000..36e93d2a --- /dev/null +++ b/programmer-humour/script.js @@ -0,0 +1,19 @@ +const imageComic = document.getElementById("imageComic"); + +function fetching() { + return fetch("https://xkcd.now.sh/?comic=latest") + .then((res) => { + if (!res.ok) { + throw new Error("error"); + } + return res.json(); + }) + .then((data) => { + console.log(data); + imageComic.src = data.img; + }) + .catch((error) => { + console.error("Error fetching comic:"); + }); +} +fetching(); diff --git a/programmer-humour/style.css b/programmer-humour/style.css new file mode 100644 index 00000000..434d368e --- /dev/null +++ b/programmer-humour/style.css @@ -0,0 +1,23 @@ +Copy code body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; +} + +.container { + max-width: 800px; + margin: 20px auto; + text-align: center; +} + +h1 { + margin-bottom: 20px; +} + +#comic-container { + margin-top: 20px; +} + +#imageComic { + max-width: 100%; +} From 64656530ba47c58db78ce2df734f3315ea32db12 Mon Sep 17 00:00:00 2001 From: Sabella-8 Date: Wed, 14 Feb 2024 18:00:02 +0000 Subject: [PATCH 2/2] corrected sonar --- programmer-humour/index.html | 2 +- programmer-humour/script.js | 4 ++-- programmer-humour/style.css | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/programmer-humour/index.html b/programmer-humour/index.html index 24fb0080..625b5ec0 100644 --- a/programmer-humour/index.html +++ b/programmer-humour/index.html @@ -1,5 +1,5 @@ - + { if (!res.ok) { @@ -16,4 +16,4 @@ function fetching() { console.error("Error fetching comic:"); }); } -fetching(); +fetchingImg(); diff --git a/programmer-humour/style.css b/programmer-humour/style.css index 434d368e..84417fc2 100644 --- a/programmer-humour/style.css +++ b/programmer-humour/style.css @@ -1,4 +1,4 @@ -Copy code body { +body { font-family: Arial, sans-serif; margin: 0; padding: 0;