/
example.html
63 lines (55 loc) · 2 KB
/
example.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
<meta charset="utf-8">
<script src='swagger-js/browser/swagger-client.js' type='text/javascript'></script>
<script src='citeproc-js/xmle4x.js' type='text/javascript'></script>
<script src='citeproc-js/xmldom.js' type='text/javascript'></script>
<script src='citeproc-js/citeproc.js' type='text/javascript'></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src='lib/orcid.js' type='text/javascript'></script>
<script src='lib/styles.js' type='text/javascript'></script>
<script type="text/javascript">
var orcidID = "0000-0003-0902-4386";
//initialise the library once all the scripts have finished loading
$( document ).ready(function() {
$("#bib").append("Loading "+orcidID);
orcid.init(resolve);
});
//this is called when the library has finished initialising
//it fetches the style XML (an optional step)
//then resolves all the citations for the given ORCID record asynchronously
function resolve(){
CSLStyles.fetchStyleXML("apa", function(styleXML){
orcid.resolveCitations(orcidID, updatePageCallback, true, styleXML);
});
}
//this is called for each citation - it's an array containing one text citation
//if it failed, the the fails parameter contains the work that failed (as a SimpleWork)
function updatePageCallback(citations, fails){
for (c in citations){
$("#bib").append(citations[c] +"<br/>");
}
for (f in fails){
$("#bibfails").append(fails[f].title + " (" + fails[f].citeprocURL+")<br/>");
}
}
//note - citations can be fetched as a batch, and use the default style.
//in this case, the callback recieves an array containing ALL citations.
//the following demonstrates this
/*
$( document ).ready(function() {
$("#bib").append("Loading "+orcidID);
orcid.init(function(){
orcid.resolveCitations(orcidID, function(citations){
for (c in citations){
$("#bib").append(citations[c] +"<br/>");
}
});
});
});
*/
</script>
<body>
<h3>My works:</h3>
<div id="bib"></div>
<h3>Failed to resolve:</h3>
<div id="bibfails"></div>
</body>