-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
38 lines (36 loc) · 1.28 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quote App</title>
<link rel="stylesheet" href="style.css" class="ref">
</head>
<body>
<div class="quote-box">
<h2> Quote of the day</h2>
<blockquote id="quote">Loading.....</blockquote>
<span id="author">Loading....</span>
<div>
<button onclick="getquote(api_url)">New Quote</button>
<button onclick="tweet()"><img src="twiter.png">Tweet</button>
</div>
</div>
<script>
const quote = document.getElementById("quote");
const author = document.getElementById("author");
const api_url = "https://api.quotable.io/random";
async function getquote(url){
const response = await fetch(url);
const data = await response.json();
console.log(data);
quote.innerHTML = data.content;
author.innerHTML = data.author;
}
getquote(api_url);
function tweet(){
window.open("https://twitter.com/intent/tweet?text=" + quote.innerHTML +"---by " + author.innerHTML, "Tweet Window", "width=600,height=300");
}
</script>
</body>
</html>