-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
164 lines (158 loc) · 3.21 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
* {
width: 24rem;
}
</style>
</head>
<body>
<div
style="
position: relative;
width: 400px;
margin-left: 400px;
height: 200px;
border: 3px solid black;
box-shadow: 3px 3px 10px black;
"
>
<div
style="
text-align: center;
font-weight: 70rem;
font-size: large;
position: absolute;
bottom: 60%;
right: -24%;
"
>
( Autor )
</div>
<div
id="quotes"
style="
color: black;
text-align: center;
font-weight: 70rem;
font-size: large;
text-shadow: 0.1px 1px 4px;
position: absolute;
"
></div>
<div
id="author"
style="
color: black;
text-align: center;
font-weight: 70rem;
font-size: large;
font-style: italic;
position: absolute;
top: 80px;
right: 0;
width: 200px;
height: 100px;
"
></div>
</div>
<div
id="quotes"
style="
color: black;
text-align: center;
font-weight: 70rem;
font-size: large;
text-shadow: 0.1px 1px 5px;
"
></div>
<div
id="author"
style="
color: black;
text-align: center;
font-weight: 70rem;
font-size: large;
font-style: italic;
"
></div>
<br />
<div
style="
color: black;
text-align: center;
font-weight: 70rem;
font-size: large;
"
>
<button
id="newQ"
style="
color: black;
text-align: center;
font-weight: 70rem;
font-size: small;
/* border: 3px solid black; */
box-shadow: 3px 3px 10px black;
"
>
New Quotes
</button>
<button
id="newTweet"
style="
color: black;
text-align: center;
font-weight: 70rem;
font-size: small;
/* border: 3px solid black; */
box-shadow: 3px 3px 10px black;
height: 2%;
"
>
Tweet Me
</button>
</div>
<script>
const Quotes = document.getElementById("quotes");
const QuotesAuthor = document.getElementById("author");
const Button = document.getElementById("newQ");
const tweetButton = document.getElementById("newTweet");
let realData = "";
let data = "";
let tweetNow = () => {
let tweetPost = `https://twitter.com/intent/tweet?text=${data.text}`;
console.log(tweetPost);
window.open(tweetPost);
};
const random = () => {
let num = Math.floor(Math.random() * 20);
data = realData[num];
// console.log(data);
// console.log(realData);
Quotes.innerText = `${data.text}`;
data.author == null
? (QuotesAuthor.innerText = "Uknown")
: (QuotesAuthor.innerText = `${data.author}`);
};
const getQuotes = async () => {
const api = "https://type.fit/api/quotes";
try {
let data = await fetch(api);
realData = await data.json();
random();
// console.log(realData[num].text);
// console.log(realData[0].author);
} catch (error) {}
};
newQ.addEventListener("click", random);
tweetButton.addEventListener("click", tweetNow);
getQuotes();
</script>
</body>
</html>