-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
54 lines (53 loc) · 1.65 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FDF to CSV</title>
</head>
<body>
<div class="text-center mt-5 align-content-center">
<h1>FDF to CSV</h1>
<ol>
<li>
Select a minimum comment length:
<input
title="Minimum comment length"
type="number"
id="minLength"
value="5"
/>
</li>
<li>
<form action="/action_page.php" enctype="multipart/form-data">
<label for="myfile">Select the FDF file you wish to convert:</label>
<input type="file" id="myfile" name="myfile" />
<br />
</form>
</li>
<li>The CSV file will be downloaded automatically✨</li>
</ol>
</div>
</body>
<script type="text/javascript" src="parseFdf.js"></script>
<script>
var reader = new FileReader();
reader.onload = function (e) {
const filename = e.target.filename;
const minCommentLen = document.getElementById("minLength").value;
const fdf = e.target.result;
const csv = fdfToCommentResponse(fdf, minCommentLen);
const blob = new Blob([csv], { type: "text/csv" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = filename.replace(".fdf", ".csv");
a.click();
};
document.getElementById("myfile").addEventListener("change", function () {
const file = this.files[0];
reader.filename = file.name;
reader.readAsText(file);
});
</script>
</html>