-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
109 lines (106 loc) · 2.58 KB
/
index.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>BibTeX to Hayagriva</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
overflow: hidden;
}
.flex-container {
display: flex;
flex-direction: column;
height: 100vh;
}
.flex-container div {
min-height: 50%;
max-height: 50%;
max-width: 100%;
min-width: 100%;
}
#hayagrivaOutput {
border-top: 2px solid #ccc;
}
.copy-button {
position: absolute;
top: 51vh;
right: 1vh;
border: none;
padding: .5em;
background-color: #999a;
}
@media (min-width: 768px) {
.flex-container {
flex-direction: row;
}
.flex-container div {
min-height: 100%;
max-height: 100%;
max-width: 50%;
min-width: 50%;
}
#hayagrivaOutput {
border: none;
border-left: 2px solid #ccc;
}
.copy-button {
top: 1em;
right: 1em;
}
}
textarea {
width: 94%;
height: 94%;
resize: none;
border: none;
padding: 3%;
}
.copy-button:hover {
background-color: #bbba;
}
.copy-button:active {
background-color: #ddda;
}
</style>
</head>
<body>
<div class="flex-container">
<div><textarea id="bibtexInput" placeholder="Paste your BibTeX here"></textarea></div>
<div><textarea id="hayagrivaOutput" placeholder="Your Hayagriva output will appear here" readonly></textarea></div>
</div>
<button class="copy-button" onclick="copyToClipboard()">Copy Output</button>
<script type="module" src="hayagriva_wrapper/pkg/hayagriva_wrapper.js"></script>
<script type="module">
import init, { convert_biblatex_to_hayagriva } from './hayagriva_wrapper/pkg/hayagriva_wrapper.js';
async function run() {
await init();
document.getElementById("bibtexInput").addEventListener("input", () => {
const bibtex = document.getElementById("bibtexInput").value;
let hayagriva = "";
if (bibtex != "") {
hayagriva = convert_biblatex_to_hayagriva(bibtex);
}
document.getElementById("hayagrivaOutput").value = hayagriva;
});
}
run();
</script>
<script>
async function copyToClipboard() {
const text = document.getElementById('hayagrivaOutput').value;
try {
await navigator.clipboard.writeText(text);
console.log('Content copied to clipboard');
} catch (err) {
console.error('Failed to copy: ', err);
}
}
</script>
</body>
</html>