-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanagedata.js
63 lines (51 loc) · 1.29 KB
/
managedata.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
var bibObject = {};
var btparser = new BibtexParser();
function getBibObject() {
return bibObject;
}
function setBibObject(data) {
this.bibObject = data;
}
function editCitation(citekey, citation) {
bibObject[citekey] = citation;
}
function loadBibFile (bibFile) {
// Read File
$.get(bibFile, function( bib_data ) {
addBibTex(bib_data);
});
}
function addBibTex (bib_data) {
btparser = new BibtexParser();
btparser.setInput(bib_data);
btparser.bibtex();
// iterate over bibTeX entries
var entries = btparser.getEntries();
// Merge with previous bibliography object
bibObject = $.extend({}, bibObject, entries);
setBibObject(bibObject);
// Reset the graph
bibTex2nodes(bibObject);
}
function makeBibTex () {
// Write each entry
var data = [];
for (var citation in bibObject) {
var citestr = "@inproceedings{" + citation;
for (var key in bibObject[citation]) {
value = bibObject[citation][key];
if(value.constructor == Array)
value = '[' + value.join(",") + ']';
else
value = '{' + value + '}';
citestr += ",\n " + key + "=" + value;
}
citestr += "\n}";
data[data.length] = citestr;
}
data = data.join("\n");
console.log(data);
var url = 'data:text/json;charset=utf8,' + encodeURIComponent(data);
window.open(url, '_blank');
window.focus();
}