-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
30 lines (26 loc) · 883 Bytes
/
app.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
function persistentInputOnInput(element) {
localStorage.setItem(element.id, element.value);
}
function persistentInputOnLoad(id) {
const textbox = document.getElementById(id);
const apiKeyValue = localStorage.getItem(id);
if (apiKeyValue && textbox.value === '') {
textbox.value = apiKeyValue;
}
}
function textOnChange() {
document.getElementById('num_flashcards').value = Math.round(document.getElementById('text').value.length / 234);
}
function downloadOnClick(event) {
event.preventDefault();
const content = document.getElementById('flashcards').value;
const blob = new Blob([content], { type: 'text/markdown' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'flashcards.md';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}