-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1139 lines (1003 loc) · 46.1 KB
/
index.html
File metadata and controls
1139 lines (1003 loc) · 46.1 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interview Flashcards</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;
box-sizing: border-box;
flex-direction: column;
}
.card-container {
width: 100%;
max-width: 600px;
background-color: #fff;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
padding: 20px;
text-align: center;
}
h1 {
color: #333;
font-size: 1.5rem;
margin-bottom: 20px;
}
#flashcard {
margin-bottom: 20px;
}
#question-box, #answer-box {
background-color: #e9e9f3;
border: 2px solid #ccc;
border-radius: 8px;
padding: 20px;
min-height: 150px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: left;
line-height: 1.6;
margin-bottom: 10px;
white-space: pre-wrap;
transition: all 0.3s ease;
}
#question-box {
background-color: #f0f0f8;
border-color: #bbb;
text-align: center;
}
#question-text {
color: #007bff;
font-weight: bold;
font-size: 1.2em;
text-align: center;
}
#answer-text {
color: #555;
}
#answer-box {
display: none;
}
.controls {
display: flex;
justify-content: space-around;
gap: 10px;
margin-bottom: 15px;
}
.icon-controls {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 10px;
}
button {
padding: 12px 24px;
font-size: 1em;
font-weight: bold;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.icon-btn {
width: 50px;
height: 50px;
padding: 0;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.5em;
}
#speak-btn {
background-color: #007bff;
}
#speak-btn.speaking {
background-color: #6c757d;
}
#autoplay-toggle-btn.active {
background-color: #28a745;
}
button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
button:hover {
background-color: #0056b3;
}
button:disabled:hover {
background-color: #ccc;
}
button:active {
background-color: #004494;
}
/* Voice Toggle Styling */
.voice-toggle-container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
gap: 10px;
}
.voice-toggle-buttons {
display: flex;
gap: 10px;
}
.voice-toggle-btn {
font-size: 0.9em;
padding: 10px 20px;
border-radius: 20px;
background-color: #ccc;
color: #333;
border: none;
cursor: pointer;
transition: background-color 0.3s ease;
}
.voice-toggle-btn.active {
background-color: #007bff;
color: #fff;
}
/* Modal styling */
.modal {
display: none;
position: fixed;
z-index: 10;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.4);
justify-content: center;
align-items: center;
}
.modal-content {
background-color: #fefefe;
padding: 20px;
border-radius: 10px;
width: 80%;
max-width: 500px;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
text-align: left;
}
.close-btn {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close-btn:hover,
.close-btn:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
.modal-content textarea {
width: 100%;
min-height: 100px;
margin-bottom: 10px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
resize: vertical;
}
.modal-content .modal-buttons {
display: flex;
justify-content: flex-end;
gap: 10px;
}
/* User Settings Section */
#settings-toggle-btn, #show-all-questions-btn {
position: fixed;
top: 20px;
z-index: 20; /* Higher z-index to be on top */
padding: 10px;
font-size: 1.2em;
width: 45px;
height: 45px;
border-radius: 50%;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
display: flex;
justify-content: center;
align-items: center;
}
#settings-toggle-btn {
left: 20px;
background-color: #007bff;
color: #fff;
}
#show-all-questions-btn {
right: 20px;
background-color: #28a745;
color: #fff;
}
#user-settings-container {
position: fixed;
top: 60px;
left: -250px; /* Hidden by default */
width: 230px;
background-color: #fff;
padding: 15px;
border-radius: 0 10px 10px 0;
box-shadow: 2px 0 5px rgba(0,0,0,0.1);
transition: left 0.3s ease-in-out;
z-index: 10;
display: flex;
flex-direction: column;
gap: 15px;
}
#user-settings-container.visible {
left: 0;
}
#user-settings-container h3 {
margin: 0 0 10px;
color: #555;
font-size: 1em;
text-align: center;
}
.user-settings-buttons {
display: flex;
flex-direction: column;
gap: 10px;
}
.user-settings-instructions {
font-size: 0.9em;
text-align: left;
padding: 10px;
border: 1px solid #eee;
border-radius: 8px;
background-color: #f8f8f8;
}
.user-settings-instructions p {
margin: 0 0 5px;
}
.user-settings-buttons button {
width: 100%;
padding: 10px;
font-size: 0.9em;
}
/* Styles for the new questions list modal */
#questions-list-modal .modal-content {
max-width: 700px;
max-height: 80vh;
overflow-y: auto;
}
.questions-list-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.questions-list-header h2 {
margin: 0;
}
.question-item {
border-bottom: 1px solid #eee;
padding-bottom: 15px;
margin-bottom: 15px;
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 10px;
}
.question-item-controls {
display: flex;
gap: 10px;
flex-wrap: wrap;
justify-content: flex-end;
}
.question-item-text {
flex-grow: 1;
display: flex;
gap: 15px;
align-items: flex-start;
}
.question-item-text input[type="checkbox"] {
margin-top: 5px;
min-width: 18px;
min-height: 18px;
}
.question-content {
flex-grow: 1;
}
.question-item:last-child {
border-bottom: none;
margin-bottom: 0;
}
.question-item h4 {
font-size: 1.1em;
color: #007bff;
margin-top: 0;
margin-bottom: 5px;
}
.question-item p {
font-size: 0.9em;
color: #555;
margin: 0;
white-space: pre-wrap;
}
.delete-selected-btn, .edit-btn {
background-color: #dc3545;
border: none;
color: white;
padding: 8px 12px;
font-size: 0.9em;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
white-space: nowrap;
}
.edit-btn {
background-color: #6c757d;
}
.delete-selected-btn:hover {
background-color: #c82333;
}
.edit-btn:hover {
background-color: #5a6268;
}
#edit-question-modal {
z-index: 20; /* New z-index to ensure it is on top */
}
.disclaimer {
margin-top: 20px;
font-size: 0.8em;
color: #888;
text-align: center;
}
</style>
</head>
<body>
<button id="settings-toggle-btn">
<i class="fas fa-cogs"></i>
</button>
<button id="show-all-questions-btn">
<i class="fas fa-list"></i>
</button>
<div id="user-settings-container">
<div class="user-settings-instructions">
<p><strong>Instructions:</strong></p>
<p><strong>Flashcards:</strong> Use 'Next' and 'Previous' to navigate. Click the question to show the answer.</p>
<p><strong>Autoplay:</strong> The sync icon auto-reads questions for you.</p>
<p><strong>Show All:</strong> See all questions, and edit or delete them.</p>
<p><strong>Add/Import:</strong> Create your own questions or import from a CSV file (e.g., from Excel or Google Sheets).</p>
</div>
<div class="voice-toggle-container">
<h3>Interviewer Voice:</h3>
<div class="voice-toggle-buttons">
<button class="voice-toggle-btn" id="male-voice-btn">Male</button>
<button class="voice-toggle-btn" id="female-voice-btn">Female</button>
</div>
</div>
<div class="user-settings-buttons">
<button id="add-question-btn">Add Question</button>
<button id="import-csv-btn">Import CSV</button>
<button id="restore-default-btn" disabled>Restore Default</button>
</div>
</div>
<div class="card-container">
<h1>Interview Flashcard Generator</h1>
<div id="flashcard">
<div id="question-box">
<p id="question-text"></p>
<div class="icon-controls">
<button id="speak-btn" class="icon-btn">
<i class="fas fa-play"></i>
</button>
<button id="autoplay-toggle-btn" class="icon-btn">
<i class="fas fa-sync-alt"></i>
</button>
</div>
</div>
<div id="answer-box">
<p id="answer-text"></p>
</div>
</div>
<div class="controls">
<button id="previous-card-btn" disabled>Previous Card</button>
<button id="show-answer-btn">Show Answer</button>
<button id="next-card-btn">Next Card</button>
</div>
</div>
<div id="add-question-modal" class="modal">
<div class="modal-content">
<span class="close-btn">×</span>
<h2>Add a New Question</h2>
<textarea id="new-question-input" placeholder="Type your question here..."></textarea>
<h2>Add the Answer</h2>
<textarea id="new-answer-input" placeholder="Type your answer here..."></textarea>
<div class="modal-buttons">
<button id="save-question-btn">Save</button>
<button id="cancel-add-btn">Cancel</button>
</div>
</div>
</div>
<div id="edit-question-modal" class="modal">
<div class="modal-content">
<span class="close-btn">×</span>
<h2>Edit Question</h2>
<textarea id="edit-question-input" placeholder="Edit your question here..."></textarea>
<h2>Edit the Answer</h2>
<textarea id="edit-answer-input" placeholder="Edit your answer here..."></textarea>
<div class="modal-buttons">
<button id="save-edit-btn">Save</button>
<button id="cancel-edit-btn">Cancel</button>
</div>
</div>
</div>
<div id="questions-list-modal" class="modal">
<div class="modal-content">
<div class="questions-list-header">
<h2>All Questions (<span id="question-count">0</span>)</h2>
<button id="delete-selected-btn" class="delete-selected-btn" disabled>Delete Selected</button>
</div>
<div id="questions-list-container">
</div>
</div>
</div>
<input type="file" id="csv-file-input" accept=".csv" style="display: none;">
<p class="disclaimer">© 2025 DJZYdevs. All Rights Reserved.</p>
<script>
// Store the default set of questions in a separate constant
const defaultQuestions = [
{
question: "Tell me about yourself.",
answer: `My name is Jaziel Chan, and I am an experienced administrative professional specialising in healthcare administration. I hold a Postgraduate Certificate in Health Administration from Monash University and am currently pursuing a Master of Business Administration at the University of Melbourne Business School.
In my current role as an Administrative Officer at The Healthcare Centre, I manage daily office operations, oversee patient flow and correspondence, and handle billing and invoicing. I also have prior experience as a Medical Receptionist at Saint Luke's Medical Centre.
I am highly organised, proficient with relevant software, and possess excellent communication skills. As a dedicated team player, I am passionate about operational excellence and providing high-quality patient care.`
},
{
question: "What I Know About Alfred Health",
answer: `Alfred Health is a leading provider in Melbourne’s inner southeast, operating four facilities focused on enhancing community well-being through teamwork, compassion, and innovation. The Alfred Cancer department specializes in comprehensive cancer care, emphasizing clinical trials and patient-centered quality care.`
},
{
question: "How does your degree in Tourism Management relate to healthcare administration?",
answer: `My Bachelor of Science in Tourism Management may seem unrelated, but it has equipped me with valuable transferable skills such as customer service, communication, and attention to detail. My experiences are well-suited for the operational aspects of healthcare administration, and they are further enhanced by my Postgraduate Certificate in Health Administration.`
},
{
question: "Why this role?",
answer: `I am drawn to this role due to its alignment with my background and goals. I’m eager to contribute my administrative skills to support the Oncology division at Alfred Health and ensure smooth clinic operations.`
},
{
question: "Why are you looking for a new job?",
answer: `I seek opportunities that align with my career goals and professional growth. This position at Alfred Health interests me due to its patient-centered approach and focus on research and innovation, which aligns with my healthcare administration skills.`
},
{
question: "How do you handle stress?",
answer: `I manage stress by staying organized and maintaining a positive mindset. Using a detailed to-do list and digital planning tools helps me keep track of deadlines, which reduces anxiety. When faced with challenges, I practice deep breathing to clear my mind and regain focus. I also value open communication and collaboration with my team, creating a supportive environment where everyone can share ideas, further reducing stress for all.`
},
{
question: "What's your biggest weakness?",
answer: `I tend to take on too much responsibility to ensure high-quality results. I've addressed this by prioritizing tasks, developing planning strategies, and trusting my colleagues, allowing for effective delegation and focus on key priorities.`
},
{
question: "Tell me about a time you failed.",
answer: `While I strive for excellence, there have been challenges. For instance, when a new process was introduced at work, it led to confusion and delays in patient appointments. Instead of viewing this as a failure, I took the initiative to mentor my colleagues on the new process. This improved our team’s performance and maintained our service quality, highlighting the importance of clear communication and support.`
},
{
question: "How do you handle a high-pressure, fast-paced work environment? Can you provide an example of a time you had to prioritize tasks to meet a deadline?",
answer: `I stay organized and prioritize effectively in high-pressure situations. As an Administrative Officer, there was a day with a high patient volume and an unexpected audit. I quickly assessed the tasks, prioritized patient care, and delegated less urgent tasks. This allowed us to complete the audit on time while maintaining high patient care standards, showcasing my ability to manage time and work under pressure.`
},
{
question: "How would you handle a situation where a patient is upset or angry?",
answer: `I remain calm and professional when patients are upset. Drawing on my customer service experience, I actively listen to their concerns, show empathy, and work towards resolving their issues using available resources. My goal is always to ensure a positive experience for the patient.`
},
{
question: "Describe a time you had to learn new software or a new process.",
answer: `In my role as an Administrative Officer at The Healthcare Centre, I have adapted best practices to enhance team performance. While knowledge of Cerner is desirable, I am a quick learner and confident in learning new software. My experience with Pracsoft and Medical Director showcases my strong computer skills, and I would approach learning Cerner with enthusiasm, fully engaging in any training provided.`
},
{
question: "Can you describe your experience with patient management and administrative tasks in a healthcare setting?",
answer: `I have significant experience in patient management and administration from roles at The Healthcare Centre and Saint Luke's Medical Centre. My duties included scheduling, managing patient flow, and handling billing. I’m proficient in relevant software and have a strong focus on organization and detail, ensuring efficient completion of all administrative tasks in compliance with privacy legislation.`
},
{
question: "The job description emphasizes teamwork and a positive team culture. Can you give an example of how you've contributed to a positive team environment?",
answer: `In my role as an Administrative Officer, I've fostered a positive team environment by mentoring colleagues on new procedures and best practices. This not not only improved individual performance but also enhanced teamwork and efficiency. I believe open communication and mutual support are vital for a positive team culture, aligning with Alfred Health's value of teamwork.
My experience as an ICU Clinical Assistant at The Royal Melbourne Hospital also involved collaborating to deliver high-level patient care, reflecting my commitment to a supportive team approach.`
},
{
question: "How do you ensure a high level of customer service for patients and their families, as well as for medical staff and general practitioners?",
answer: `Providing excellent customer service is central to my roles as an Administrative Officer and Medical Receptionist. I manage front desk inquiries professionally and responsively, using my background in hospitality to combine kindness with efficiency, ensuring that everyone feels supported and respected.`
},
{
question: "How have you contributed to quality improvement in a previous role?",
answer: `In my current role, I've implemented best practices to enhance our workflow and team efficiency. I continuously seek opportunities to streamline tasks, believing that operational excellence directly improves the quality of care we provide.`
},
{
question: "How do you stay organised and manage your time?",
answer: `I possess strong organisational and time management skills. I prioritise tasks and plan my workflow to meet deadlines, enabling me to efficiently manage daily operations.`
},
{
question: "What are your long-term career goals?",
answer: `I aim to secure a position where I can showcase my skills and dedication to excellence. I'm committed to ongoing professional development, currently pursuing further education to enhance my capabilities.`
},
{
question: "What is your 5-year plan?",
answer: `In five years, I plan to advance my career in an organisation that values patient care and operational excellence. With my MBA from the University of Melbourne Business School, I want to take on greater responsibilities and if given the chance with you help I’ll be able to grow as a leader in healthcare, aligning with Alfred Health's mission.`
},
{
question: "Why I Want to Work Here",
answer: `I am eager to join Alfred Health to apply my skills and dedication to operational excellence in supporting the Haematology Oncology & Radiation Oncology service. My experience as an Administrative Officer and Medical Receptionist makes me a great fit for the position's administrative and clerical tasks.
I am passionate about patient-centered care and thrive in team environments. In my previous role as an ICU Clinical Assistant, I collaborated with a team to provide high-level patient care, aligning with Alfred Health's belief that "we are strongest when we work as a team." The organization’s commitment to compassion and continuous improvement resonates with my professional values, and I am excited about this opportunity to contribute to its mission.`
},
{
question: "Why Should We Hire You?",
answer: `I believe my skills and experience closely match this role's requirements. I have substantial knowledge of healthcare administration and a successful background as an Administrative Officer and Medical Receptionist, handling tasks like scheduling, managing patient flow, and billing.
With strong organisational, customer service, and communication skills, I’m a dedicated team player who has mentored staff to enhance performance. I am eager to learn, willing to put in the effort, and committed to contributing to the success of Alfred Health.`
},
];
let interviewQuestions = [...defaultQuestions];
const questionText = document.getElementById('question-text');
const answerText = document.getElementById('answer-text');
const previousCardBtn = document.getElementById('previous-card-btn');
const showAnswerBtn = document.getElementById('show-answer-btn');
const nextCardBtn = document.getElementById('next-card-btn');
const speakBtn = document.getElementById('speak-btn');
const autoplayToggleBtn = document.getElementById('autoplay-toggle-btn');
const answerBox = document.getElementById('answer-box');
const maleVoiceBtn = document.getElementById('male-voice-btn');
const femaleVoiceBtn = document.getElementById('female-voice-btn');
const addQuestionBtn = document.getElementById('add-question-btn');
const importCsvBtn = document.getElementById('import-csv-btn');
const restoreDefaultBtn = document.getElementById('restore-default-btn');
const addQuestionModal = document.getElementById('add-question-modal');
const closeAddModalBtn = document.querySelector('#add-question-modal .close-btn');
const saveQuestionBtn = document.getElementById('save-question-btn');
const cancelAddBtn = document.getElementById('cancel-add-btn');
const newQuestionInput = document.getElementById('new-question-input');
const newAnswerInput = document.getElementById('new-answer-input');
const editQuestionModal = document.getElementById('edit-question-modal');
const closeEditModalBtn = document.querySelector('#edit-question-modal .close-btn');
const saveEditBtn = document.getElementById('save-edit-btn');
const cancelEditBtn = document.getElementById('cancel-edit-btn');
const editQuestionInput = document.getElementById('edit-question-input');
const editAnswerInput = document.getElementById('edit-answer-input');
const settingsToggleBtn = document.getElementById('settings-toggle-btn');
const userSettingsContainer = document.getElementById('user-settings-container');
const showAllQuestionsBtn = document.getElementById('show-all-questions-btn');
const questionsListModal = document.getElementById('questions-list-modal');
const questionsListContainer = document.getElementById('questions-list-container');
const questionCountSpan = document.getElementById('question-count');
const deleteSelectedBtn = document.getElementById('delete-selected-btn');
const csvFileInput = document.getElementById('csv-file-input');
let usedQuestions = new Set();
let autoplayEnabled = false;
let selectedVoice = null;
let maleVoice = null;
let femaleVoice = null;
let history = [];
let historyIndex = -1;
let isSpeaking = false;
let speakingTimeout = null;
let selectedQuestions = new Set();
let currentEditIndex = -1;
const QUESTION_LIMIT = 30;
const MINIMUM_QUESTIONS = 5;
function findVoice(voiceNames, lang) {
const voices = speechSynthesis.getVoices();
for (let name of voiceNames) {
const voice = voices.find(v => v.name === name);
if (voice) return voice;
}
const fallbackVoice = voices.find(v => v.lang.includes(lang));
if (fallbackVoice) return fallbackVoice;
return voices[0];
}
function initializeVoices() {
const maleVoiceNames = [
'Microsoft James Mobile - English (Australia)',
'Google Australian English Male',
'Microsoft James Online (Natural) - English (Australia)',
'Google UK English Male',
'Microsoft Ryan Online (Natural) - English (United Kingdom)',
'Microsoft Christopher Online (Natural) - English (United States)',
'Google US English Male'
];
const femaleVoiceNames = [
'Microsoft Olivia - English (Australia)',
'Google Australian English Female',
'Microsoft Kate Online (Natural) - English (Australia)',
'Microsoft Sonia Online (Natural) - English (United Kingdom)',
'Google UK English Female',
'Microsoft Jenny Online (Natural) - English (United States)',
'Google US English Female'
];
maleVoice = findVoice(maleVoiceNames, 'en-AU');
femaleVoice = findVoice(femaleVoiceNames, 'en-AU');
selectedVoice = femaleVoice;
maleVoiceBtn.classList.remove('active');
femaleVoiceBtn.classList.add('active');
}
function resetSpeakButton() {
isSpeaking = false;
speakBtn.classList.remove('speaking');
speakBtn.innerHTML = '<i class="fas fa-play"></i>';
}
function updateButtonStates() {
if (historyIndex <= 0) {
previousCardBtn.disabled = true;
} else {
previousCardBtn.disabled = false;
}
const questionsChanged = JSON.stringify(interviewQuestions) !== JSON.stringify(defaultQuestions);
restoreDefaultBtn.disabled = !questionsChanged;
if (interviewQuestions.length >= QUESTION_LIMIT) {
addQuestionBtn.disabled = true;
addQuestionBtn.title = "Maximum questions reached (30)";
} else {
addQuestionBtn.disabled = false;
addQuestionBtn.title = "";
}
deleteSelectedBtn.disabled = selectedQuestions.size === 0;
}
function getRandomQuestionIndex() {
if (usedQuestions.size === interviewQuestions.length) {
usedQuestions.clear();
}
let randomIndex;
do {
randomIndex = Math.floor(Math.random() * interviewQuestions.length);
} while (usedQuestions.has(randomIndex));
usedQuestions.add(randomIndex);
return randomIndex;
}
function speakQuestion(text) {
stopSpeaking();
speakingTimeout = setTimeout(() => {
const utterance = new SpeechSynthesisUtterance(text);
utterance.rate = 1.0;
utterance.pitch = 1.0;
if (selectedVoice) {
utterance.voice = selectedVoice;
}
utterance.onend = () => {
resetSpeakButton();
};
utterance.onerror = () => {
resetSpeakButton();
}
isSpeaking = true;
speakBtn.classList.add('speaking');
speakBtn.innerHTML = '<i class="fas fa-stop"></i>';
window.speechSynthesis.speak(utterance);
}, 100);
}
function stopSpeaking() {
if (speakingTimeout) {
clearTimeout(speakingTimeout);
}
if ('speechSynthesis' in window) {
window.speechSynthesis.cancel();
}
resetSpeakButton();
}
function showCard(index) {
stopSpeaking();
const currentCard = interviewQuestions[index];
questionText.innerText = currentCard.question;
answerText.innerText = currentCard.answer;
if (answerBox.style.display !== 'flex') {
answerBox.style.display = 'none';
showAnswerBtn.innerText = "Show Answer";
} else {
showAnswerBtn.innerText = "Hide Answer";
}
if (autoplayEnabled) {
speakQuestion(currentCard.question);
}
}
function generateQuestionsList() {
questionsListContainer.innerHTML = '';
questionCountSpan.innerText = interviewQuestions.length;
selectedQuestions.clear();
updateButtonStates();
interviewQuestions.forEach((item, index) => {
const questionItem = document.createElement('div');
questionItem.classList.add('question-item');
const questionTextContainer = document.createElement('div');
questionTextContainer.classList.add('question-item-text');
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.dataset.index = index;
checkbox.addEventListener('change', (e) => {
const idx = parseInt(e.target.dataset.index);
if (e.target.checked) {
selectedQuestions.add(idx);
} else {
selectedQuestions.delete(idx);
}
updateButtonStates();
});
const questionContent = document.createElement('div');
questionContent.classList.add('question-content');
const questionTitle = document.createElement('h4');
questionTitle.innerText = `${index + 1}. ${item.question}`;
const answerParagraph = document.createElement('p');
answerParagraph.innerText = item.answer;
questionContent.appendChild(questionTitle);
questionContent.appendChild(answerParagraph);
questionTextContainer.appendChild(checkbox);
questionTextContainer.appendChild(questionContent);
const controlsContainer = document.createElement('div');
controlsContainer.classList.add('question-item-controls');
const editBtn = document.createElement('button');
editBtn.classList.add('edit-btn');
editBtn.innerText = 'Edit';
editBtn.dataset.index = index;
editBtn.addEventListener('click', () => {
openEditModal(index);
});
controlsContainer.appendChild(editBtn);
questionItem.appendChild(questionTextContainer);
questionItem.appendChild(controlsContainer);
questionsListContainer.appendChild(questionItem);
});
}
deleteSelectedBtn.addEventListener('click', () => {
if (selectedQuestions.size === 0) return;
const remainingQuestionsCount = interviewQuestions.length - selectedQuestions.size;
if (remainingQuestionsCount < MINIMUM_QUESTIONS) {
alert(`You must have a minimum of ${MINIMUM_QUESTIONS} questions. Cannot delete the selected questions.`);
return;
}
const confirmDelete = confirm(`Are you sure you want to delete ${selectedQuestions.size} question(s)?`);
if (!confirmDelete) return;
stopSpeaking();
const indicesToDelete = Array.from(selectedQuestions).sort((a, b) => b - a);
indicesToDelete.forEach(index => {
interviewQuestions.splice(index, 1);
});
generateQuestionsList();
updateButtonStates();
const currentQuestionIndex = history[historyIndex];
if (indicesToDelete.includes(currentQuestionIndex)) {
const newIndex = getRandomQuestionIndex();
history = [newIndex];
historyIndex = 0;
showCard(newIndex);
} else {
history = history.map(item => {
let newIndex = item;
indicesToDelete.forEach(deletedIndex => {
if (item > deletedIndex) {
newIndex--;
}
});
return newIndex;
});
showCard(history[historyIndex]);
}
});
function toggleAnswer() {
if (answerBox.style.display === 'none') {
answerBox.style.display = 'flex';
showAnswerBtn.innerText = "Show Answer";
} else {
answerBox.style.display = 'none';
showAnswerBtn.innerText = "Hide Answer";
}
}
function openEditModal(index) {
currentEditIndex = index;
const questionToEdit = interviewQuestions[index];
editQuestionInput.value = questionToEdit.question;
editAnswerInput.value = questionToEdit.answer;
editQuestionModal.style.display = 'flex';
}
function parseCSV(text) {
const lines = text.split(/\r?\n/).filter(line => line.trim() !== '');
const questions = [];
lines.forEach(line => {
const parts = [];
let inQuote = false;
let currentPart = '';
for (let i = 0; i < line.length; i++) {
const char = line[i];
if (char === '"') {
inQuote = !inQuote;
} else if (char === ',' && !inQuote) {
parts.push(currentPart.trim());
currentPart = '';
} else {
currentPart += char;
}
}
parts.push(currentPart.trim());
if (parts.length === 2) {
questions.push({
question: parts[0].replace(/^"|"$/g, '').replace(/""/g, '"'),
answer: parts[1].replace(/^"|"$/g, '').replace(/""/g, '"')
});
}
});
return questions;
}
// Event listeners
showAnswerBtn.addEventListener('click', toggleAnswer);
nextCardBtn.addEventListener('click', () => {
if (historyIndex < history.length - 1) {
historyIndex++;
showCard(history[historyIndex]);
} else {
const nextIndex = getRandomQuestionIndex();
history.push(nextIndex);
historyIndex++;
showCard(nextIndex);
}
updateButtonStates();
});
previousCardBtn.addEventListener('click', () => {
if (historyIndex > 0) {
historyIndex--;
showCard(history[historyIndex]);
}
updateButtonStates();
});
speakBtn.addEventListener('click', () => {
if (isSpeaking) {
stopSpeaking();
} else {
const currentQuestion = document.getElementById('question-text').innerText;
speakQuestion(currentQuestion);
}
});
autoplayToggleBtn.addEventListener('click', () => {
autoplayEnabled = !autoplayEnabled;
if (autoplayEnabled) {
autoplayToggleBtn.classList.add("active");
} else {
autoplayToggleBtn.classList.remove("active");
stopSpeaking();
}
});
maleVoiceBtn.addEventListener('click', () => {
selectedVoice = maleVoice;
maleVoiceBtn.classList.add('active');
femaleVoiceBtn.classList.remove('active');
});
femaleVoiceBtn.addEventListener('click', () => {
selectedVoice = femaleVoice;
femaleVoiceBtn.classList.add('active');
maleVoiceBtn.classList.remove('active');
});
// Add Question modal listeners
addQuestionBtn.addEventListener('click', () => {
addQuestionModal.style.display = 'flex';
});
closeAddModalBtn.addEventListener('click', () => {
addQuestionModal.style.display = 'none';
});