-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_song.html
More file actions
170 lines (152 loc) · 7.54 KB
/
search_song.html
File metadata and controls
170 lines (152 loc) · 7.54 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Search Songs</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.3.0/animate.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.js"></script>
<script language="javascript" type="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="CSS/nav_bar.css">
</head>
<body>
<!--Navigation Bar -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"><img src="img/logo.png" class="web_logo" alt="web_logo"></a>
</div>
<div class="collapse navbar-collapse navbar-right" id="myNavbar">
<ul class="nav navbar-nav">
<li><a class="nav-link" href="index.html">Home</a></li>
<li class="dropdown"><a class="dropdown-toggle nav-link" data-toggle="dropdown" href="#">Pages<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a target="_blank" href="top_charts.html">Charts-Hot 50</a></li>
<li><a target="_blank" href="new_releases.html">New Releases</a></li>
<li><a target="_blank" href="songs_by_artists.html">Songs and Albums By Artists</a></li>
<li><a target="_blank" href="top_albums.html">Top Albums</a></li>
</ul>
</li>
<li><a class="nav-link" href="index.html#footer">About</a></li>
<li><a class="nav-link" target="_blank" href="feedback_form.php">Feedback Form</a></li>
<li <a class="active"><a class="active nav-link" href="search_song.html"><i class="glyphicon glyphicon-search"></i></a></li>
</ul>
</div>
</div>
</nav>
<!--Main Content-->
<!--Search Box-->
<div class="search-header container-fluid">
<div class="search-header-content">
<h1>Get information about any song</h1>
<div class="search-bar row">
<div class="col-lg-12">
<div class="row">
<div class="search-grp col-lg-3 col-md-3 col-sm-12">
<input type="text" id="artist" class="search-btn" placeholder="Enter Artist">
</div>
<div class="search-grp col-lg-3 col-md-3 col-sm-12">
<input type="text" id="song" class="search-btn" placeholder="Enter Song">
</div>
<div class="search-grp col-lg-3 col-md-3 col-sm-12">
<button type="button" class="search-sub-btn btn btn-outline-light">Search</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Result of the search box-->
<div class="search-result container-fluid">
<div class="search-result-content container">
<!-- Result here dynamically at run time-->
</div>
</div>
<!-- Javascript and Jquery-->
<script type="text/javascript">
$(document).ready(function()
{
$("h1").addClass("wow slideInRight");
$("h1").attr("data-wow-delay","1s");
$(".search-sub-btn").on("click",function()
{
$(".search-result-content").html("");
var name= document.getElementById("artist").value; // get the artist
var song= document.getElementById("song").value; // get the song name
console.log(name);
console.log(song);
$.getJSON("http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=e292f7273e2ec29065bf3e11f2836d29&artist="+name+"&track="+song+"&format=json",function(json)
{
if(json.error==undefined) // if correct name is enteres
{
console.log(json);
item=json.track;
if (item.album==undefined) // if the song album is not available in json file
{
it_image=" ";
it_album_title="NA";
}
else
{
if((item.album.image)==undefined) // if the song album image is not available in json file
{
it_image=" ";
}
else
it_image=item.album.image[3]["#text"];
if(item.album.title==undefined) // if the song album title is not available in json file
{
it_album_title="NA";
}
else
it_album_title=item.album.title;
}
if(item.toptags==undefined) // if the tags information is not available in the json file
{
it_genre="NA";
}
else
{
if(item.toptags.tag[0]==undefined) // if the genre is not available
it_genre="NA";
else
it_genre=item.toptags.tag[0].name;
}
if(item.wiki==undefined) // if the content is not available in the json file
{
it_content="";
}
else
it_content=item.wiki.content;
// appending the songs result
$(".search-result-content").append('<div class="search-result-img col-lg-4"><img src="'+it_image+'"></div><div class="col-lg-8"><ul class="details"><li>Song Name: '+item.name+'</li><li>Artist: '+item.artist.name+'</li><li>Album: '+it_album_title+'</li><li>Listeners: '+item.listeners+'</li><li>Genre: '+it_genre+'</li><li>'+it_content+'</li></ul></div></div>');
$(".search-result-content").css( //styling
{
"padding":"100px",
"font-weight":"400",
"line-height": "1.5",
"text-align": "left",
"color":"white",
})
}// end of if statement if the correct name is entered
else // if correct name is not entered
{
$(".search-result-content").append('<h2 style="color:deeppink;text-align:center;">Pls make sure to type in the correct artist name and song</h2>');
}
})// end of json method
})// end of search submit click function
}) // end of ready function
</script>
<script>
new WOW().init();
</script>
</body>
</html>