gojiteji commited on
Commit
6e37400
·
verified ·
1 Parent(s): 8baa68c

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +773 -19
index.html CHANGED
@@ -1,19 +1,773 @@
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="ja">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Medical Transcription Editor</title>
7
+ <!-- FontAwesome for Icons -->
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <!-- Google Fonts -->
10
+ <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&family=Inter:wght@300;400;600&display=swap" rel="stylesheet">
11
+
12
+ <style>
13
+ :root {
14
+ --primary-color: #2563eb;
15
+ --primary-hover: #1d4ed8;
16
+ --secondary-color: #64748b;
17
+ --background-color: #f8fafc;
18
+ --surface-color: #ffffff;
19
+ --text-main: #1e293b;
20
+ --text-secondary: #64748b;
21
+ --border-color: #e2e8f0;
22
+ --error-color: #ef4444;
23
+ --success-color: #22c55e;
24
+ --warning-color: #f59e0b;
25
+ --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
26
+ --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
27
+ --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
28
+ --radius-md: 0.5rem;
29
+ --radius-lg: 0.75rem;
30
+ --radius-xl: 1rem;
31
+ }
32
+
33
+ * {
34
+ box-sizing: border-box;
35
+ margin: 0;
36
+ padding: 0;
37
+ }
38
+
39
+ body {
40
+ font-family: 'Inter', 'Noto Sans JP', sans-serif;
41
+ background-color: var(--background-color);
42
+ color: var(--text-main);
43
+ line-height: 1.6;
44
+ min-height: 100vh;
45
+ display: flex;
46
+ flex-direction: column;
47
+ }
48
+
49
+ /* --- Header --- */
50
+ header {
51
+ background-color: var(--surface-color);
52
+ border-bottom: 1px solid var(--border-color);
53
+ padding: 1rem 2rem;
54
+ display: flex;
55
+ justify-content: space-between;
56
+ align-items: center;
57
+ box-shadow: var(--shadow-sm);
58
+ position: sticky;
59
+ top: 0;
60
+ z-index: 100;
61
+ }
62
+
63
+ .brand {
64
+ display: flex;
65
+ align-items: center;
66
+ gap: 0.75rem;
67
+ font-weight: 700;
68
+ font-size: 1.25rem;
69
+ color: var(--primary-color);
70
+ }
71
+
72
+ .brand i {
73
+ font-size: 1.5rem;
74
+ }
75
+
76
+ .built-with {
77
+ font-size: 0.875rem;
78
+ color: var(--text-secondary);
79
+ text-decoration: none;
80
+ display: flex;
81
+ align-items: center;
82
+ gap: 0.5rem;
83
+ transition: color 0.2s;
84
+ }
85
+
86
+ .built-with:hover {
87
+ color: var(--primary-color);
88
+ }
89
+
90
+ /* --- Main Layout --- */
91
+ main {
92
+ flex: 1;
93
+ display: grid;
94
+ grid-template-columns: 1fr 350px;
95
+ gap: 2rem;
96
+ padding: 2rem;
97
+ max-width: 1400px;
98
+ margin: 0 auto;
99
+ width: 100%;
100
+ }
101
+
102
+ @media (max-width: 1024px) {
103
+ main {
104
+ grid-template-columns: 1fr;
105
+ }
106
+ }
107
+
108
+ /* --- Editor Section --- */
109
+ .editor-container {
110
+ background-color: var(--surface-color);
111
+ border-radius: var(--radius-xl);
112
+ box-shadow: var(--shadow-md);
113
+ padding: 2rem;
114
+ display: flex;
115
+ flex-direction: column;
116
+ gap: 1.5rem;
117
+ height: fit-content;
118
+ }
119
+
120
+ .section-header {
121
+ display: flex;
122
+ justify-content: space-between;
123
+ align-items: center;
124
+ margin-bottom: 0.5rem;
125
+ }
126
+
127
+ .section-title {
128
+ font-size: 1.125rem;
129
+ font-weight: 600;
130
+ color: var(--text-main);
131
+ display: flex;
132
+ align-items: center;
133
+ gap: 0.5rem;
134
+ }
135
+
136
+ .status-badge {
137
+ font-size: 0.75rem;
138
+ padding: 0.25rem 0.75rem;
139
+ border-radius: 9999px;
140
+ font-weight: 500;
141
+ text-transform: uppercase;
142
+ letter-spacing: 0.05em;
143
+ }
144
+
145
+ .status-badge.analyzed {
146
+ background-color: #dbeafe;
147
+ color: var(--primary-color);
148
+ }
149
+
150
+ .status-badge.processing {
151
+ background-color: #fef3c7;
152
+ color: var(--warning-color);
153
+ }
154
+
155
+ /* Input Area */
156
+ .input-wrapper {
157
+ position: relative;
158
+ }
159
+
160
+ textarea {
161
+ width: 100%;
162
+ min-height: 150px;
163
+ padding: 1rem;
164
+ font-size: 1rem;
165
+ border: 2px solid var(--border-color);
166
+ border-radius: var(--radius-lg);
167
+ font-family: inherit;
168
+ resize: vertical;
169
+ transition: border-color 0.2s, box-shadow 0.2s;
170
+ outline: none;
171
+ }
172
+
173
+ textarea:focus {
174
+ border-color: var(--primary-color);
175
+ box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
176
+ }
177
+
178
+ .input-hint {
179
+ font-size: 0.875rem;
180
+ color: var(--text-secondary);
181
+ margin-top: 0.5rem;
182
+ display: flex;
183
+ justify-content: space-between;
184
+ }
185
+
186
+ /* Action Buttons */
187
+ .actions {
188
+ display: flex;
189
+ gap: 1rem;
190
+ flex-wrap: wrap;
191
+ }
192
+
193
+ .btn {
194
+ display: inline-flex;
195
+ align-items: center;
196
+ gap: 0.5rem;
197
+ padding: 0.625rem 1.25rem;
198
+ font-size: 0.95rem;
199
+ font-weight: 500;
200
+ border-radius: var(--radius-md);
201
+ border: none;
202
+ cursor: pointer;
203
+ transition: all 0.2s;
204
+ }
205
+
206
+ .btn-primary {
207
+ background-color: var(--primary-color);
208
+ color: white;
209
+ box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
210
+ }
211
+
212
+ .btn-primary:hover {
213
+ background-color: var(--primary-hover);
214
+ transform: translateY(-1px);
215
+ }
216
+
217
+ .btn-primary:active {
218
+ transform: translateY(0);
219
+ }
220
+
221
+ .btn-secondary {
222
+ background-color: white;
223
+ color: var(--text-main);
224
+ border: 1px solid var(--border-color);
225
+ }
226
+
227
+ .btn-secondary:hover {
228
+ background-color: #f1f5f9;
229
+ }
230
+
231
+ /* --- Results Section --- */
232
+ .results-panel {
233
+ background-color: var(--surface-color);
234
+ border-radius: var(--radius-xl);
235
+ box-shadow: var(--shadow-md);
236
+ padding: 2rem;
237
+ display: flex;
238
+ flex-direction: column;
239
+ gap: 1.5rem;
240
+ height: fit-content;
241
+ position: sticky;
242
+ top: 5rem;
243
+ }
244
+
245
+ .result-header {
246
+ border-bottom: 1px solid var(--border-color);
247
+ padding-bottom: 1rem;
248
+ }
249
+
250
+ .result-content {
251
+ background-color: #f8fafc;
252
+ border: 1px solid var(--border-color);
253
+ border-radius: var(--radius-md);
254
+ padding: 1rem;
255
+ min-height: 100px;
256
+ white-space: pre-wrap;
257
+ color: var(--text-main);
258
+ font-size: 1rem;
259
+ position: relative;
260
+ }
261
+
262
+ .result-content.highlight {
263
+ background-color: #ecfdf5;
264
+ border-color: #a7f3d0;
265
+ }
266
+
267
+ .suggestions-list {
268
+ display: flex;
269
+ flex-direction: column;
270
+ gap: 1rem;
271
+ max-height: 400px;
272
+ overflow-y: auto;
273
+ padding-right: 0.5rem;
274
+ }
275
+
276
+ /* Scrollbar Styling */
277
+ .suggestions-list::-webkit-scrollbar {
278
+ width: 6px;
279
+ }
280
+ .suggestions-list::-webkit-scrollbar-track {
281
+ background: #f1f1f1;
282
+ border-radius: 4px;
283
+ }
284
+ .suggestions-list::-webkit-scrollbar-thumb {
285
+ background: #cbd5e1;
286
+ border-radius: 4px;
287
+ }
288
+ .suggestions-list::-webkit-scrollbar-thumb:hover {
289
+ background: #94a3b8;
290
+ }
291
+
292
+ .suggestion-card {
293
+ background-color: white;
294
+ border: 1px solid var(--border-color);
295
+ border-radius: var(--radius-md);
296
+ padding: 1rem;
297
+ transition: all 0.2s;
298
+ cursor: pointer;
299
+ position: relative;
300
+ overflow: hidden;
301
+ }
302
+
303
+ .suggestion-card:hover {
304
+ border-color: var(--primary-color);
305
+ box-shadow: var(--shadow-sm);
306
+ }
307
+
308
+ .suggestion-card.active {
309
+ border-color: var(--primary-color);
310
+ background-color: #eff6ff;
311
+ }
312
+
313
+ .suggestion-card::before {
314
+ content: '';
315
+ position: absolute;
316
+ left: 0;
317
+ top: 0;
318
+ bottom: 0;
319
+ width: 4px;
320
+ background-color: var(--primary-color);
321
+ opacity: 0;
322
+ transition: opacity 0.2s;
323
+ }
324
+
325
+ .suggestion-card.active::before {
326
+ opacity: 1;
327
+ }
328
+
329
+ .card-header {
330
+ display: flex;
331
+ justify-content: space-between;
332
+ align-items: flex-start;
333
+ margin-bottom: 0.5rem;
334
+ }
335
+
336
+ .card-title {
337
+ font-weight: 600;
338
+ font-size: 0.9rem;
339
+ color: var(--text-main);
340
+ }
341
+
342
+ .card-badge {
343
+ font-size: 0.7rem;
344
+ padding: 0.15rem 0.5rem;
345
+ border-radius: 4px;
346
+ background-color: #f1f5f9;
347
+ color: var(--text-secondary);
348
+ font-weight: 500;
349
+ }
350
+
351
+ .card-body {
352
+ font-size: 0.9rem;
353
+ color: var(--text-secondary);
354
+ margin-bottom: 0.75rem;
355
+ }
356
+
357
+ .card-footer {
358
+ display: flex;
359
+ justify-content: space-between;
360
+ align-items: center;
361
+ font-size: 0.85rem;
362
+ }
363
+
364
+ .action-icon {
365
+ color: var(--text-secondary);
366
+ padding: 0.25rem;
367
+ border-radius: 4px;
368
+ transition: color 0.2s;
369
+ }
370
+
371
+ .action-icon:hover {
372
+ color: var(--primary-color);
373
+ background-color: #eff6ff;
374
+ }
375
+
376
+ /* Toast Notification */
377
+ .toast-container {
378
+ position: fixed;
379
+ bottom: 2rem;
380
+ right: 2rem;
381
+ display: flex;
382
+ flex-direction: column;
383
+ gap: 1rem;
384
+ z-index: 1000;
385
+ }
386
+
387
+ .toast {
388
+ background-color: var(--surface-color);
389
+ border-left: 4px solid var(--primary-color);
390
+ padding: 1rem 1.5rem;
391
+ border-radius: var(--radius-md);
392
+ box-shadow: var(--shadow-lg);
393
+ display: flex;
394
+ align-items: center;
395
+ gap: 0.75rem;
396
+ animation: slideIn 0.3s ease-out forwards;
397
+ min-width: 300px;
398
+ }
399
+
400
+ .toast.success { border-left-color: var(--success-color); }
401
+ .toast.error { border-left-color: var(--error-color); }
402
+
403
+ @keyframes slideIn {
404
+ from { transform: translateX(100%); opacity: 0; }
405
+ to { transform: translateX(0); opacity: 1; }
406
+ }
407
+
408
+ @keyframes fadeOut {
409
+ to { opacity: 0; transform: translateY(10px); }
410
+ }
411
+
412
+ /* Loading Spinner */
413
+ .spinner {
414
+ width: 1.25rem;
415
+ height: 1.25rem;
416
+ border: 2px solid rgba(255, 255, 255, 0.3);
417
+ border-radius: 50%;
418
+ border-top-color: white;
419
+ animation: spin 0.8s linear infinite;
420
+ }
421
+
422
+ @keyframes spin {
423
+ to { transform: rotate(360deg); }
424
+ }
425
+
426
+ /* Footer */
427
+ footer {
428
+ text-align: center;
429
+ padding: 2rem;
430
+ color: var(--text-secondary);
431
+ font-size: 0.875rem;
432
+ border-top: 1px solid var(--border-color);
433
+ background-color: var(--surface-color);
434
+ margin-top: auto;
435
+ }
436
+ </style>
437
+ </head>
438
+ <body>
439
+
440
+ <header>
441
+ <div class="brand">
442
+ <i class="fa-solid fa-file-medical"></i>
443
+ <span>MediTranscribe</span>
444
+ </div>
445
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="built-with">
446
+ Built with anycoder <i class="fa-solid fa-arrow-up-right-from-square" style="font-size: 0.75rem;"></i>
447
+ </a>
448
+ </header>
449
+
450
+ <main>
451
+ <!-- Left Column: Input -->
452
+ <section class="editor-container">
453
+ <div class="section-header">
454
+ <div class="section-title">
455
+ <i class="fa-solid fa-pen-to-square" style="color: var(--primary-color);"></i>
456
+ Original Text
457
+ </div>
458
+ <span class="status-badge processing" id="status-badge">Processing...</span>
459
+ </div>
460
+
461
+ <div class="input-wrapper">
462
+ <textarea id="input-text" placeholder="Paste the patient transcript here...">患者さんは同期がするらしいですが、信念図は以上なしです。</textarea>
463
+ <div class="input-hint">
464
+ <span>Supports Japanese text input</span>
465
+ <span id="char-count">0 characters</span>
466
+ </div>
467
+ </div>
468
+
469
+ <div class="actions">
470
+ <button class="btn btn-primary" id="analyze-btn">
471
+ <i class="fa-solid fa-wand-magic-sparkles"></i>
472
+ Analyze & Fix
473
+ </button>
474
+ <button class="btn btn-secondary" id="clear-btn">
475
+ <i class="fa-solid fa-eraser"></i>
476
+ Clear
477
+ </button>
478
+ <button class="btn btn-secondary" id="copy-btn">
479
+ <i class="fa-regular fa-copy"></i>
480
+ Copy Result
481
+ </button>
482
+ </div>
483
+ </section>
484
+
485
+ <!-- Right Column: Results -->
486
+ <section class="results-panel">
487
+ <div class="result-header">
488
+ <div class="section-title">
489
+ <i class="fa-solid fa-check-circle" style="color: var(--success-color);"></i>
490
+ Corrected Output
491
+ </div>
492
+ </div>
493
+
494
+ <div id="result-content" class="result-content">
495
+ Waiting for analysis...
496
+ </div>
497
+
498
+ <div class="section-header" style="margin-top: 1rem; border-top: 1px solid var(--border-color); padding-top: 1rem;">
499
+ <div class="section-title">
500
+ <i class="fa-solid fa-list-ul" style="color: var(--secondary-color);"></i>
501
+ Suggestions
502
+ </div>
503
+ </div>
504
+
505
+ <div id="suggestions-list" class="suggestions-list">
506
+ <!-- Dynamic Content Here -->
507
+ </div>
508
+ </section>
509
+ </main>
510
+
511
+ <footer>
512
+ <p>&copy; 2023 MediTranscribe. Secure Medical Transcription Tool.</p>
513
+ </footer>
514
+
515
+ <!-- Toast Container -->
516
+ <div class="toast-container" id="toast-container"></div>
517
+
518
+ <script>
519
+ // --- Configuration & State ---
520
+ const config = {
521
+ delay: 800, // Simulated processing time
522
+ };
523
+
524
+ const state = {
525
+ isAnalyzing: false,
526
+ originalText: '',
527
+ correctedText: '',
528
+ suggestions: []
529
+ };
530
+
531
+ // --- DOM Elements ---
532
+ const elements = {
533
+ input: document.getElementById('input-text'),
534
+ output: document.getElementById('result-content'),
535
+ suggestionsList: document.getElementById('suggestions-list'),
536
+ analyzeBtn: document.getElementById('analyze-btn'),
537
+ clearBtn: document.getElementById('clear-btn'),
538
+ copyBtn: document.getElementById('copy-btn'),
539
+ charCount: document.getElementById('char-count'),
540
+ statusBadge: document.getElementById('status-badge'),
541
+ toastContainer: document.getElementById('toast-container')
542
+ };
543
+
544
+ // --- Initialization ---
545
+ document.addEventListener('DOMContentLoaded', () => {
546
+ updateCharCount();
547
+
548
+ // Focus input if empty
549
+ if (!elements.input.value) {
550
+ elements.input.focus();
551
+ }
552
+ });
553
+
554
+ // --- Event Listeners ---
555
+ elements.input.addEventListener('input', updateCharCount);
556
+
557
+ elements.analyzeBtn.addEventListener('click', handleAnalyze);
558
+
559
+ elements.clearBtn.addEventListener('click', () => {
560
+ elements.input.value = '';
561
+ updateCharCount();
562
+ elements.output.textContent = 'Waiting for analysis...';
563
+ elements.suggestionsList.innerHTML = '';
564
+ elements.statusBadge.className = 'status-badge';
565
+ elements.statusBadge.textContent = 'Ready';
566
+ elements.input.focus();
567
+ showToast('Input cleared', 'info');
568
+ });
569
+
570
+ elements.copyBtn.addEventListener('click', copyToClipboard);
571
+
572
+ // --- Core Logic ---
573
+
574
+ function updateCharCount() {
575
+ const count = elements.input.value.length;
576
+ elements.charCount.textContent = `${count} characters`;
577
+ }
578
+
579
+ function handleAnalyze() {
580
+ const text = elements.input.value.trim();
581
+
582
+ if (!text) {
583
+ showToast('Please enter some text to analyze.', 'error');
584
+ return;
585
+ }
586
+
587
+ if (state.isAnalyzing) return;
588
+
589
+ startAnalysis(text);
590
+ }
591
+
592
+ function startAnalysis(text) {
593
+ state.isAnalyzing = true;
594
+
595
+ // UI Updates
596
+ elements.analyzeBtn.disabled = true;
597
+ elements.analyzeBtn.innerHTML = '<div class="spinner"></div> Analyzing...';
598
+ elements.statusBadge.className = 'status-badge processing';
599
+ elements.statusBadge.textContent = 'Processing...';
600
+
601
+ // Simulate API delay
602
+ setTimeout(() => {
603
+ processText(text);
604
+ finishAnalysis();
605
+ }, config.delay);
606
+ }
607
+
608
+ function processText(text) {
609
+ // Mock Analysis Logic based on the user's specific request
610
+ // "患者さんは同期がするらしいですが、信念図は以上なしです。"
611
+ // This is likely a mishearing of "脈波" (myakuhaku - pulse) and "既往歴" (kikai-reki - medical history)
612
+ // "同期" (doki) -> "脈波" (myakuhaku)
613
+ // "信念図" (shinnen-zu) -> "既往歴" (kikai-reki)
614
+ // "以上なし" (ijou nashi) -> "既往歴なし" (kikai-reki nashi - No medical history)
615
+
616
+ const corrections = [
617
+ {
618
+ type: 'Phonetic Error',
619
+ severity: 'high',
620
+ original: '同期',
621
+ corrected: '脈波',
622
+ reason: 'Likely misheard due to similar sounds.',
623
+ context: '検査項目'
624
+ },
625
+ {
626
+ type: 'Semantic Error',
627
+ severity: 'high',
628
+ original: '信念図',
629
+ corrected: '既往歴',
630
+ reason: 'Likely misheard due to similar sounds.',
631
+ context: 'Medical History'
632
+ },
633
+ {
634
+ type: 'Grammar/Flow',
635
+ severity: 'medium',
636
+ original: '以上なしです',
637
+ corrected: '既往歴なしです',
638
+ reason: 'Missing context word "既往歴".',
639
+ context: 'Diagnosis Summary'
640
+ }
641
+ ];
642
+
643
+ // Construct corrected text
644
+ let processedText = text
645
+ .replace('同期', '脈波')
646
+ .replace('信念図', '既往歴')
647
+ .replace('以上なし', '既往歴なし');
648
+
649
+ state.originalText = text;
650
+ state.correctedText = processedText;
651
+ state.suggestions = corrections;
652
+
653
+ // Render Results
654
+ renderOutput();
655
+ renderSuggestions();
656
+ }
657
+
658
+ function finishAnalysis() {
659
+ state.isAnalyzing = false;
660
+
661
+ // Reset UI
662
+ elements.analyzeBtn.disabled = false;
663
+ elements.analyzeBtn.innerHTML = '<i class="fa-solid fa-wand-magic-sparkles"></i> Analyze & Fix';
664
+ elements.statusBadge.className = 'status-badge analyzed';
665
+ elements.statusBadge.textContent = 'Completed';
666
+
667
+ showToast('Analysis complete. Corrections applied.', 'success');
668
+ }
669
+
670
+ function renderOutput() {
671
+ elements.output.textContent = state.correctedText;
672
+ elements.output.classList.add('highlight');
673
+
674
+ // Remove highlight class after animation
675
+ setTimeout(() => {
676
+ elements.output.classList.remove('highlight');
677
+ }, 2000);
678
+ }
679
+
680
+ function renderSuggestions() {
681
+ elements.suggestionsList.innerHTML = '';
682
+
683
+ state.suggestions.forEach((suggestion, index) => {
684
+ const card = document.createElement('div');
685
+ card.className = 'suggestion-card';
686
+ card.onclick = () => applySuggestion(index);
687
+
688
+ // Severity Badge Color
689
+ let badgeColor = '#64748b'; // gray
690
+ if(suggestion.severity === 'high') badgeColor = '#ef4444'; // red
691
+ if(suggestion.severity === 'medium') badgeColor = '#f59e0b'; // orange
692
+
693
+ card.innerHTML = `
694
+ <div class="card-header">
695
+ <span class="card-title">${suggestion.type}</span>
696
+ <span class="card-badge" style="background-color: ${badgeColor}20; color: ${badgeColor}">${suggestion.severity}</span>
697
+ </div>
698
+ <div class="card-body">
699
+ <div style="display:flex; gap:0.5rem; margin-bottom:0.25rem;">
700
+ <span style="text-decoration: line-through; color: #94a3b8;">${suggestion.original}</span>
701
+ <i class="fa-solid fa-arrow-right" style="color: #cbd5e1; margin-top: 3px;"></i>
702
+ <span style="color: var(--primary-color); font-weight: 600;">${suggestion.corrected}</span>
703
+ </div>
704
+ <p style="font-size: 0.85rem; margin-top: 0.5rem;">${suggestion.reason}</p>
705
+ </div>
706
+ <div class="card-footer">
707
+ <span style="color: var(--text-secondary); font-size: 0.8rem;">Context: ${suggestion.context}</span>
708
+ <i class="fa-solid fa-plus action-icon" title="Apply Fix"></i>
709
+ </div>
710
+ `;
711
+
712
+ elements.suggestionsList.appendChild(card);
713
+ });
714
+ }
715
+
716
+ function applySuggestion(index) {
717
+ const s = state.suggestions[index];
718
+
719
+ // Update input
720
+ const currentInput = elements.input.value;
721
+ // Simple replace logic for demo (in production, you'd handle overlapping matches)
722
+ const newInput = currentInput.replace(s.original, s.corrected);
723
+
724
+ elements.input.value = newInput;
725
+ updateCharCount();
726
+
727
+ // Re-trigger analysis
728
+ handleAnalyze();
729
+
730
+ showToast(`Applied correction: ${s.original} -> ${s.corrected}`, 'success');
731
+ }
732
+
733
+ async function copyToClipboard() {
734
+ if (!state.correctedText) {
735
+ showToast('Nothing to copy yet.', 'error');
736
+ return;
737
+ }
738
+
739
+ try {
740
+ await navigator.clipboard.writeText(state.correctedText);
741
+ showToast('Text copied to clipboard!', 'success');
742
+ } catch (err) {
743
+ showToast('Failed to copy text.', 'error');
744
+ }
745
+ }
746
+
747
+ // --- Toast System ---
748
+ function showToast(message, type = 'info') {
749
+ const toast = document.createElement('div');
750
+ toast.className = `toast ${type}`;
751
+
752
+ let icon = 'fa-info-circle';
753
+ if (type === 'success') icon = 'fa-check-circle';
754
+ if (type === 'error') icon = 'fa-exclamation-circle';
755
+
756
+ toast.innerHTML = `
757
+ <i class="fa-solid ${icon}" style="color: inherit;"></i>
758
+ <span>${message}</span>
759
+ `;
760
+
761
+ elements.toastContainer.appendChild(toast);
762
+
763
+ // Remove after 3 seconds
764
+ setTimeout(() => {
765
+ toast.style.animation = 'fadeOut 0.3s ease-out forwards';
766
+ toast.addEventListener('animationend', () => {
767
+ toast.remove();
768
+ });
769
+ }, 3000);
770
+ }
771
+ </script>
772
+ </body>
773
+ </html>