-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
57 lines (49 loc) · 1.51 KB
/
Copy pathscript.js
File metadata and controls
57 lines (49 loc) · 1.51 KB
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
let flashcards = [];
let currentCard = null;
function showTab(tabId) {
document.querySelectorAll('.tab').forEach(tab => tab.classList.remove('active'));
document.getElementById(tabId).classList.add('active');
}
function generateFlashcards() {
const notes = document.getElementById('notesInput').value;
if (!notes.trim()) return alert("Enter some notes!");
// Simple simulation: split sentences
notes.split('.').forEach((sentence, i) => {
if (sentence.trim()) {
flashcards.push({ q: "What about: " + sentence.trim() + "?", a: sentence.trim() });
}
});
alert("Flashcards generated!");
}
function addManualCard() {
const q = document.getElementById('qInput').value;
const a = document.getElementById('aInput').value;
if (q && a) {
flashcards.push({ q, a });
alert("Card added!");
}
}
function revealAnswer() {
if (!currentCard) {
currentCard = flashcards.shift();
}
if (currentCard) {
document.getElementById('flashcard').innerText = `${currentCard.q}\n\nAnswer: ${currentCard.a}`;
} else {
document.getElementById('flashcard').innerText = "No more cards!";
}
}
function grade(difficulty) {
alert("You graded this card as: " + difficulty);
currentCard = null;
revealAnswer();
}
function createDeck() {
const deckName = document.getElementById('deckName').value;
if (deckName) {
const li = document.createElement('li');
li.innerText = deckName;
document.getElementById('deckList').appendChild(li);
document.getElementById('deckName').value = "";
}
}