DanielMoz commited on
Commit
8ccbfab
·
verified ·
1 Parent(s): 3521a04

1. The theme buttons do not work; fix that. 2. Create cards input must be alongside Preview space; check for responsiveness. 3. Add translation option (portuguese). 4. Make the flashcard preview more colourful, vibrant. 5. Add a feature of your choice. - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +535 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Flashcard Simulator
3
- emoji: 🐨
4
- colorFrom: pink
5
- colorTo: red
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: flashcard-simulator
3
+ emoji: 🐳
4
+ colorFrom: gray
5
+ colorTo: pink
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,535 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="dark">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Flash Card Study Simulator</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ /* Custom themes */
11
+ .blue-theme {
12
+ --tw-bg-opacity: 1;
13
+ --tw-text-opacity: 1;
14
+ --color-primary: 59 130 246;
15
+ --color-secondary: 191 219 254;
16
+ }
17
+
18
+ .green-theme {
19
+ --tw-bg-opacity: 1;
20
+ --tw-text-opacity: 1;
21
+ --color-primary: 34 197 94;
22
+ --color-secondary: 187 247 208;
23
+ }
24
+
25
+ .blue-theme .card {
26
+ background: linear-gradient(to bottom right, var(--color-secondary), white);
27
+ }
28
+
29
+ .green-theme .card {
30
+ background: linear-gradient(to bottom right, var(--color-secondary), white);
31
+ }
32
+
33
+ .card {
34
+ perspective: 1000px;
35
+ transform-style: preserve-3d;
36
+ transition: all 0.5s ease;
37
+ }
38
+ .card-inner {
39
+ transition: transform 0.6s;
40
+ transform-style: preserve-3d;
41
+ }
42
+ .card.flipped .card-inner {
43
+ transform: rotateY(180deg);
44
+ }
45
+ .card-front, .card-back {
46
+ backface-visibility: hidden;
47
+ position: absolute;
48
+ width: 100%;
49
+ height: 100%;
50
+ }
51
+ .card-back {
52
+ transform: rotateY(180deg);
53
+ }
54
+ .fade-in {
55
+ animation: fadeIn 0.3s ease-in;
56
+ }
57
+ @keyframes fadeIn {
58
+ from { opacity: 0; }
59
+ to { opacity: 1; }
60
+ }
61
+ .progress-bar {
62
+ transition: width 0.3s ease;
63
+ }
64
+ </style>
65
+ </head>
66
+ <body class="bg-gray-100 dark:bg-gray-900 min-h-screen transition-colors duration-300">
67
+ <div class="container mx-auto px-4 py-8 max-w-4xl">
68
+ <!-- Header -->
69
+ <header class="flex justify-between items-center mb-8">
70
+ <h1 class="text-3xl font-bold text-gray-800 dark:text-white" id="mainTitle">Flash Card Simulator</h1>
71
+ <div class="flex items-center space-x-2">
72
+ <button id="enLangBtn" class="p-2 rounded-full bg-blue-500 text-white" title="English">
73
+ EN
74
+ </button>
75
+ <button id="ptLangBtn" class="p-2 rounded-full bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-200" title="Português">
76
+ PT
77
+ </button>
78
+ <div class="flex items-center space-x-2">
79
+ <button id="lightThemeBtn" class="p-2 rounded-full bg-gray-200 text-gray-700" title="Light Theme">
80
+ <i class="fas fa-sun"></i>
81
+ </button>
82
+ <button id="darkThemeBtn" class="p-2 rounded-full bg-gray-700 text-gray-200" title="Dark Theme">
83
+ <i class="fas fa-moon"></i>
84
+ </button>
85
+ <button id="blueThemeBtn" class="p-2 rounded-full bg-blue-100 text-blue-700" title="Blue Theme">
86
+ <i class="fas fa-droplet"></i>
87
+ </button>
88
+ <button id="greenThemeBtn" class="p-2 rounded-full bg-green-100 text-green-700" title="Green Theme">
89
+ <i class="fas fa-leaf"></i>
90
+ </button>
91
+ </div>
92
+ </header>
93
+
94
+ <!-- Main Content -->
95
+ <div class="grid grid-cols-1 xl:grid-cols-2 gap-8">
96
+ <!-- Input Section -->
97
+ <div id="inputSection" class="bg-white dark:bg-gray-800 rounded-xl shadow-lg p-6 transition-all duration-300">
98
+ <h2 class="text-xl font-semibold mb-4 text-gray-800 dark:text-white">Create Your Cards</h2>
99
+
100
+ <div class="mb-4">
101
+ <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Deck Title</label>
102
+ <input type="text" id="deckTitle" placeholder="My Study Deck"
103
+ class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
104
+ </div>
105
+
106
+ <div id="cardInputs" class="space-y-4">
107
+ <div class="card-input-group flex items-start space-x-2">
108
+ <div class="flex-1 space-y-2">
109
+ <input type="text" placeholder="Term" class="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white">
110
+ <textarea placeholder="Definition" rows="2" class="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"></textarea>
111
+ <select class="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white">
112
+ <option value="easy">Easy</option>
113
+ <option value="medium">Medium</option>
114
+ <option value="hard">Hard</option>
115
+ </select>
116
+ </div>
117
+ <button class="remove-card-btn mt-2 text-red-500 hover:text-red-700 dark:hover:text-red-400">
118
+ <i class="fas fa-times"></i>
119
+ </button>
120
+ </div>
121
+ </div>
122
+
123
+ <div class="flex justify-between mt-6">
124
+ <button id="addCardBtn" class="px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg transition-colors">
125
+ <i class="fas fa-plus mr-2"></i>Add Card
126
+ </button>
127
+ <button id="startStudyBtn" class="px-4 py-2 bg-green-500 hover:bg-green-600 text-white rounded-lg transition-colors">
128
+ <i class="fas fa-play mr-2"></i>Start Studying
129
+ </button>
130
+ </div>
131
+ </div>
132
+
133
+ <!-- Preview Section -->
134
+ <div id="previewSection" class="bg-white dark:bg-gray-800 rounded-xl shadow-lg p-6 transition-all duration-300">
135
+ <h2 class="text-xl font-semibold mb-4 text-gray-800 dark:text-white">Preview</h2>
136
+ <div class="flex justify-center">
137
+ <div class="card w-full max-w-md h-64 bg-gradient-to-br from-purple-100 via-pink-100 to-yellow-100 dark:from-purple-900 dark:via-pink-900 dark:to-yellow-900 rounded-xl shadow-lg cursor-pointer transform hover:scale-105 transition-transform duration-300" id="previewCard">
138
+ <div class="card-inner h-full">
139
+ <div class="card-front flex flex-col justify-center items-center h-full p-6">
140
+ <p class="text-gray-500 dark:text-gray-300 text-sm">Term</p>
141
+ <h3 class="text-2xl font-bold text-center text-gray-800 dark:text-white mt-2">Sample Term</h3>
142
+ </div>
143
+ <div class="card-back flex flex-col justify-center items-center h-full p-6">
144
+ <p class="text-gray-500 dark:text-gray-300 text-sm">Definition</p>
145
+ <p class="text-lg text-center text-gray-700 dark:text-gray-200 mt-2">Sample definition goes here...</p>
146
+ </div>
147
+ </div>
148
+ </div>
149
+ </div>
150
+ <p class="text-sm text-gray-500 dark:text-gray-400 text-center mt-4">Click the card to flip</p>
151
+ </div>
152
+ </div>
153
+
154
+ <!-- Study Mode Section (Hidden Initially) -->
155
+ <div id="studySection" class="hidden bg-white dark:bg-gray-800 rounded-xl shadow-lg p-6 mt-8 transition-all duration-300">
156
+ <div class="flex justify-between items-center mb-6">
157
+ <h2 id="studyDeckTitle" class="text-xl font-semibold text-gray-800 dark:text-white">Studying: My Deck</h2>
158
+ <button id="exitStudyBtn" class="px-3 py-1 bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-200 rounded-lg hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors">
159
+ Exit Study Mode
160
+ </button>
161
+ </div>
162
+
163
+ <!-- Progress Bar -->
164
+ <div class="mb-6">
165
+ <div class="flex justify-between mb-1">
166
+ <span id="progressText" class="text-sm font-medium text-gray-700 dark:text-gray-300">0/0 cards</span>
167
+ <span id="scoreText" class="text-sm font-medium text-gray-700 dark:text-gray-300">Score: 0%</span>
168
+ </div>
169
+ <div class="w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2.5">
170
+ <div id="progressBar" class="progress-bar bg-blue-500 h-2.5 rounded-full" style="width: 0%"></div>
171
+ </div>
172
+ </div>
173
+
174
+ <!-- Flash Card -->
175
+ <div class="flex justify-center mb-8">
176
+ <div class="card w-full max-w-md h-80 bg-gradient-to-br from-blue-50 to-blue-100 dark:from-gray-700 dark:to-gray-600 blue-theme:from-blue-100 blue-theme:to-white green-theme:from-green-100 green-theme:to-white rounded-xl shadow-lg cursor-pointer" id="studyCard">
177
+ <div class="card-inner h-full">
178
+ <div class="card-front flex flex-col justify-center items-center h-full p-6">
179
+ <p class="text-gray-500 dark:text-gray-300 text-sm">Term</p>
180
+ <h3 id="cardTerm" class="text-3xl font-bold text-center text-gray-800 dark:text-white mt-4">Loading...</h3>
181
+ </div>
182
+ <div class="card-back flex flex-col justify-center items-center h-full p-6">
183
+ <p class="text-gray-500 dark:text-gray-300 text-sm">Definition</p>
184
+ <p id="cardDefinition" class="text-xl text-center text-gray-700 dark:text-gray-200 mt-4">Loading...</p>
185
+ </div>
186
+ </div>
187
+ </div>
188
+ </div>
189
+
190
+ <!-- Controls -->
191
+ <div class="flex flex-col sm:flex-row justify-center space-y-4 sm:space-y-0 sm:space-x-4">
192
+ <button id="knewItBtn" class="px-6 py-3 bg-green-500 hover:bg-green-600 text-white rounded-lg transition-colors">
193
+ <i class="fas fa-check mr-2"></i>Knew It
194
+ </button>
195
+ <button id="flipCardBtn" class="px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg transition-colors">
196
+ <i class="fas fa-sync-alt mr-2"></i>Flip Card
197
+ </button>
198
+ <button id="didntKnowBtn" class="px-6 py-3 bg-red-500 hover:bg-red-600 text-white rounded-lg transition-colors">
199
+ <i class="fas fa-times mr-2"></i>Didn't Know
200
+ </button>
201
+ </div>
202
+ </div>
203
+ </div>
204
+
205
+ <script>
206
+ // Theme Management
207
+ const themes = {
208
+ light: {
209
+ class: '',
210
+ icon: 'fa-sun',
211
+ bg: 'bg-gray-200',
212
+ text: 'text-gray-700'
213
+ },
214
+ dark: {
215
+ class: 'dark',
216
+ icon: 'fa-moon',
217
+ bg: 'bg-gray-700',
218
+ text: 'text-gray-200'
219
+ },
220
+ blue: {
221
+ class: 'blue-theme',
222
+ icon: 'fa-droplet',
223
+ bg: 'bg-blue-100',
224
+ text: 'text-blue-700'
225
+ },
226
+ green: {
227
+ class: 'green-theme',
228
+ icon: 'fa-leaf',
229
+ bg: 'bg-green-100',
230
+ text: 'text-green-700'
231
+ }
232
+ };
233
+
234
+ // Set theme
235
+ function setTheme(themeName) {
236
+ // Remove all theme classes first
237
+ document.documentElement.classList.remove('dark', 'blue-theme', 'green-theme');
238
+
239
+ // Add selected theme class
240
+ if (themeName !== 'light') {
241
+ document.documentElement.classList.add(themes[themeName].class);
242
+ }
243
+
244
+ // Update active button styles
245
+ Object.keys(themes).forEach(theme => {
246
+ const btn = document.getElementById(`${theme}ThemeBtn`);
247
+ if (btn) {
248
+ btn.className = `p-2 rounded-full ${theme === themeName ?
249
+ `${themes[theme].bg} ${themes[theme].text}` :
250
+ 'bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-200'}`;
251
+ }
252
+ });
253
+
254
+ // Save to localStorage
255
+ localStorage.setItem('theme', themeName);
256
+ }
257
+
258
+ // Translation texts
259
+ const translations = {
260
+ en: {
261
+ title: "Flash Card Simulator",
262
+ createCards: "Create Your Cards",
263
+ deckTitle: "Deck Title",
264
+ term: "Term",
265
+ definition: "Definition",
266
+ difficulty: "Difficulty",
267
+ preview: "Preview",
268
+ addCard: "Add Card",
269
+ startStudy: "Start Studying",
270
+ studying: "Studying",
271
+ exitStudy: "Exit Study Mode",
272
+ knewIt: "Knew It",
273
+ flipCard: "Flip Card",
274
+ didntKnow: "Didn't Know"
275
+ },
276
+ pt: {
277
+ title: "Simulador de Cartões",
278
+ createCards: "Crie Seus Cartões",
279
+ deckTitle: "Título do Baralho",
280
+ term: "Termo",
281
+ definition: "Definição",
282
+ difficulty: "Dificuldade",
283
+ preview: "Pré-visualização",
284
+ addCard: "Adicionar Cartão",
285
+ startStudy: "Começar a Estudar",
286
+ studying: "Estudando",
287
+ exitStudy: "Sair do Modo Estudo",
288
+ knewIt: "Sabia",
289
+ flipCard: "Virar Cartão",
290
+ didntKnow: "Não Sabia"
291
+ }
292
+ };
293
+
294
+ // Set language
295
+ function setLanguage(lang) {
296
+ document.getElementById('mainTitle').textContent = translations[lang].title;
297
+ document.querySelector('#inputSection h2').textContent = translations[lang].createCards;
298
+ document.querySelector('#inputSection label').textContent = translations[lang].deckTitle;
299
+ document.querySelector('#previewSection h2').textContent = translations[lang].preview;
300
+ document.getElementById('addCardBtn').innerHTML = `<i class="fas fa-plus mr-2"></i>${translations[lang].addCard}`;
301
+ document.getElementById('startStudyBtn').innerHTML = `<i class="fas fa-play mr-2"></i>${translations[lang].startStudy}`;
302
+ document.getElementById('studyDeckTitle').textContent = `${translations[lang].studying}: My Deck`;
303
+ document.getElementById('exitStudyBtn').textContent = translations[lang].exitStudy;
304
+ document.getElementById('knewItBtn').innerHTML = `<i class="fas fa-check mr-2"></i>${translations[lang].knewIt}`;
305
+ document.getElementById('flipCardBtn').innerHTML = `<i class="fas fa-sync-alt mr-2"></i>${translations[lang].flipCard}`;
306
+ document.getElementById('didntKnowBtn').innerHTML = `<i class="fas fa-times mr-2"></i>${translations[lang].didntKnow}`;
307
+
308
+ // Update all input placeholders
309
+ document.querySelectorAll('#cardInputs input[type="text"]').forEach(input => {
310
+ input.placeholder = translations[lang].term;
311
+ });
312
+ document.querySelectorAll('#cardInputs textarea').forEach(textarea => {
313
+ textarea.placeholder = translations[lang].definition;
314
+ });
315
+ document.querySelectorAll('#cardInputs select').forEach(select => {
316
+ select.innerHTML = `
317
+ <option value="easy">${translations[lang].easy || 'Easy'}</option>
318
+ <option value="medium">${translations[lang].medium || 'Medium'}</option>
319
+ <option value="hard">${translations[lang].hard || 'Hard'}</option>
320
+ `;
321
+ });
322
+
323
+ // Update active button
324
+ document.getElementById('enLangBtn').className = `p-2 rounded-full ${lang === 'en' ? 'bg-blue-500 text-white' : 'bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-200'}`;
325
+ document.getElementById('ptLangBtn').className = `p-2 rounded-full ${lang === 'pt' ? 'bg-blue-500 text-white' : 'bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-200'}`;
326
+
327
+ localStorage.setItem('language', lang);
328
+ }
329
+
330
+ // Initialize theme and language
331
+ const savedTheme = localStorage.getItem('theme') ||
332
+ (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
333
+ setTheme(savedTheme);
334
+
335
+ const savedLanguage = localStorage.getItem('language') || 'en';
336
+ setLanguage(savedLanguage);
337
+
338
+ // Language buttons
339
+ document.getElementById('enLangBtn').addEventListener('click', () => setLanguage('en'));
340
+ document.getElementById('ptLangBtn').addEventListener('click', () => setLanguage('pt'));
341
+
342
+ // Theme buttons
343
+ document.getElementById('lightThemeBtn').addEventListener('click', () => setTheme('light'));
344
+ document.getElementById('darkThemeBtn').addEventListener('click', () => setTheme('dark'));
345
+ document.getElementById('blueThemeBtn').addEventListener('click', () => setTheme('blue'));
346
+ document.getElementById('greenThemeBtn').addEventListener('click', () => setTheme('green'));
347
+
348
+ // Card Management
349
+ let cards = [];
350
+ let currentCardIndex = 0;
351
+ let knownCards = 0;
352
+ let totalCards = 0;
353
+
354
+ // Add new card input
355
+ document.getElementById('addCardBtn').addEventListener('click', () => {
356
+ const cardInputs = document.getElementById('cardInputs');
357
+ const newCard = document.createElement('div');
358
+ newCard.className = 'card-input-group flex items-start space-x-2 fade-in';
359
+ newCard.innerHTML = `
360
+ <div class="flex-1 space-y-2">
361
+ <input type="text" placeholder="Term" class="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white">
362
+ <textarea placeholder="Definition" rows="2" class="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"></textarea>
363
+ </div>
364
+ <button class="remove-card-btn mt-2 text-red-500 hover:text-red-700 dark:hover:text-red-400">
365
+ <i class="fas fa-times"></i>
366
+ </button>
367
+ `;
368
+ cardInputs.appendChild(newCard);
369
+
370
+ // Add event to remove button
371
+ newCard.querySelector('.remove-card-btn').addEventListener('click', () => {
372
+ newCard.classList.add('opacity-0', 'h-0', 'overflow-hidden', 'transition-all', 'duration-300');
373
+ setTimeout(() => newCard.remove(), 300);
374
+ });
375
+
376
+ // Update preview
377
+ updatePreview();
378
+ });
379
+
380
+ // Update preview card
381
+ function updatePreview() {
382
+ const inputs = document.querySelectorAll('.card-input-group');
383
+ if (inputs.length > 0) {
384
+ const lastInput = inputs[inputs.length - 1];
385
+ const term = lastInput.querySelector('input').value || 'Sample Term';
386
+ const definition = lastInput.querySelector('textarea').value || 'Sample definition goes here...';
387
+
388
+ document.querySelector('#previewCard .card-front h3').textContent = term;
389
+ document.querySelector('#previewCard .card-back p:nth-child(2)').textContent = definition;
390
+ }
391
+ }
392
+
393
+ // Add input listeners for live preview
394
+ document.getElementById('cardInputs').addEventListener('input', (e) => {
395
+ if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') {
396
+ updatePreview();
397
+ }
398
+ });
399
+
400
+ // Flip card functionality for preview
401
+ document.getElementById('previewCard').addEventListener('click', function() {
402
+ this.classList.toggle('flipped');
403
+ });
404
+
405
+ // Start study session
406
+ document.getElementById('startStudyBtn').addEventListener('click', () => {
407
+ const deckTitle = document.getElementById('deckTitle').value || 'My Study Deck';
408
+ const cardInputs = document.querySelectorAll('.card-input-group');
409
+
410
+ if (cardInputs.length === 0) {
411
+ alert('Please add at least one flash card before starting.');
412
+ return;
413
+ }
414
+
415
+ // Collect all cards
416
+ cards = [];
417
+ cardInputs.forEach(input => {
418
+ const term = input.querySelector('input').value.trim();
419
+ const definition = input.querySelector('textarea').value.trim();
420
+
421
+ if (term && definition) {
422
+ cards.push({
423
+ term,
424
+ definition,
425
+ known: false
426
+ });
427
+ }
428
+ });
429
+
430
+ if (cards.length === 0) {
431
+ alert('Please fill in both term and definition for at least one card.');
432
+ return;
433
+ }
434
+
435
+ // Shuffle cards
436
+ shuffleArray(cards);
437
+
438
+ // Reset study stats
439
+ currentCardIndex = 0;
440
+ knownCards = 0;
441
+ totalCards = cards.length;
442
+
443
+ // Update UI
444
+ document.getElementById('studyDeckTitle').textContent = `Studying: ${deckTitle}`;
445
+ document.getElementById('inputSection').classList.add('hidden');
446
+ document.getElementById('previewSection').classList.add('hidden');
447
+ document.getElementById('studySection').classList.remove('hidden');
448
+
449
+ // Show first card
450
+ showCurrentCard();
451
+ updateProgress();
452
+ });
453
+
454
+ // Exit study mode
455
+ document.getElementById('exitStudyBtn').addEventListener('click', () => {
456
+ document.getElementById('inputSection').classList.remove('hidden');
457
+ document.getElementById('previewSection').classList.remove('hidden');
458
+ document.getElementById('studySection').classList.add('hidden');
459
+ });
460
+
461
+ // Show current card in study mode
462
+ function showCurrentCard() {
463
+ if (currentCardIndex < cards.length) {
464
+ const card = cards[currentCardIndex];
465
+ document.getElementById('cardTerm').textContent = card.term;
466
+ document.getElementById('cardDefinition').textContent = card.definition;
467
+
468
+ // Ensure card is not flipped when showing new card
469
+ const studyCard = document.getElementById('studyCard');
470
+ studyCard.classList.remove('flipped');
471
+ } else {
472
+ // Study session complete
473
+ const score = Math.round((knownCards / totalCards) * 100);
474
+ document.getElementById('cardTerm').textContent = 'Study Complete!';
475
+ document.getElementById('cardDefinition').textContent = `You knew ${knownCards} of ${totalCards} cards (${score}%)`;
476
+
477
+ // Disable buttons
478
+ document.getElementById('knewItBtn').disabled = true;
479
+ document.getElementById('didntKnowBtn').disabled = true;
480
+ document.getElementById('flipCardBtn').disabled = true;
481
+ }
482
+ }
483
+
484
+ // Update progress bar and text
485
+ function updateProgress() {
486
+ const progress = Math.round(((currentCardIndex) / totalCards) * 100);
487
+ const score = currentCardIndex > 0 ? Math.round((knownCards / currentCardIndex) * 100) : 0;
488
+
489
+ document.getElementById('progressText').textContent = `${currentCardIndex}/${totalCards} cards`;
490
+ document.getElementById('scoreText').textContent = `Score: ${score}%`;
491
+ document.getElementById('progressBar').style.width = `${progress}%`;
492
+ }
493
+
494
+ // Flip card in study mode
495
+ document.getElementById('flipCardBtn').addEventListener('click', () => {
496
+ document.getElementById('studyCard').classList.toggle('flipped');
497
+ });
498
+
499
+ // Click card to flip in study mode
500
+ document.getElementById('studyCard').addEventListener('click', function() {
501
+ this.classList.toggle('flipped');
502
+ });
503
+
504
+ // Knew it button
505
+ document.getElementById('knewItBtn').addEventListener('click', () => {
506
+ if (currentCardIndex < cards.length) {
507
+ cards[currentCardIndex].known = true;
508
+ knownCards++;
509
+ currentCardIndex++;
510
+ showCurrentCard();
511
+ updateProgress();
512
+ }
513
+ });
514
+
515
+ // Didn't know button
516
+ document.getElementById('didntKnowBtn').addEventListener('click', () => {
517
+ if (currentCardIndex < cards.length) {
518
+ cards[currentCardIndex].known = false;
519
+ currentCardIndex++;
520
+ showCurrentCard();
521
+ updateProgress();
522
+ }
523
+ });
524
+
525
+ // Utility function to shuffle array
526
+ function shuffleArray(array) {
527
+ for (let i = array.length - 1; i > 0; i--) {
528
+ const j = Math.floor(Math.random() * (i + 1));
529
+ [array[i], array[j]] = [array[j], array[i]];
530
+ }
531
+ return array;
532
+ }
533
+ </script>
534
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=DanielMoz/flashcard-simulator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
535
+ </html>