-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.html
233 lines (219 loc) · 5.44 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script
src="https://code.jquery.com/jquery-3.5.1.js"
integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
crossorigin="anonymous"
></script>
<title>TAYLOR SWIFT API</title>
<style>
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css);
@import url(https://fonts.googleapis.com/css?family=Pacifico&display=swap);
body {
font-weight: 600;
}
.container {
margin: auto 15%;
}
.content {
max-width: 700px;
color: #242424;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
"Helvetica Neue", sans-serif;
}
h1,
h2,
h3 {
font-weight: 600;
padding-bottom: 0.3em;
border-bottom: 1px solid #eaecef;
}
li {
padding-bottom: 0.5em;
font-weight: 600;
}
li > span {
text-decoration: underline;
color: black;
font-weight: 600;
/* color: rgb(67, 124, 230); */
}
a {
text-decoration: underline;
/* color: rgb(67, 124, 230); */
font-style: italic;
color: black;
}
.capitalize {
text-transform: capitalize;
/* text-align: center; */
}
#lyrics {
/* text-align: center; */
}
#fetch {
color: black;
font-weight: bold;
font-size: larger;
/* font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; */
/* font-family:Verdana, Geneva, Tahoma, sans-serif; */
font-family: "Pacifico", cursive;
font-style: italic;
}
#quotes {
font-size: xx-large;
}
button {
border: none;
background: #fff;
cursor: pointer;
}
button > i,
#tweet-quote {
color: red;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<h1>
<img src="https://i.imgur.com/nVjpIKO.jpg" height="60px" />
TAYLOR SWIFT API
</h1>
<p>Open Source API for Taylor Swift lyrics</p>
<h2>API End-Points</h2>
<ul>
<li>
GET RANDOM LYRICS:
<a
href="javascript:void(0)"
onclick="window.open(`${window.location.href}get`)"
target="_blank"
rel="noopener"
rel="noreferrer"
><span class="current-url"></span>get</a
>
</li>
QUERY PARAMETERS:
<ul>
<li>
GET RANDOM LYRICS FROM AN ALBUM:
<a
href="javascript:void(0)"
onclick="window.open(`${window.location.href}get?album=evermore`)"
><span class="current-url"></span>get?album=<album></a
>
</li>
<li>
GET RANDOM LYRICS FROM A SONG:
<a
href="javascript:void(0)"
onclick="window.open(`${window.location.href}get?song=lover`)"
><span class="current-url"></span>get?song=<song></a
>
</li>
</ul>
<li>
GET ALL LYRICS MATCHING THE FILTERS:
<ul>
<li>
FILTER BY SONG: <a
href="javascript:void(0)"
onclick="window.open(`${window.location.href}get-all?song=lover`)"
><span class="current-url"></span>get-all?song=<song></a
>
</li>
<li>
FILTER BY ALBUM: <a
href="javascript:void(0)"
onclick="window.open(`${window.location.href}get-all?album=reputation`)"
><span class="current-url"></span>get-all?album=<album></a
>
</li>
</ul>
</li>
</ul>
<h2>
Random Taylor Quote
<button class="btn" id="new-quote">
<i class="fa fa-refresh"></i>
</button>
<button class="btn">
<a id="tweet-quote"><i class="fa fa-twitter"></i></a>
</button>
</h2>
<div id="fetch">
<span id="quotes">"</span>
<div id="lyrics">
I don't know what I want, so don't ask me / 'Cause I'm
still trying to figure it out
</div>
<span id="quotes">"</span>
<p>
<span class="capitalize" id="song"
>- a place in this world, </span
><span class="capitalize" id="album">Taylor Swift</span>
</p>
</div>
<p>
*Contribute lyrics/features at
<a
href="https://github.com/MitanshiKshatriya/taylor-swift-api"
>GitHub</a
>
</p>
</div>
</div>
<script>
// rendering the current url in span elements
var currentUrl = window.location.href;
$("span.current-url").html(currentUrl);
function getQuotesJson() {
$.ajax({
method: "GET",
url: `${location.href}get`,
dataType: "json",
success: onSuccess,
error: onError,
});
}
function onSuccess(jsonReturn) {
console.log("success");
quoteData = jsonReturn;
// {"quote":"Cold was the steel of my axe to grind for the boys who broke my heart /
// Now I send their babies presents",
// "song":"Invisible String",
// "album":"folklore"}
var newquote = quoteData.quote;
var song = quoteData.song;
var album = quoteData.album;
$("#lyrics").html(newquote);
$("#song").html("- " + song + ", ");
$("#album").html(album);
$("#tweet-quote").attr(
"href",
"http://www.twitter.com/intent/tweet?text=" +
newquote +
" -" +
song +
", " +
album
);
}
function onError(jsonReturn) {
console.log("error");
}
$("#new-quote").on("click", function () {
getQuotesJson();
});
$("document").ready(function () {
getQuotesJson();
});
</script>
</body>
</html>