omaralaa2004 commited on
Commit
b413aec
·
verified ·
1 Parent(s): 12be340

Delete templates

Browse files
Files changed (1) hide show
  1. templates +0 -896
templates DELETED
@@ -1,896 +0,0 @@
1
- <script type="text/javascript">
2
- var gk_isXlsx = false;
3
- var gk_xlsxFileLookup = {};
4
- var gk_fileData = {};
5
- function filledCell(cell) {
6
- return cell !== '' && cell != null;
7
- }
8
- function loadFileData(filename) {
9
- if (gk_isXlsx && gk_xlsxFileLookup[filename]) {
10
- try {
11
- var workbook = XLSX.read(gk_fileData[filename], { type: 'base64' });
12
- var firstSheetName = workbook.SheetNames[0];
13
- var worksheet = workbook.Sheets[firstSheetName];
14
-
15
- // Convert sheet to JSON to filter blank rows
16
- var jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 1, blankrows: false, defval: '' });
17
- // Filter out blank rows (rows where all cells are empty, null, or undefined)
18
- var filteredData = jsonData.filter(row => row.some(filledCell));
19
-
20
- // Heuristic to find the header row by ignoring rows with fewer filled cells than the next row
21
- var headerRowIndex = filteredData.findIndex((row, index) =>
22
- row.filter(filledCell).length >= filteredData[index + 1]?.filter(filledCell).length
23
- );
24
- // Fallback
25
- if (headerRowIndex === -1 || headerRowIndex > 25) {
26
- headerRowIndex = 0;
27
- }
28
-
29
- // Convert filtered JSON back to CSV
30
- var csv = XLSX.utils.aoa_to_sheet(filteredData.slice(headerRowIndex)); // Create a new sheet from filtered array of arrays
31
- csv = XLSX.utils.sheet_to_csv(csv, { header: 1 });
32
- return csv;
33
- } catch (e) {
34
- console.error(e);
35
- return "";
36
- }
37
- }
38
- return gk_fileData[filename] || "";
39
- }
40
- </script><!DOCTYPE html>
41
- <html lang="en">
42
- <head>
43
- <meta charset="UTF-8">
44
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
45
- <title>Stroke Risk Prediction</title>
46
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
47
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
48
- <style>
49
- :root {
50
- --primary-color: #4e54c8;
51
- --secondary-color: #8f94fb;
52
- --success-color: #23ce6b;
53
- --danger-color: #ff6b6b;
54
- --light-bg: #f9f9ff;
55
- --dark-text: #333344;
56
- }
57
-
58
- body {
59
- background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
60
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
61
- color: var(--dark-text);
62
- min-height: 100vh;
63
- display: flex;
64
- align-items: center;
65
- justify-content: center;
66
- padding: 20px 0;
67
- }
68
-
69
- .container {
70
- max-width: 900px;
71
- background-color: rgba(255, 255, 255, 0.95);
72
- padding: 40px;
73
- border-radius: 20px;
74
- box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
75
- backdrop-filter: blur(5px);
76
- }
77
-
78
- h1 {
79
- background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
80
- -webkit-background-clip: text;
81
- background-clip: text;
82
- color: transparent;
83
- font-weight: 700;
84
- margin-bottom: 30px;
85
- text-align: center;
86
- font-size: 2.5rem;
87
- }
88
-
89
- .form-group {
90
- margin-bottom: 25px;
91
- position: relative;
92
- }
93
-
94
- .form-control {
95
- border-radius: 10px;
96
- padding: 12px 15px;
97
- border: 2px solid #e0e0ff;
98
- transition: all 0.3s ease;
99
- }
100
-
101
- .form-control:focus {
102
- box-shadow: 0 0 0 3px rgba(78, 84, 200, 0.2);
103
- border-color: var(--primary-color);
104
- }
105
-
106
- label {
107
- font-weight: 600;
108
- margin-bottom: 8px;
109
- display: block;
110
- color: var(--primary-color);
111
- }
112
-
113
- .btn-predict {
114
- background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
115
- border: none;
116
- width: 100%;
117
- padding: 15px;
118
- font-size: 18px;
119
- margin-top: 20px;
120
- border-radius: 10px;
121
- font-weight: 600;
122
- color: white;
123
- transition: all 0.3s ease;
124
- position: relative;
125
- overflow: hidden;
126
- }
127
-
128
- .btn-predict:hover {
129
- transform: translateY(-3px);
130
- box-shadow: 0 7px 14px rgba(78, 84, 200, 0.3);
131
- }
132
-
133
- .btn-predict:after {
134
- content: '';
135
- position: absolute;
136
- top: 50%;
137
- left: 50%;
138
- width: 5px;
139
- height: 5px;
140
- background: rgba(255, 255, 255, 0.5);
141
- opacity: 0;
142
- border-radius: 100%;
143
- transform: scale(1, 1) translate(-50%, -50%);
144
- transform-origin: 50% 50%;
145
- }
146
-
147
- .btn-predict:focus:not(:active)::after {
148
- animation: ripple 1s ease-out;
149
- }
150
-
151
- @keyframes ripple {
152
- 0% {
153
- transform: scale(0, 0);
154
- opacity: 0.5;
155
- }
156
- 100% {
157
- transform: scale(20, 20);
158
- opacity: 0;
159
- }
160
- }
161
-
162
- .result-container {
163
- margin-top: 40px;
164
- padding: 30px;
165
- border-radius: 15px;
166
- display: none;
167
- transform: translateY(20px);
168
- transition: all 0.5s ease;
169
- }
170
-
171
- .high-risk {
172
- background-color: rgba(255, 107, 107, 0.2);
173
- border: 2px solid var(--danger-color);
174
- }
175
-
176
- .low-risk {
177
- background-color: rgba(35, 206, 107, 0.2);
178
- border: 2px solid var(--success-color);
179
- }
180
-
181
- .form-section {
182
- padding: 20px;
183
- border-radius: 15px;
184
- box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
185
- margin-bottom: 25px;
186
- background-color: white;
187
- }
188
-
189
- .section-title {
190
- border-bottom: 2px solid #e0e0ff;
191
- padding-bottom: 10px;
192
- margin-bottom: 20px;
193
- color: var(--primary-color);
194
- font-weight: 600;
195
- }
196
-
197
- .progress-bar {
198
- height: 8px;
199
- background-color: #e0e0ff;
200
- border-radius: 4px;
201
- margin-bottom: 30px;
202
- position: relative;
203
- }
204
-
205
- .progress-fill {
206
- height: 100%;
207
- border-radius: 4px;
208
- background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
209
- width: 0;
210
- transition: width 0.3s ease;
211
- }
212
-
213
- .gauge-container {
214
- width: 200px;
215
- height: 200px;
216
- margin: 0 auto;
217
- position: relative;
218
- }
219
-
220
- .gauge {
221
- width: 200px;
222
- height: 100px;
223
- position: relative;
224
- overflow: hidden;
225
- border-top-left-radius: 100px;
226
- border-top-right-radius: 100px;
227
- margin-bottom: 10px;
228
- }
229
-
230
- .gauge-bg {
231
- width: 200px;
232
- height: 200px;
233
- border-radius: 100px;
234
- position: absolute;
235
- background: linear-gradient(0deg, #f0f0f0 0%, #e0e0e0 100%);
236
- }
237
-
238
- .gauge-fill {
239
- width: 200px;
240
- height: 200px;
241
- border-radius: 100px;
242
- position: absolute;
243
- background: linear-gradient(90deg, #23ce6b 0%, #ff6b6b 100%);
244
- transform-origin: center bottom;
245
- transform: rotate(0deg);
246
- transition: transform 1s ease-out;
247
- }
248
-
249
- .gauge-center {
250
- width: 160px;
251
- height: 160px;
252
- background: white;
253
- border-radius: 80px;
254
- position: absolute;
255
- top: 20px;
256
- left: 20px;
257
- z-index: 10;
258
- display: flex;
259
- align-items: center;
260
- justify-content: center;
261
- flex-direction: column;
262
- }
263
-
264
- .percentage {
265
- font-size: 32px;
266
- font-weight: 700;
267
- color: var(--dark-text);
268
- }
269
-
270
- .risk-label {
271
- font-size: 18px;
272
- font-weight: 600;
273
- }
274
-
275
- .form-nav {
276
- display: flex;
277
- justify-content: space-between;
278
- margin-top: 20px;
279
- }
280
-
281
- .btn-nav {
282
- padding: 10px 20px;
283
- border-radius: 10px;
284
- background: white;
285
- border: 2px solid #e0e0ff;
286
- color: var(--primary-color);
287
- font-weight: 600;
288
- transition: all 0.3s ease;
289
- }
290
-
291
- .btn-nav:hover {
292
- background: var(--primary-color);
293
- color: white;
294
- border-color: var(--primary-color);
295
- }
296
-
297
- .form-step {
298
- display: none;
299
- }
300
-
301
- .form-step.active {
302
- display: block;
303
- animation: fadeIn 0.5s;
304
- }
305
-
306
- @keyframes fadeIn {
307
- from { opacity: 0; transform: translateY(20px); }
308
- to { opacity: 1; transform: translateY(0); }
309
- }
310
-
311
- .step-indicator {
312
- display: flex;
313
- justify-content: center;
314
- margin-bottom: 30px;
315
- }
316
-
317
- .step {
318
- width: 40px;
319
- height: 40px;
320
- border-radius: 50%;
321
- background-color: #e0e0ff;
322
- display: flex;
323
- align-items: center;
324
- justify-content: center;
325
- font-weight: 600;
326
- color: var(--dark-text);
327
- margin: 0 10px;
328
- position: relative;
329
- transition: all 0.3s ease;
330
- }
331
-
332
- .step.active {
333
- background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
334
- color: white;
335
- transform: scale(1.1);
336
- }
337
-
338
- .step.completed {
339
- background: var(--success-color);
340
- color: white;
341
- }
342
-
343
- .step-line {
344
- position: absolute;
345
- height: 3px;
346
- background-color: #e0e0ff;
347
- top: 20px;
348
- left: 40px;
349
- width: calc(100% - 100px);
350
- z-index: -1;
351
- }
352
-
353
- .factors-list {
354
- padding: 20px;
355
- background-color: #f9f9ff;
356
- border-radius: 10px;
357
- margin-top: 20px;
358
- }
359
-
360
- .factor-item {
361
- margin-bottom: 10px;
362
- padding-left: 25px;
363
- position: relative;
364
- }
365
-
366
- .factor-item:before {
367
- content: '•';
368
- position: absolute;
369
- left: 8px;
370
- color: var(--primary-color);
371
- font-weight: bold;
372
- }
373
-
374
- .risk-actions {
375
- margin-top: 20px;
376
- padding: 20px;
377
- background-color: #fdfdff;
378
- border-radius: 10px;
379
- border-left: 4px solid var(--primary-color);
380
- }
381
-
382
- .form-floating {
383
- margin-bottom: 20px;
384
- }
385
-
386
- .form-floating label {
387
- padding: 1rem 0.75rem;
388
- }
389
-
390
- .info-tooltip {
391
- display: inline-block;
392
- width: 18px;
393
- height: 18px;
394
- background-color: #e0e0ff;
395
- color: var(--primary-color);
396
- border-radius: 50%;
397
- text-align: center;
398
- line-height: 18px;
399
- font-size: 12px;
400
- margin-left: 5px;
401
- cursor: pointer;
402
- position: relative;
403
- }
404
-
405
- .info-tooltip .tooltip-text {
406
- visibility: hidden;
407
- width: 200px;
408
- background-color: #333;
409
- color: white;
410
- text-align: center;
411
- border-radius: 6px;
412
- padding: 5px;
413
- position: absolute;
414
- z-index: 1;
415
- bottom: 125%;
416
- left: 50%;
417
- margin-left: -100px;
418
- opacity: 0;
419
- transition: opacity 0.3s;
420
- font-size: 12px;
421
- font-weight: normal;
422
- }
423
-
424
- .info-tooltip:hover .tooltip-text {
425
- visibility: visible;
426
- opacity: 1;
427
- }
428
-
429
- .loader {
430
- display: none;
431
- width: 48px;
432
- height: 48px;
433
- border: 5px solid var(--primary-color);
434
- border-bottom-color: transparent;
435
- border-radius: 50%;
436
- box-sizing: border-box;
437
- animation: rotation 1s linear infinite;
438
- position: absolute;
439
- top: 50%;
440
- left: 50%;
441
- transform: translate(-50%, -50%);
442
- }
443
-
444
- @keyframes rotation {
445
- 0% {
446
- transform: translate(-50%, -50%) rotate(0deg);
447
- }
448
- 100% {
449
- transform: translate(-50%, -50%) rotate(360deg);
450
- }
451
- }
452
-
453
- .overlay {
454
- display: none;
455
- position: fixed;
456
- top: 0;
457
- left: 0;
458
- width: 100%;
459
- height: 100%;
460
- background-color: rgba(0, 0, 0, 0.5);
461
- z-index: 1000;
462
- }
463
- </style>
464
- </head>
465
- <body>
466
- <div class="container animate__animated animate__fadeIn">
467
- <div class="step-indicator">
468
- <div class="step active" id="step-1">1</div>
469
- <div class="step" id="step-2">2</div>
470
- <div class="step" id="step-3">3</div>
471
- <div class="step-line"></div>
472
- </div>
473
-
474
- <h1>Stroke Risk Prediction</h1>
475
-
476
- <div class="progress-bar">
477
- <div class="progress-fill" id="progress-bar"></div>
478
- </div>
479
-
480
- <form id="prediction-form">
481
- <div class="form-step active" id="form-step-1">
482
- <div class="form-section">
483
- <h3 class="section-title">Personal Information</h3>
484
- <div class="row">
485
- <div class="col-md-6">
486
- <div class="form-group">
487
- <label for="age">Age <span class="info-tooltip">i<span class="tooltip-text">Enter your age in years</span></span></label>
488
- <input type="number" class="form-control" id="age" name="age" required min="0" max="120" step="0.1">
489
- </div>
490
- </div>
491
- <div class="col-md-6">
492
- <div class="form-group">
493
- <label for="gender">Gender <span class="info-tooltip">i<span class="tooltip-text">Select your gender</span></span></label>
494
- <select class="form-control" id="gender" name="gender" required>
495
- <option value="">Select Gender</option>
496
- <option value="Male">Male</option>
497
- <option value="Female">Female</option>
498
- <option value="Other">Other</option>
499
- </select>
500
- </div>
501
- </div>
502
- </div>
503
-
504
- <div class="row">
505
- <div class="col-md-6">
506
- <div class="form-group">
507
- <label for="ever_married">Ever Married <span class="info-tooltip">i<span class="tooltip-text">Have you ever been married?</span></span></label>
508
- <select class="form-control" id="ever_married" name="ever_married" required>
509
- <option value="">Select</option>
510
- <option value="Yes">Yes</option>
511
- <option value="No">No</option>
512
- </select>
513
- </div>
514
- </div>
515
- <div class="col-md-6">
516
- <div class="form-group">
517
- <label for="Residence_type">Residence Type <span class="info-tooltip">i<span class="tooltip-text">Urban or rural area</span></span></label>
518
- <select class="form-control" id="Residence_type" name="Residence_type" required>
519
- <option value="">Select</option>
520
- <option value="Urban">Urban</option>
521
- <option value="Rural">Rural</option>
522
- </select>
523
- </div>
524
- </div>
525
- </div>
526
-
527
- <div class="row">
528
- <div class="col-md-12">
529
- <div class="form-group">
530
- <label for="work_type">Work Type <span class="info-tooltip">i<span class="tooltip-text">Type of employment</span></span></label>
531
- <select class="form-control" id="work_type" name="work_type" required>
532
- <option value="">Select Work Type</option>
533
- <option value="Private">Private</option>
534
- <option value="Self-employed">Self-employed</option>
535
- <option value="Govt_job">Government Job</option>
536
- <option value="Never_worked">Never worked</option>
537
- </select>
538
- </div>
539
- </div>
540
- </div>
541
- </div>
542
-
543
- <div class="form-nav">
544
- <div></div>
545
- <button type="button" class="btn btn-nav" id="next-1">Next <i class="fas fa-arrow-right"></i></button>
546
- </div>
547
- </div>
548
-
549
- <div class="form-step" id="form-step-2">
550
- <div class="form-section">
551
- <h3 class="section-title">Health Information</h3>
552
- <div class="row">
553
- <div class="col-md-6">
554
- <div class="form-group">
555
- <label for="hypertension">Hypertension <span class="info-tooltip">i<span class="tooltip-text">Do you have hypertension?</span></span></label>
556
- <select class="form-control" id="hypertension" name="hypertension" required>
557
- <option value="">Select</option>
558
- <option value="1">Yes</option>
559
- <option value="0">No</option>
560
- </select>
561
- </div>
562
- </div>
563
- <div class="col-md-6">
564
- <div class="form-group">
565
- <label for="heart_disease">Heart Disease <span class="info-tooltip">i<span class="tooltip-text">Do you have heart disease?</span></span></label>
566
- <select class="form-control" id="heart_disease" name="heart_disease" required>
567
- <option value="">Select</option>
568
- <option value="1">Yes</option>
569
- <option value="0">No</option>
570
- </select>
571
- </div>
572
- </div>
573
- </div>
574
-
575
- <div class="row">
576
- <div class="col-md-6">
577
- <div class="form-group">
578
- <label for="avg_glucose_level">Average Glucose Level (mg/dL) <span class="info-tooltip">i<span class="tooltip-text">Normal fasting blood sugar is under 100 mg/dL</span></span></label>
579
- <input type="number" class="form-control" id="avg_glucose_level" name="avg_glucose_level" required min="0" step="0.01">
580
- </div>
581
- </div>
582
- <div class="col-md-6">
583
- <div class="form-group">
584
- <label for="bmi">BMI <span class="info-tooltip">i<span class="tooltip-text">Body Mass Index (weight in kg / height in m²)</span></span></label>
585
- <input type="number" class="form-control" id="bmi" name="bmi" required min="0" max="100" step="0.01">
586
- </div>
587
- </div>
588
- </div>
589
-
590
- <div class="row">
591
- <div class="col-md-12">
592
- <div class="form-group">
593
- <label for="smoking_status">Smoking Status <span class="info-tooltip">i<span class="tooltip-text">Your smoking habits</span></span></label>
594
- <select class="form-control" id="smoking_status" name="smoking_status" required>
595
- <option value="">Select Smoking Status</option>
596
- <option value="formerly smoked">Formerly Smoked</option>
597
- <option value="never smoked">Never Smoked</option>
598
- <option value="smokes">Currently Smokes</option>
599
- <option value="Unknown">Unknown</option>
600
- </select>
601
- </div>
602
- </div>
603
- </div>
604
- </div>
605
-
606
- <div class="form-nav">
607
- <button type="button" class="btn btn-nav" id="prev-2">Previous</button>
608
- <button type="button" class="btn btn-nav" id="next-2">Next</button>
609
- </div>
610
- </div>
611
-
612
- <div class="form-step" id="form-step-3">
613
- <div class="form-section">
614
- <h3 class="section-title">Summary</h3>
615
- <p>Please review your information below before submitting:</p>
616
-
617
- <div class="row">
618
- <div class="col-md-6">
619
- <p><strong>Age:</strong> <span id="summary-age"></span></p>
620
- <p><strong>Gender:</strong> <span id="summary-gender"></span></p>
621
- <p><strong>Ever Married:</strong> <span id="summary-married"></span></p>
622
- <p><strong>Residence Type:</strong> <span id="summary-residence"></span></p>
623
- <p><strong>Work Type:</strong> <span id="summary-work"></span></p>
624
- </div>
625
- <div class="col-md-6">
626
- <p><strong>Hypertension:</strong> <span id="summary-hypertension"></span></p>
627
- <p><strong>Heart Disease:</strong> <span id="summary-heart"></span></p>
628
- <p><strong>Avg. Glucose Level:</strong> <span id="summary-glucose"></span> mg/dL</p>
629
- <p><strong>BMI:</strong> <span id="summary-bmi"></span></p>
630
- <p><strong>Smoking Status:</strong> <span id="summary-smoking"></span></p>
631
- </div>
632
- </div>
633
- </div>
634
-
635
- <div class="form-nav">
636
- <button type="button" class="btn btn-nav" id="prev-3">Previous</button>
637
- <button type="submit" class="btn btn-predict">Predict Stroke Risk</button>
638
- </div>
639
- </div>
640
- </form>
641
-
642
- <div id="result" class="result-container animate__animated">
643
- <h3 id="result-title" class="text-center mb-4">Prediction Result</h3>
644
-
645
- <div class="gauge-container">
646
- <div class="gauge">
647
- <div class="gauge-bg"></div>
648
- <div class="gauge-fill" id="gauge-fill"></div>
649
- </div>
650
- <div class="gauge-center">
651
- <div class="percentage" id="probability-display">0%</div>
652
- <div class="risk-label" id="risk-label">Risk</div>
653
- </div>
654
- </div>
655
-
656
- <p id="result-message" class="text-center mt-4 mb-3"></p>
657
-
658
- <div class="factors-list" id="risk-factors">
659
- <h4>Key Risk Factors:</h4>
660
- <div class="factor-item">Age is a significant risk factor for stroke</div>
661
- <div class="factor-item" id="factor-glucose">High glucose levels increase stroke risk</div>
662
- <div class="factor-item" id="factor-hypertension">Hypertension significantly increases stroke risk</div>
663
- <div class="factor-item" id="factor-heart">Heart disease is a major risk factor</div>
664
- <div class="factor-item" id="factor-smoking">Smoking increases stroke risk</div>
665
- </div>
666
-
667
- <div class="risk-actions">
668
- <h4>Recommended Actions:</h4>
669
- <p>Based on your results, consider the following steps:</p>
670
- <ul>
671
- <li>Consult with your healthcare provider</li>
672
- <li>Monitor your blood pressure regularly</li>
673
- <li>Maintain a healthy diet and exercise routine</li>
674
- <li>If you smoke, consider quitting</li>
675
- <li>Keep your glucose levels in check</li>
676
- </ul>
677
- <p class="text-center mt-3"><strong>Remember:</strong> This tool provides an estimate only and is not a substitute for professional medical advice.</p>
678
- </div>
679
-
680
- <div class="text-center mt-4">
681
- <button type="button" class="btn btn-nav" id="start-over">Start Over</button>
682
- </div>
683
- </div>
684
- </div>
685
-
686
- <div class="overlay" id="loading-overlay">
687
- <div class="loader"></div>
688
- </div>
689
-
690
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
691
- <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/js/all.min.js"></script>
692
- <script>
693
- $(document).ready(function() {
694
- let currentStep = 1;
695
- const totalSteps = 3;
696
-
697
- // Update progress bar
698
- function updateProgressBar() {
699
- const progressPercent = ((currentStep - 1) / (totalSteps - 1)) * 100;
700
- $('#progress-bar').css('width', progressPercent + '%');
701
- }
702
-
703
- // Navigate to next step
704
- function nextStep() {
705
- if (validateStep(currentStep)) {
706
- $(`#form-step-${currentStep}`).removeClass('active');
707
- currentStep++;
708
- $(`#form-step-${currentStep}`).addClass('active animate__animated animate__fadeIn');
709
-
710
- // Update step indicators
711
- $(`.step`).removeClass('active');
712
- $(`#step-${currentStep}`).addClass('active');
713
-
714
- // Mark previous steps as completed
715
- for (let i = 1; i < currentStep; i++) {
716
- $(`#step-${i}`).addClass('completed');
717
- }
718
-
719
- updateProgressBar();
720
-
721
- // If final step, update summary
722
- if (currentStep === 3) {
723
- updateSummary();
724
- }
725
- }
726
- }
727
-
728
- // Navigate to previous step
729
- function prevStep() {
730
- $(`#form-step-${currentStep}`).removeClass('active');
731
- currentStep--;
732
- $(`#form-step-${currentStep}`).addClass('active animate__animated animate__fadeIn');
733
-
734
- // Update step indicators
735
- $(`.step`).removeClass('active');
736
- $(`#step-${currentStep}`).addClass('active');
737
-
738
- updateProgressBar();
739
- }
740
-
741
- // Validate current step
742
- function validateStep(step) {
743
- let isValid = true;
744
-
745
- $(`#form-step-${step} input, #form-step-${step} select`).each(function() {
746
- if ($(this).prop('required') && !$(this).val()) {
747
- isValid = false;
748
- $(this).addClass('is-invalid');
749
- } else {
750
- $(this).removeClass('is-invalid');
751
- }
752
- });
753
-
754
- return isValid;
755
- }
756
-
757
- // Update summary before submission
758
- function updateSummary() {
759
- $('#summary-age').text($('#age').val());
760
- $('#summary-gender').text($('#gender').val());
761
- $('#summary-married').text($('#ever_married').val());
762
- $('#summary-residence').text($('#Residence_type').val());
763
- $('#summary-work').text($('#work_type').val());
764
- $('#summary-hypertension').text($('#hypertension').val() === '1' ? 'Yes' : 'No');
765
- $('#summary-heart').text($('#heart_disease').val() === '1' ? 'Yes' : 'No');
766
- $('#summary-glucose').text($('#avg_glucose_level').val());
767
- $('#summary-bmi').text($('#bmi').val());
768
- $('#summary-smoking').text($('#smoking_status').val());
769
- }
770
-
771
- // Navigation button click handlers
772
- $('#next-1').click(nextStep);
773
- $('#next-2').click(nextStep);
774
- $('#prev-2').click(prevStep);
775
- $('#prev-3').click(prevStep);
776
-
777
- // Start over button
778
- $('#start-over').click(function() {
779
- $('#prediction-form')[0].reset();
780
- $('#result').removeClass('animate__fadeIn').addClass('animate__fadeOut');
781
-
782
- setTimeout(function() {
783
- $('#result').hide().removeClass('animate__fadeOut');
784
-
785
- // Reset to first step
786
- $('.form-step').removeClass('active');
787
- $('#form-step-1').addClass('active');
788
- currentStep = 1;
789
-
790
- // Reset step indicators
791
- $('.step').removeClass('active completed');
792
- $('#step-1').addClass('active');
793
-
794
- updateProgressBar();
795
- }, 500);
796
- });
797
-
798
- // Field validation on input change
799
- $('input, select').on('change', function() {
800
- if ($(this).prop('required') && !$(this).val()) {
801
- $(this).addClass('is-invalid');
802
- } else {
803
- $(this).removeClass('is-invalid');
804
- }
805
- });
806
-
807
- // Form submission with animation
808
- $('#prediction-form').on('submit', function(e) {
809
- e.preventDefault();
810
-
811
- if (validateStep(currentStep)) {
812
- // Show loading overlay
813
- $('#loading-overlay').fadeIn();
814
-
815
- // Collect form data
816
- const formData = {
817
- age: $('#age').val(),
818
- gender: $('#gender').val(),
819
- ever_married: $('#ever_married').val(),
820
- residence_type: $('#Residence_type').val(),
821
- work_type: $('#work_type').val(),
822
- hypertension: $('#hypertension').val(),
823
- heart_disease: $('#heart_disease').val(),
824
- avg_glucose_level: $('#avg_glucose_level').val(),
825
- bmi: $('#bmi').val(),
826
- smoking_status: $('#smoking_status').val()
827
- };
828
-
829
- // Send data to Flask backend
830
- $.ajax({
831
- url: '/predict',
832
- type: 'POST',
833
- contentType: 'application/json',
834
- data: JSON.stringify({ input: formData }),
835
- success: function(response) {
836
- if (response.success) {
837
- // Hide loading overlay
838
- $('#loading-overlay').fadeOut();
839
-
840
- // Process and display result
841
- processResult(response);
842
- } else {
843
- $('#loading-overlay').fadeOut();
844
- alert('Error: ' + response.error);
845
- }
846
- },
847
- error: function(xhr, status, error) {
848
- console.error('Error submitting data:', error);
849
- $('#loading-overlay').fadeOut();
850
- alert('An error occurred while processing your request. Please try again.');
851
- }
852
- });
853
- }
854
- });
855
-
856
- // Process and display prediction results
857
- function processResult(response) {
858
- const { probability, riskLevel, contributingFactors } = response;
859
-
860
- // Update gauge
861
- const rotation = (probability / 100) * 180; // Map 0-100% to 0-180 degrees
862
- $('#gauge-fill').css('transform', `rotate(${rotation}deg)`);
863
-
864
- // Update percentage and risk label
865
- $('#probability-display').text(`${probability}%`);
866
- $('#risk-label').text(`${riskLevel} Risk`);
867
-
868
- // Update result message and styling
869
- $('#result').removeClass('high-risk low-risk');
870
- if (riskLevel === 'High') {
871
- $('#result').addClass('high-risk');
872
- $('#result-message').text('Your stroke risk is high. Please consult a healthcare professional immediately.');
873
- } else if (riskLevel === 'Moderate') {
874
- $('#result').addClass('high-risk');
875
- $('#result-message').text('Your stroke risk is moderate. Consider discussing with your doctor.');
876
- } else {
877
- $('#result').addClass('low-risk');
878
- $('#result-message').text('Your stroke risk is low. Continue maintaining a healthy lifestyle.');
879
- }
880
-
881
- // Update risk factors visibility
882
- $('#factor-glucose').toggle(contributingFactors.glucose);
883
- $('#factor-hypertension').toggle(contributingFactors.hypertension);
884
- $('#factor-heart').toggle(contributingFactors.heartDisease);
885
- $('#factor-smoking').toggle(contributingFactors.smoking);
886
-
887
- // Show result with animation
888
- $('#result').show().removeClass('animate__fadeOut').addClass('animate__fadeIn');
889
-
890
- // Hide form
891
- $('#prediction-form').hide();
892
- }
893
- });
894
- </script>
895
- </body>
896
- </html>