diff --git a/programmer-humour/index.html b/programmer-humour/index.html new file mode 100644 index 00000000..625b5ec0 --- /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..66e97fc5 --- /dev/null +++ b/programmer-humour/script.js @@ -0,0 +1,19 @@ +const imageComic = document.getElementById("imageComic"); + +function fetchingImg() { + 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:"); + }); +} +fetchingImg(); diff --git a/programmer-humour/style.css b/programmer-humour/style.css new file mode 100644 index 00000000..84417fc2 --- /dev/null +++ b/programmer-humour/style.css @@ -0,0 +1,23 @@ +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%; +}