-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
43 lines (39 loc) · 1.63 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
<html>
<head>
<title>Album cover generator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Random album generator</h1>
<h4>Band name is a random wikipedia article, cover is a random flickr picture, album name is a random amazon product</h4>
<div class="album">
<div class="dimmer"></div>
<h1></h1>
<h3></h3>
</div>
<button>Generate an other one!</button>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="jquery.remote-selector.js"></script>
<script>
function cleanTitle(title)
{
return title
.replace(/[A-Z]{2,}/g, '')
.replace(/[0-9]/g, '')
.replace(/[\W]+/g, ' ').split(' ').slice(0, 3).join(' ')
}
function generateAlbum()
{
$.remote('http://en.wikipedia.org/wiki/Special:Random #firstHeading span, http://www.flickr.com/explore/interesting/7days img.pc_img, http://randomamazonproduct.com .amazon-title')
.then(function ($title, $cover, $quote) {
var $album = $('.album');
$album.find('h1').html(cleanTitle($title.text()));
$album.css({'background-image': 'url("' + $cover.filter(function(x){return x.width >= 240 && x.height >= 240}).attr('src') + '")'});
$album.find('h3').html(cleanTitle($quote.text()));
});
}
generateAlbum();
$('button').on('click', generateAlbum);
</script>
</body>
</html>