Jobanjps commited on
Commit
bc1db07
·
verified ·
1 Parent(s): 4aa1532

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +271 -6
templates/index.html CHANGED
@@ -323,11 +323,69 @@
323
  opacity: 0;
324
  transform: translateY(20px);
325
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  }
327
 
328
  .result.show {
329
  opacity: 1;
330
- transform: translateY(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  }
332
 
333
  .result-card {
@@ -370,19 +428,126 @@
370
  }
371
 
372
  .result-value {
373
- font-size: 32px;
374
  font-weight: 700;
375
  background: linear-gradient(135deg, #667eea, #764ba2);
376
  -webkit-background-clip: text;
377
  -webkit-text-fill-color: transparent;
378
  background-clip: text;
379
- margin-bottom: 8px;
380
  }
381
 
382
  .result-description {
383
  color: #718096;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  font-size: 14px;
385
- line-height: 1.5;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  }
387
 
388
  .wellness-indicator {
@@ -745,23 +910,48 @@
745
  </form>
746
 
747
  <div class="result" id="resultSection">
 
748
  <div class="result-card">
749
  <div class="result-content">
750
  <div class="result-label">Mental Health Index</div>
751
- <div class="result-value" id="resultValue">0.0</div>
752
  <div class="result-description" id="resultDescription">
753
  Your personalized health score based on digital habits
754
  </div>
 
 
 
 
 
 
 
 
 
 
755
  <div class="wellness-indicator">
756
  <div class="indicator-dot poor" data-range="0-25"></div>
757
  <div class="indicator-dot fair" data-range="25-50"></div>
758
  <div class="indicator-dot good" data-range="50-75"></div>
759
  <div class="indicator-dot excellent" data-range="75-100"></div>
760
  </div>
 
 
 
 
 
 
 
 
 
 
 
761
  </div>
762
  </div>
763
  </div>
764
 
 
 
 
765
  <!-- Copyright -->
766
  <div class="copyright">
767
  © 2025 Jobanpreet Singh. All rights reserved.
@@ -864,6 +1054,12 @@
864
  </div>
865
 
866
  <script>
 
 
 
 
 
 
867
  // Page Navigation
868
  function showPage(pageName) {
869
  // Hide all pages
@@ -928,6 +1124,41 @@
928
  return "Consider significant lifestyle adjustments for better mental health.";
929
  }
930
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
931
  function updateWellnessIndicator(score) {
932
  const dots = document.querySelectorAll('.indicator-dot');
933
  dots.forEach(dot => dot.classList.remove('active'));
@@ -944,7 +1175,7 @@
944
  if (!startTimestamp) startTimestamp = timestamp;
945
  const progress = Math.min((timestamp - startTimestamp) / duration, 1);
946
  const value = progress * (end - start) + start;
947
- element.textContent = value.toFixed(1);
948
  if (progress < 1) {
949
  window.requestAnimationFrame(step);
950
  }
@@ -952,6 +1183,24 @@
952
  window.requestAnimationFrame(step);
953
  }
954
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
955
  form.addEventListener('submit', async function(e) {
956
  e.preventDefault();
957
 
@@ -974,14 +1223,30 @@
974
 
975
  const wellnessScore = calculateWellnessIndex(screenTime, sleepHours, workScreen);
976
  const description = getWellnessDescription(wellnessScore);
 
977
 
978
  // Show results with animation
 
979
  resultSection.classList.add('show');
980
  resultDescription.textContent = description;
981
 
 
 
 
 
 
 
 
 
 
 
 
982
  // Animate the score counter
983
  animateValue(resultValue, 0, wellnessScore, 1000);
984
 
 
 
 
985
  // Update wellness indicator
986
  setTimeout(() => updateWellnessIndicator(wellnessScore), 500);
987
 
 
323
  opacity: 0;
324
  transform: translateY(20px);
325
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
326
+ position: fixed;
327
+ top: 50%;
328
+ left: 50%;
329
+ transform: translate(-50%, -50%) scale(0.8);
330
+ width: 90%;
331
+ max-width: 500px;
332
+ background: rgba(255, 255, 255, 0.98);
333
+ backdrop-filter: blur(20px);
334
+ border-radius: 24px;
335
+ padding: 40px;
336
+ box-shadow: 0 25px 50px rgba(0,0,0,0.3);
337
+ z-index: 2000;
338
+ pointer-events: none;
339
  }
340
 
341
  .result.show {
342
  opacity: 1;
343
+ transform: translate(-50%, -50%) scale(1);
344
+ pointer-events: auto;
345
+ }
346
+
347
+ .result-overlay {
348
+ position: fixed;
349
+ top: 0;
350
+ left: 0;
351
+ width: 100%;
352
+ height: 100%;
353
+ background: rgba(0, 0, 0, 0.7);
354
+ backdrop-filter: blur(5px);
355
+ z-index: 1999;
356
+ opacity: 0;
357
+ pointer-events: none;
358
+ transition: opacity 0.5s ease;
359
+ }
360
+
361
+ .result-overlay.show {
362
+ opacity: 1;
363
+ pointer-events: auto;
364
+ }
365
+
366
+ .result-close-btn {
367
+ position: absolute;
368
+ top: 15px;
369
+ right: 15px;
370
+ background: #f7fafc;
371
+ border: none;
372
+ color: #718096;
373
+ font-size: 28px;
374
+ cursor: pointer;
375
+ width: 35px;
376
+ height: 35px;
377
+ display: flex;
378
+ align-items: center;
379
+ justify-content: center;
380
+ border-radius: 50%;
381
+ transition: all 0.3s ease;
382
+ font-weight: 300;
383
+ }
384
+
385
+ .result-close-btn:hover {
386
+ background: #e2e8f0;
387
+ color: #2d3748;
388
+ transform: rotate(90deg);
389
  }
390
 
391
  .result-card {
 
428
  }
429
 
430
  .result-value {
431
+ font-size: 48px;
432
  font-weight: 700;
433
  background: linear-gradient(135deg, #667eea, #764ba2);
434
  -webkit-background-clip: text;
435
  -webkit-text-fill-color: transparent;
436
  background-clip: text;
437
+ margin-bottom: 20px;
438
  }
439
 
440
  .result-description {
441
  color: #718096;
442
+ font-size: 15px;
443
+ line-height: 1.6;
444
+ margin-bottom: 20px;
445
+ }
446
+
447
+ /* Health Meter */
448
+ .health-meter-container {
449
+ margin: 25px 0;
450
+ padding: 20px;
451
+ background: #f7fafc;
452
+ border-radius: 12px;
453
+ }
454
+
455
+ .meter-label {
456
+ font-size: 14px;
457
+ color: #4a5568;
458
+ font-weight: 600;
459
+ margin-bottom: 12px;
460
+ text-align: left;
461
+ }
462
+
463
+ .meter-wrapper {
464
+ position: relative;
465
+ width: 100%;
466
+ height: 30px;
467
+ background: #e2e8f0;
468
+ border-radius: 15px;
469
+ overflow: hidden;
470
+ box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
471
+ }
472
+
473
+ .meter-fill {
474
+ height: 100%;
475
+ width: 0%;
476
+ background: linear-gradient(90deg, #e53e3e, #ed8936, #ecc94b, #48bb78, #38b2ac);
477
+ border-radius: 15px;
478
+ transition: width 2s cubic-bezier(0.4, 0, 0.2, 1);
479
+ position: relative;
480
+ overflow: hidden;
481
+ }
482
+
483
+ .meter-fill::after {
484
+ content: '';
485
+ position: absolute;
486
+ top: 0;
487
+ left: 0;
488
+ width: 100%;
489
+ height: 100%;
490
+ background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
491
+ animation: shimmer 2s infinite;
492
+ }
493
+
494
+ @keyframes shimmer {
495
+ 0% { transform: translateX(-100%); }
496
+ 100% { transform: translateX(100%); }
497
+ }
498
+
499
+ .meter-percentage {
500
+ position: absolute;
501
+ top: 50%;
502
+ left: 50%;
503
+ transform: translate(-50%, -50%);
504
  font-size: 14px;
505
+ font-weight: 700;
506
+ color: #2d3748;
507
+ text-shadow: 0 1px 2px rgba(255,255,255,0.8);
508
+ }
509
+
510
+ /* Improvement Tips */
511
+ .improvement-tips {
512
+ margin-top: 25px;
513
+ padding: 20px;
514
+ background: linear-gradient(135deg, #f0f4ff, #e6f2ff);
515
+ border-radius: 12px;
516
+ border-left: 4px solid #667eea;
517
+ text-align: left;
518
+ }
519
+
520
+ .tips-header {
521
+ display: flex;
522
+ align-items: center;
523
+ gap: 8px;
524
+ font-size: 16px;
525
+ font-weight: 700;
526
+ color: #2d3748;
527
+ margin-bottom: 12px;
528
+ }
529
+
530
+ .tips-content {
531
+ color: #4a5568;
532
+ font-size: 14px;
533
+ line-height: 1.7;
534
+ }
535
+
536
+ .tips-content ul {
537
+ list-style: none;
538
+ padding: 0;
539
+ margin-top: 10px;
540
+ }
541
+
542
+ .tips-content li {
543
+ padding: 8px 0 8px 25px;
544
+ position: relative;
545
+ }
546
+
547
+ .tips-content li::before {
548
+ content: '💡';
549
+ position: absolute;
550
+ left: 0;
551
  }
552
 
553
  .wellness-indicator {
 
910
  </form>
911
 
912
  <div class="result" id="resultSection">
913
+ <button class="result-close-btn" onclick="closeResultWindow()">×</button>
914
  <div class="result-card">
915
  <div class="result-content">
916
  <div class="result-label">Mental Health Index</div>
917
+ <div class="result-value" id="resultValue">0.0%</div>
918
  <div class="result-description" id="resultDescription">
919
  Your personalized health score based on digital habits
920
  </div>
921
+
922
+ <!-- Health Meter -->
923
+ <div class="health-meter-container">
924
+ <div class="meter-label">Health Score Visualization</div>
925
+ <div class="meter-wrapper">
926
+ <div class="meter-fill" id="meterFill"></div>
927
+ <div class="meter-percentage" id="meterPercentage">0%</div>
928
+ </div>
929
+ </div>
930
+
931
  <div class="wellness-indicator">
932
  <div class="indicator-dot poor" data-range="0-25"></div>
933
  <div class="indicator-dot fair" data-range="25-50"></div>
934
  <div class="indicator-dot good" data-range="50-75"></div>
935
  <div class="indicator-dot excellent" data-range="75-100"></div>
936
  </div>
937
+
938
+ <!-- Improvement Tips -->
939
+ <div class="improvement-tips">
940
+ <div class="tips-header">
941
+ <span>🎯</span>
942
+ <span>How to Improve Your Mental Health</span>
943
+ </div>
944
+ <div class="tips-content" id="tipsContent">
945
+ <!-- Tips will be dynamically inserted here -->
946
+ </div>
947
+ </div>
948
  </div>
949
  </div>
950
  </div>
951
 
952
+ <!-- Result Overlay -->
953
+ <div class="result-overlay" id="resultOverlay" onclick="closeResultWindow()"></div>
954
+
955
  <!-- Copyright -->
956
  <div class="copyright">
957
  © 2025 Jobanpreet Singh. All rights reserved.
 
1054
  </div>
1055
 
1056
  <script>
1057
+ // Close Result Window
1058
+ function closeResultWindow() {
1059
+ document.getElementById('resultSection').classList.remove('show');
1060
+ document.getElementById('resultOverlay').classList.remove('show');
1061
+ }
1062
+
1063
  // Page Navigation
1064
  function showPage(pageName) {
1065
  // Hide all pages
 
1124
  return "Consider significant lifestyle adjustments for better mental health.";
1125
  }
1126
 
1127
+ function getImprovementTips(screenTime, sleepHours, workScreen, score) {
1128
+ let tips = [];
1129
+
1130
+ if (sleepHours < 7) {
1131
+ tips.push("Increase your sleep duration to 7-9 hours for optimal mental recovery");
1132
+ tips.push("Establish a consistent bedtime routine to improve sleep quality");
1133
+ } else if (sleepHours > 9) {
1134
+ tips.push("Consider reducing sleep duration to 7-9 hours for better energy levels");
1135
+ }
1136
+
1137
+ if (screenTime > 8) {
1138
+ tips.push("Reduce daily screen time by taking regular breaks (20-20-20 rule: every 20 minutes, look at something 20 feet away for 20 seconds)");
1139
+ tips.push("Set screen time limits and use apps to track your usage");
1140
+ }
1141
+
1142
+ const workScreenRatio = workScreen / screenTime;
1143
+ if (workScreenRatio > 0.7) {
1144
+ tips.push("Balance work screen time with recreational activities away from screens");
1145
+ tips.push("Take regular breaks during work hours to reduce digital fatigue");
1146
+ }
1147
+
1148
+ if (score < 80) {
1149
+ tips.push("Practice mindfulness or meditation for 10-15 minutes daily");
1150
+ tips.push("Engage in physical exercise for at least 30 minutes per day");
1151
+ tips.push("Spend time outdoors and in nature to reduce stress");
1152
+ }
1153
+
1154
+ if (tips.length === 0) {
1155
+ tips.push("Continue maintaining your excellent habits!");
1156
+ tips.push("Consider helping others improve their mental health awareness");
1157
+ }
1158
+
1159
+ return tips;
1160
+ }
1161
+
1162
  function updateWellnessIndicator(score) {
1163
  const dots = document.querySelectorAll('.indicator-dot');
1164
  dots.forEach(dot => dot.classList.remove('active'));
 
1175
  if (!startTimestamp) startTimestamp = timestamp;
1176
  const progress = Math.min((timestamp - startTimestamp) / duration, 1);
1177
  const value = progress * (end - start) + start;
1178
+ element.textContent = value.toFixed(1) + '%';
1179
  if (progress < 1) {
1180
  window.requestAnimationFrame(step);
1181
  }
 
1183
  window.requestAnimationFrame(step);
1184
  }
1185
 
1186
+ function animateMeter(percentage) {
1187
+ const meterFill = document.getElementById('meterFill');
1188
+ const meterPercentage = document.getElementById('meterPercentage');
1189
+
1190
+ setTimeout(() => {
1191
+ meterFill.style.width = percentage + '%';
1192
+
1193
+ let count = 0;
1194
+ const interval = setInterval(() => {
1195
+ count++;
1196
+ meterPercentage.textContent = Math.min(count, percentage).toFixed(0) + '%';
1197
+ if (count >= percentage) {
1198
+ clearInterval(interval);
1199
+ }
1200
+ }, 20);
1201
+ }, 300);
1202
+ }
1203
+
1204
  form.addEventListener('submit', async function(e) {
1205
  e.preventDefault();
1206
 
 
1223
 
1224
  const wellnessScore = calculateWellnessIndex(screenTime, sleepHours, workScreen);
1225
  const description = getWellnessDescription(wellnessScore);
1226
+ const tips = getImprovementTips(screenTime, sleepHours, workScreen, wellnessScore);
1227
 
1228
  // Show results with animation
1229
+ document.getElementById('resultOverlay').classList.add('show');
1230
  resultSection.classList.add('show');
1231
  resultDescription.textContent = description;
1232
 
1233
+ // Display improvement tips
1234
+ const tipsContent = document.getElementById('tipsContent');
1235
+ const tipsList = document.createElement('ul');
1236
+ tips.forEach(tip => {
1237
+ const li = document.createElement('li');
1238
+ li.textContent = tip;
1239
+ tipsList.appendChild(li);
1240
+ });
1241
+ tipsContent.innerHTML = '';
1242
+ tipsContent.appendChild(tipsList);
1243
+
1244
  // Animate the score counter
1245
  animateValue(resultValue, 0, wellnessScore, 1000);
1246
 
1247
+ // Animate the meter
1248
+ animateMeter(wellnessScore);
1249
+
1250
  // Update wellness indicator
1251
  setTimeout(() => updateWellnessIndicator(wellnessScore), 500);
1252