-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
38 lines (33 loc) · 964 Bytes
/
app.js
File metadata and controls
38 lines (33 loc) · 964 Bytes
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
let words = [];
let currentIndex = 0;
let flipped = false;
fetch('words.csv')
.then(response => response.text())
.then(data => {
const lines = data.trim().split('\n').slice(1); // Skip header
words = lines.map(line => {
const [english, tewa] = line.split(',');
return { english, tewa };
});
showCard();
});
function showCard() {
const card = words[currentIndex];
document.getElementById('front').textContent = card.english;
document.getElementById('back').textContent = card.tewa;
document.getElementById('flashcard').classList.remove('flipped');
flipped = false;
}
function flipCard() {
flipped = !flipped;
const flashcard = document.getElementById('flashcard');
flashcard.classList.toggle('flipped', flipped);
}
function nextCard() {
currentIndex = (currentIndex + 1) % words.length;
showCard();
}
function prevCard() {
currentIndex = (currentIndex - 1 + words.length) % words.length;
showCard();
}