-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnkiTools.html
31 lines (30 loc) · 1.07 KB
/
AnkiTools.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="script" href="AnkiTools.js">
<script type="text/javascript" src="AnkiTools.js"></script>
<script>
// Test code to make sure the CSV is working
let card1 = new Card("hi, hello!", '"""test"""');
let card2 = new Card("hjaiihi", "hello wlrd!");
let deck = new Deck("name", [card1, card2]);
let csv = deck.genCSV();
let csvURI = encodeURIComponent(csv);
</script>
</head>
<body>
<!-- Used for testing capabilities, will move to react eventually -->
<a id="a" href="" download="" >
<button>Download</button>
</a>
<script type="text/javascript">
// Convert CSV into data URL
csvURL = "data:text/csv," + csvURI;
// Get a element
let a = document.getElementById("a");
// Set it to the data url
a.href = csvURL;
</script>
</body>
</html>