-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
101 lines (92 loc) · 3.07 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script>
window.onload=init;
const QUOTES=[{quote:"hello",author:"Maaz"},{quote:"How you doing",author:"FRIENDS"},{quote:"esi",author:"Someone"}];
let twitterLink='https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=';
function generateQuote(){
const quoteIndex=Math.floor(Math.random() * QUOTES.length);
currentQuote=QUOTES[quoteIndex];
currentAuthor=QUOTES[quoteIndex];
console.log("quote generate");
let twittertextquote=currentQuote.quote.replace("/ /g","%20");
let twittertextauthor=currentQuote.author.replace("/ /g","%20");
let finallink=twitterLink+twittertextquote+"%20-%20"+twittertextauthor;
document.getElementById("tweet-quote").href=finallink;
document.getElementById("text").innerText=currentQuote.quote;
document.getElementById("author").innerText=currentAuthor.author;
}
function init(){
generateQuote();
}
</script>
<title>Random Quote Generator</title>
<style>* {
margin: 0;
padding: 0;
list-style: none;
vertical-align: baseline;
}
div {
position: relative;
z-index: 2;
}
.card{
border-radius: 3px;
position: relative;
//margin:8% auto auto auto;
width: 450px;
padding: 40px 50px;
display: table;
background-color: #fff;
.quote-text {
text-align: center;
width: 450px;
height: auto;
clear: both;
font-weight: 500;
font-size: 1.75em;
}
.quote-author {
width: 450px;
height: auto;
clear: both;
padding-top: 20px;
font-size: 1em;
text-align: right;
}
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<wrapper id="quote-box">
<div class="container" style="position: relative;
text-align: center;
color: white;">
<img src="https://source.unsplash.com/collection/1028723/1600x900" alt="Snow" style="width:100%;height:100%">
<div class="card" style=" border-radius: 3px;
width: 450px;
display:table;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white">
<div id="text" style=" text-align: center;
width: 450px;
height: auto;
clear: both;
font-weight: 500;
font-size: 1.75em;"></div>
<div id="author"></div>
<button class="btn btn-danger" id="new-quote" type="button" name="button" onclick="generateQuote()">New Quote</button>
<a href="#" id="tweet-quote" class="btn btn-primary">Tweet Quote</a>
</div>
</div>
</wrapper>
</body>
</html>