This repository has been archived by the owner on May 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
featuredbooks.js
60 lines (43 loc) · 1.75 KB
/
featuredbooks.js
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
/* featuredbooks.js */
/* Daniel Zimmel 2013 */
// Configuration: set your values here.
var mylib = 'rdg01';
var myccl = 'wab=featuredbook';
$(document).ready(function() {
// loading message
$('body').append('<p id="fetching">fetching from '+mylib+'...</p>');
// get Aleph-X
$.ajax({url:'http://www.coll.mpg.de/bib/beta/temp/rss.php?myquery='+myccl+'&mybase='+mylib+'&output=json',
dataType: 'jsonp',
success: function(data) {
$('#fetching').remove();
var itemData = data.channel.item;
// for(var i =0;i < itemData.length-1;i++) // alle Titel ausgeben (max. 100)
for(var i =0;i < itemData.length && i < 5;i++) // nur die aktuellsten 5 Titel ausgeben
{
if (typeof itemData[i].guid == 'string') {
var isbn = itemData[i].guid;} else { var isbn = undefined; }
if (isbn) {
// var title_short = itemData[i].title.slice(0,90) + "...";
$('body').append('<div class="item" id="item'+i+'"><a href="'+itemData[i].link+'"><img src="" class="content" title="'+itemData[i].title+'" /></a></div>');
$('#item'+i).each( function() {
// console.log(i);
$.ajax({url: 'http://books.google.com/books?bibkeys=ISBN:'+isbn+'&jscmd=viewapi',
dataType: 'jsonp',
//context: {i:i}, // set current iterator (async!)
i: i,
success: function(booksInfo) {
for (id in booksInfo) {
isbn = id;
//console.log(booksInfo[id].thumbnail_url);
//console.log(this.i);
$('#item'+this.i).find('img').attr('src', booksInfo[id].thumbnail_url);
}
}
});
});
}
}
}
});
});