-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
200 lines (156 loc) · 6.46 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Find the Best Songz for any artist!</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
<script type="text/javascript" src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'></script>
<script type="text/javascript">
$(document).ready(function(){
var ex=$("#examples");
random_artists=["Van Halen", "David Lee Roth", "Sammy Hagar", "Steve Vai", "Michael Jackson","White Snake","Prince","Poison","Guns and Roses","Metallica","Motley Crue"];
num=Math.floor(Math.random()*11)
random_artist=random_artists[num];
ex.text("ex: " + random_artist);
var query;
$('#button1').click(function(){
search=$("#query").val();
search_url="http://www.gorankem.com:4000/api/v1/search/results/"+search+".js?callback=?";
//extract the id from search
$.getJSON(search_url,function(json){
$.each(json,function(i,result){
if (this['position']=="1")
{
query=this['search-result']['id'];
var img_url='http://gorankem.com:4000/api/v1/artist/image2/'+query+'.js?callback=?';
// $.getJSON(img_url,function(json){
// $.each(json.image,function(i,img){
// $("#results").prepend('<p><img src='+img.url+' /></p>');
// });
// });
//get top tracks from the artist
var url='http://gorankem.com:4000/api/v1/artist/tracks/'+query+'.js?callback=?';
$.getJSON(url,function(json){
$("#results").text("")
$.each(json.tracks,function(i,track){
$("#results").append('<p class="Heading1a">'+track.rank+' '+track.title+' with ' +track.value +' points</p>');
});
});
}
});
});
});
});
//
/* $.getJSON(theUrl + "?callback=?",null,
function(data) {
$.each(data, function() {
$("#song-list").append('<li>'+data.tracks.rank+'</li>');
//'<li id="' + this.tracks['rank'] + '"><h2 class="song-title"><a href="#" title="'+this.tracks['title']+'">'+this.tracks['title']+'</a></h2><div class="song-content">'+ this.tracks['value'] + ' points.</div><!-- /.song-content --></li>'
});
var songList=document.getElementById("song-list");
alert(this);
//songList.appendChild(items);
}
);
*/
$(function(){
$('#button1').click(function(){
$('.lastfmImage').remove();
$('.lastfmBio').remove();
query=$("#query").val();
$("#searched_for").text('You searched for ' +query);
var theUrl="http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist="+query+"&api_key=67cdab0ced66f1fcd971fc1bef514ff0&format=json&callback=?";
$.getJSON(theUrl, function(data) {
if (data.artist==null)
{
alert("no artist found")
}
else
{
var body = document.getElementById("song-list");
$.each(data.artist.image, function(i,img){
if (img['size']=='mega'){
var image=document.createElement('img');
image.setAttribute('src', img['#text']);
image.setAttribute('id', i+' - '+img['size']);
image.setAttribute('class','lastfmImage');
body.appendChild(image);
("image size: "+ this['size'] + " image url: " + this['#text']);
}
});
/* var shortbio=document.createElement('div');
shortbio.setAttribute('class','lastfmBio');
shortbio.innerHTML=(data.artist.bio.summary);
body.appendChild(shortbio);
*/
var br=document.createElement('br');
body.appendChild(br);
body.appendChild(br);
var header=document.createElement('hr');
header.setAttribute('class','lastfmBio');
body.appendChild(header);
var longbio=document.createElement('div');
longbio.setAttribute("style","height:800px;overflow-y:auto;");
longbio.setAttribute('class','lastfmBio');
longbio.innerHTML=(data.artist.bio.content);
body.appendChild(longbio);
return this;
};
});
});
});
</script>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<!--[if lte IE 7]>
<script src="js/IE8.js" type="text/javascript"></script><![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="css/ie6.css"/><![endif]-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22336211-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body id="index" class="home" >
<!-- Content : start -->
<div class="Content" id="Home">
<div class="Frame FLC">
<div class="Box1 SearchAnswers">
<label for="askQuestion" class="Heading1a" style="display:inline; padding-right:10px;">Enter an artist name</label><span class="Note" style="color:#666666;">and find the fan favorite songs!</span><br />
<input type="text" name="question" value="" id="query" class="textInput" style="background-image: none; width:805px;" />
<input type="submit" id="button1" name="go" value="Submit" class="submitButton Heading2a" />
<br />
<span class="Note" id="examples" style="color:#666666;"></span>
</div>
<div id="happening_now" class="happeningNow Column1">
<h2 class="Heading1a SectionTitle">top songs <span id="searched_for" class="Note">from the artist you searched for</span></h2>
<table>
<thead>
<tr>
<th>Activity</th>
<th>Posted</th>
</tr>
</thead>
<tbody id="hn_table">
<div id="results">
</div>
</tbody>
</table>
<ol id="song-list">
</ol>
</div>
</div>
<footer id="footer-content" class="body">
<span class="bio">Best Songz brings the fan sentiment to you, allowing you to find the best songz from any artist via the <a href="http://gorankem.com">GoRankem API</a></span>
</footer><!-- /#footer-content -->
</div>
<!-- Content : end -->
</body>
</html>