Spaces:
Sleeping
Sleeping
File size: 2,669 Bytes
737784d 4476161 737784d 3038601 737784d 4476161 737784d 67db981 737784d 67db981 737784d 67db981 737784d 2a49bbd 737784d 2a49bbd 737784d |
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flashcards</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<div class="flashcard" id="flashcard">
<div class="content">
<h2>Set: {{ set_name }} ({{ index + 1 }}/{{ total }})</h2>
<p id="card-text"><strong>English:</strong> {{ english }}</p>
</div>
<div class="navigation">
<button id="prevBtn">Previous</button>
<button id="flipBtn">Flip</button>
<button id="nextBtn">Next</button>
</div>
</div>
<script>
const flipBtn = document.getElementById('flipBtn');
let showingEnglish = true;
const englishText = "<strong>English:</strong> {{ english }}";
const japaneseText = "<strong>Japanese:</strong> {{ japanese }}";
flipBtn.addEventListener('click', function() {
const cardText = document.getElementById('card-text');
if (showingEnglish) {
cardText.innerHTML = japaneseText;
showingEnglish = false;
} else {
cardText.innerHTML = englishText;
showingEnglish = true;
}
});
document.getElementById('prevBtn').addEventListener('click', function() {
let newIndex = {{ index }} - 1;
if (newIndex < 0) {
newIndex = {{ total }} - 1;
}
navigate('{{ url_for("index") }}?set={{ set_name }}&index=' + newIndex);
});
document.getElementById('nextBtn').addEventListener('click', function() {
let newIndex = {{ index }} + 1;
if (newIndex >= {{ total }}) {
newIndex = 0;
}
navigate('{{ url_for("index") }}?set={{ set_name }}&index=' + newIndex);
});
function navigate(url) {
const flashcard = document.getElementById('flashcard');
animateFadeOut(flashcard, function() {
window.location.href = url;
});
}
function animateFadeOut(element, callback) {
let opacity = 1;
function fade() {
opacity -= 0.1;
if (opacity <= 0) {
element.style.opacity = 0;
callback();
} else {
element.style.opacity = opacity;
requestAnimationFrame(fade);
}
}
fade();
}
</script>
</body>
</html>
|