-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
48 lines (41 loc) · 1.26 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quote generator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="quotebox">
<h2>
Quote by Taylor Swift
</h2>
<blockquote id="song">Loading..</blockquote>
<span id="quote">Loading</span>
<div>
<button onclick="getquote(api_url)">
New Quote
</button>
<button onclick="tweet()">Tweet<img src="tweet1.png"></button>
</div>
</div>
<script>
const song = document.getElementById("song");
const quote = document.getElementById("quote");
const api_url = "https://taylorswiftapi.onrender.com/get";
async function getquote(url){
const response = await fetch(url);
var data = await response.json();
console.log(data);
song.innerHTML = data.quote;
quote.innerHTML = data.song;
}
getquote(api_url);
function tweet(){
window.open("https://twitter.com/intent/tweet?text=" + quote.innerHTML + "--- by" + song.innerHTML,
"Tweet Window", "width=600, height=300");
}
</script>
</body>
</html>