-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
70 lines (61 loc) · 2.05 KB
/
index.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
61
62
63
64
65
66
67
68
69
70
(function(factory) {
typeof define === 'function' && define.amd ? define(factory) : factory();
})(function() {
'use strict';
function addPublications(meta, parentElement) {
var parentDiv = d3.select(parentElement);
var list = parentDiv.append('ul').attr('class', 'pubs');
var items = list
.selectAll('li')
.data(meta)
.enter()
.append('li')
.attr('class', 'pub'); //thumb
items.append('img').attr('src', function(d) {
return './img/' + d.thumbnail;
}); // .text(d => (d.description ? d.description : "<no description available>"));
var wraps = items.append('div').attr('class', 'pub-wrap'); //title
wraps
.append('p')
.attr('class', 'title')
.text(function(d) {
return d.title;
}); //description
wraps
.append('p')
.attr('class', 'reference')
.text(function(d) {
return d.reference;
}); //author
wraps
.append('p')
.attr('class', 'author')
.text(function(d) {
return d.authors;
}); //tags
function cap1(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
var taglist = wraps.append('ul').attr('class', 'tags');
taglist
.selectAll('li')
.data(function(d) {
return d.links;
})
.enter()
.append('li')
.append('a')
.attr('href', function(d) {
return d.href.indexOf('http') > -1 ? d.href : './pubs/' + d.href;
})
.attr('class', function(d) {
return d.type;
})
.html(function(d) {
return d.type == 'github' ? d.type : cap1(d.type);
});
}
d3.json('./data/publicationMetadata.json', function(error, publications) {
addPublications(publications, '.pubs');
});
});