OzoneAsai commited on
Commit
4476161
1 Parent(s): 1fc1917

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +19 -3
templates/index.html CHANGED
@@ -9,16 +9,32 @@
9
  <body>
10
  <div class="flashcard" id="flashcard">
11
  <div class="content">
12
- <h2>Set: {{ set_name }}</h2>
13
- <p><strong>English:</strong> {{ english }}</p>
14
- <p><strong>Japanese:</strong> {{ japanese }}</p>
15
  </div>
16
  <div class="navigation">
17
  <button id="prevBtn">Previous</button>
 
18
  <button id="nextBtn">Next</button>
19
  </div>
20
  </div>
21
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  document.getElementById('prevBtn').addEventListener('click', function() {
23
  navigate('{{ url_for("prev_card", set=set_name, index=index) }}');
24
  });
 
9
  <body>
10
  <div class="flashcard" id="flashcard">
11
  <div class="content">
12
+ <h2>Set: {{ set_name }} ({{ index + 1 }}/{{ total }})</h2>
13
+ <p id="card-text"><strong>English:</strong> {{ english }}</p>
 
14
  </div>
15
  <div class="navigation">
16
  <button id="prevBtn">Previous</button>
17
+ <button id="flipBtn">Flip</button>
18
  <button id="nextBtn">Next</button>
19
  </div>
20
  </div>
21
  <script>
22
+ const flipBtn = document.getElementById('flipBtn');
23
+ let showingEnglish = true;
24
+ const englishText = "<strong>English:</strong> {{ english }}";
25
+ const japaneseText = "<strong>Japanese:</strong> {{ japanese }}";
26
+
27
+ flipBtn.addEventListener('click', function() {
28
+ const cardText = document.getElementById('card-text');
29
+ if (showingEnglish) {
30
+ cardText.innerHTML = japaneseText;
31
+ showingEnglish = false;
32
+ } else {
33
+ cardText.innerHTML = englishText;
34
+ showingEnglish = true;
35
+ }
36
+ });
37
+
38
  document.getElementById('prevBtn').addEventListener('click', function() {
39
  navigate('{{ url_for("prev_card", set=set_name, index=index) }}');
40
  });