Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb316036

Browse files
update Dad Joke Generator project
1 parent420c6ab commitb316036

File tree

7 files changed

+109
-1674
lines changed

7 files changed

+109
-1674
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<htmllang="en">
3+
<head>
4+
<metacharset="UTF-8"/>
5+
<metahttp-equiv="X-UA-Compatible"content="IE=edge"/>
6+
<metaname="viewport"content="width=device-width, initial-scale=1.0"/>
7+
<title>Dad Joke Generator</title>
8+
<linkrel="stylesheet"href="style.css"/>
9+
</head>
10+
<body>
11+
<divclass="container">
12+
<h1class="heading">Dad Joke Generator</h1>
13+
<h2class="joke"id="joke">Dad Joke</h2>
14+
<buttonclass="btn"id="btn">Tell me a joke</button>
15+
</div>
16+
<scriptsrc="index.js"></script>
17+
</body>
18+
</html>

‎projects/dad-jokes-generator/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
constbtnEl=document.getElementById("btn");
2+
constjokeEl=document.getElementById("joke");
3+
4+
constapiKey="SAXb3lrT9IIorMjQkAFWBg==KCDQCZgWgcoAU4ai";
5+
6+
constoptions={
7+
method:"GET",
8+
headers:{
9+
"X-Api-Key":apiKey,
10+
},
11+
};
12+
13+
constapiURL=`https://api.api-ninjas.com/v1/dadjokes?limit=1`;
14+
15+
asyncfunctiongetJoke(){
16+
try{
17+
btnEl.innerText="Loading...";
18+
btnEl.disabled=true;
19+
jokeEl.innerText="Updating...";
20+
constresponse=awaitfetch(apiURL,options);
21+
constdata=awaitresponse.json();
22+
constjokeContent=data[0].joke;
23+
jokeEl.innerText=jokeContent;
24+
btnEl.innerText="Tell me a joke";
25+
btnEl.disabled=false;
26+
console.log(data);
27+
}catch(error){
28+
console.log(error);
29+
jokeEl.innerText="An error happened, try again later";
30+
btnEl.innerText="Tell me a joke";
31+
btnEl.disabled=false;
32+
}
33+
}
34+
35+
getJoke();
36+
37+
btnEl.addEventListener("click",getJoke);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
body {
2+
margin:0;
3+
display: flex;
4+
min-height:100vh;
5+
justify-content: center;
6+
align-items: center;
7+
font-family: monospace;
8+
background:linear-gradient(to left bottom, lightblue, lightpink, lightblue);
9+
}
10+
11+
.container {
12+
background-color:rgba(255,255,255,0.3);
13+
box-shadow:06px10pxrgba(0,0,0,0.3);
14+
padding:20px;
15+
border-radius:15px;
16+
width:85%;
17+
text-align: center;
18+
color: darkgreen;
19+
}
20+
21+
.heading {
22+
font-size:35px;
23+
font-weight:200;
24+
font-family: Impact;
25+
letter-spacing:2px;
26+
27+
text-shadow:5px5px2pxrgba(0,0,0,0.3);
28+
}
29+
30+
.joke {
31+
font-size:25px;
32+
font-weight:500;
33+
margin:40px;
34+
}
35+
36+
.btn {
37+
font-size:18px;
38+
font-weight:700;
39+
border-radius:5px;
40+
cursor: pointer;
41+
padding:10px;
42+
margin-top:15px;
43+
background-color:rgba(255,255,255,0.3);
44+
border-color:rgba(255,255,255,0.6);
45+
text-transform: uppercase;
46+
width:300px;
47+
color: darkgreen;
48+
}
49+
50+
.btn:hover {
51+
background-color:rgba(255,255,255,0.5);
52+
box-shadow:04px4pxrgba(0,0,0,0.3);
53+
transition: all300ms ease;
54+
}

‎projects/project-idea-generator/index.html

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎projects/project-idea-generator/src/css/styles.css

Lines changed: 0 additions & 102 deletions
This file was deleted.

‎projects/project-idea-generator/src/js/main.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp