Hawkwind commited on
Commit
93ded9d
·
verified ·
1 Parent(s): 4bbba18

Add 1 files

Browse files
Files changed (1) hide show
  1. index.html +103 -0
index.html CHANGED
@@ -449,5 +449,108 @@
449
  // Reset scores
450
  scores = { E: 0, I: 0, S: 0, N: 0, T: 0, F: 0, J: 0, P: 0 };
451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
 
 
 
 
 
 
 
453
  </html>
 
449
  // Reset scores
450
  scores = { E: 0, I: 0, S: 0, N: 0, T: 0, F: 0, J: 0, P: 0 };
451
 
452
+ // Calculate scores for each dimension
453
+ questions.forEach((question, index) => {
454
+ const answerIndex = answers[index];
455
+ if (answerIndex === undefined) return;
456
+
457
+ const weight = question.weights[answerIndex];
458
+
459
+ switch(question.dimension) {
460
+ case "E/I":
461
+ weight > 0 ? scores.E++ : scores.I++;
462
+ break;
463
+ case "S/N":
464
+ weight > 0 ? scores.S++ : scores.N++;
465
+ break;
466
+ case "T/F":
467
+ weight > 0 ? scores.T++ : scores.F++;
468
+ break;
469
+ case "J/P":
470
+ weight > 0 ? scores.J++ : scores.P++;
471
+ break;
472
+ }
473
+ });
474
+
475
+ // Determine MBTI type
476
+ const type = [
477
+ scores.E >= scores.I ? "E" : "I",
478
+ scores.S >= scores.N ? "S" : "N",
479
+ scores.T >= scores.F ? "T" : "F",
480
+ scores.J >= scores.P ? "J" : "P"
481
+ ].join("");
482
+
483
+ return {
484
+ type: type,
485
+ scores: scores
486
+ };
487
+ }
488
+
489
+ // Show results
490
+ function showResults() {
491
+ const results = calculateResults();
492
+
493
+ // Display MBTI type
494
+ mbtiType.textContent = results.type;
495
+
496
+ // Calculate and display dimension percentages
497
+ const totalEI = scores.E + scores.I;
498
+ const totalSN = scores.S + scores.N;
499
+ const totalTF = scores.T + scores.F;
500
+ const totalJP = scores.J + scores.P;
501
+
502
+ const ePercent = Math.round((scores.E / totalEI) * 100);
503
+ const sPercent = Math.round((scores.S / totalSN) * 100);
504
+ const tPercent = Math.round((scores.T / totalTF) * 100);
505
+ const jPercent = Math.round((scores.J / totalJP) * 100);
506
+
507
+ eiBar.style.width = `${ePercent}%`;
508
+ snBar.style.width = `${sPercent}%`;
509
+ tfBar.style.width = `${tPercent}%`;
510
+ jpBar.style.width = `${jPercent}%`;
511
+
512
+ eiScore.textContent = `${ePercent}% / ${100 - ePercent}%`;
513
+ snScore.textContent = `${sPercent}% / ${100 - sPercent}%`;
514
+ tfScore.textContent = `${tPercent}% / ${100 - tPercent}%`;
515
+ jpScore.textContent = `${jPercent}% / ${100 - jPercent}%`;
516
+
517
+ // Show results screen
518
+ questionScreen.classList.add('hidden');
519
+ resultsScreen.classList.remove('hidden');
520
+ }
521
+
522
+ // Event listeners
523
+ startBtn.addEventListener('click', () => {
524
+ welcomeScreen.classList.add('hidden');
525
+ questionScreen.classList.remove('hidden');
526
+ initTest();
527
+ });
528
+
529
+ nextBtn.addEventListener('click', () => {
530
+ if (currentQuestion < questions.length - 1) {
531
+ currentQuestion++;
532
+ showQuestion();
533
+ } else {
534
+ showResults();
535
+ }
536
+ });
537
+
538
+ prevBtn.addEventListener('click', () => {
539
+ if (currentQuestion > 0) {
540
+ currentQuestion--;
541
+ showQuestion();
542
+ }
543
+ });
544
+
545
+ retakeBtn.addEventListener('click', () => {
546
+ resultsScreen.classList.add('hidden');
547
+ welcomeScreen.classList.remove('hidden');
548
+ });
549
 
550
+ learnMoreBtn.addEventListener('click', () => {
551
+ // This would link to more detailed information about the MBTI type
552
+ alert("This would link to more detailed information about your MBTI type in a real implementation.");
553
+ });
554
+ </script>
555
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Hawkwind/quick-mbti-test" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
556
  </html>