This repository has been archived by the owner on Aug 20, 2020. It is now read-only.
forked from rsdoiel/bibtex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbibmerge.js
48 lines (46 loc) · 1.83 KB
/
bibmerge.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
/*
* bibmerge.js binds the form elements to access the bibtex object implemented with GopherJS
*/
(function (window, document) {
'use strict';
var inputTextAreaA = document.getElementById("inputA-bibtex"),
inputTextAreaB = document.getElementById("inputB-bibtex"),
outputTextArea = document.getElementById("output-bibtex"),
operation = document.getElementById("merge-type-bibtex"),
submitButton = document.getElementById("merge-bibtex"),
cmdExample = document.getElementById("cmd-example-bibtex");
submitButton.addEventListener("click", function (evt) {
var merge = bibtex.New(),
cmd = [],
out = "",
opOK = true;
switch (operation.value) {
case "join":
outputTextArea.value = merge.Join(inputTextAreaA.value, inputTextAreaB.value);
opOK = true;
break;
case "diff":
outputTextArea.value = merge.Diff(inputTextAreaA.value, inputTextAreaB.value);
opOK = true;
break;
case "intersect":
outputTextArea.value = merge.Intersect(inputTextAreaA.value, inputTextAreaB.value);
opOK = true;
break;
case "exclusive":
outputTextArea.value = merge.Exclusive(inputTextAreaA.value, inputTextAreaB.value);
opOK = true;
break;
default:
outputTextArea.value = "unknown operation requested";
opOK = false;
}
if (cmdExample && opOK === true) {
cmd.push("bibmerge");
cmd.push("-" + operation.value);
cmd.push("example1.bib");
cmd.push("example2.bib");
cmdExample.value = cmd.join(" ");
}
});
}(window, document));