Spaces:
Running

xspace / index.html
onlyoneritz's picture
Update index.html
157d364 verified
Raw History Blame Contribute Delete
24.7 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Personality Insights | Discover Your True Self</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.question-card {
transition: all 0.3s ease;
transform-style: preserve-3d;
}
.flipped {
transform: rotateY(180deg);
}
.card-face {
backface-visibility: hidden;
position: absolute;
width: 100%;
height: 100%;
}
.card-back {
transform: rotateY(180deg);
}
.progress-bar {
transition: width 0.5s ease;
}
.option-btn:hover {
transform: translateY(-2px);
}
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
</style>
</head>
<body class="bg-gradient-to-br from-indigo-50 to-purple-50 min-h-screen font-sans">
<div class="container mx-auto px-4 py-8 max-w-4xl">
<!-- Header -->
<header class="text-center mb-12">
<h1 class="text-4xl font-bold text-indigo-800 mb-2">Personality Insights</h1>
<p class="text-lg text-gray-600">Discover your unique personality traits through our scientifically-backed assessment</p>
</header>
<!-- Main App Container -->
<div id="app" class="bg-white rounded-xl shadow-xl overflow-hidden">
<!-- Welcome Screen -->
<div id="welcome-screen" class="p-8 text-center fade-in">
<div class="w-32 h-32 mx-auto mb-6 bg-indigo-100 rounded-full flex items-center justify-center">
<i class="fas fa-user-astronaut text-6xl text-indigo-500"></i>
</div>
<h2 class="text-2xl font-semibold text-gray-800 mb-4">Ready to Discover Your Personality?</h2>
<p class="text-gray-600 mb-8 max-w-md mx-auto">
This assessment will ask you 15 questions about your preferences and behaviors.
Answer honestly to get the most accurate results.
</p>
<button id="start-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-3 px-8 rounded-full transition-all transform hover:scale-105 shadow-md">
Start Assessment
</button>
<div class="mt-6 text-sm text-gray-500">
<i class="fas fa-lock mr-1"></i> Your responses are completely anonymous
</div>
</div>
<!-- Assessment Screen -->
<div id="assessment-screen" class="hidden">
<!-- Progress Bar -->
<div class="bg-gray-100 h-2">
<div id="progress-bar" class="progress-bar bg-gradient-to-r from-indigo-400 to-purple-500 h-full" style="width: 0%"></div>
</div>
<!-- Question Container -->
<div class="p-8">
<div class="relative h-64 mb-8">
<!-- Question Card -->
<div id="question-card" class="question-card w-full h-full bg-white rounded-lg shadow-md p-6 relative">
<!-- Front of Card (Question) -->
<div class="card-face flex flex-col">
<div class="flex justify-between items-start mb-6">
<span id="question-number" class="text-sm font-medium text-indigo-600 bg-indigo-50 px-3 py-1 rounded-full">Question 1 of 15</span>
<button id="flip-btn" class="text-gray-400 hover:text-indigo-500">
<i class="fas fa-info-circle"></i>
</button>
</div>
<h3 id="question-text" class="text-xl font-medium text-gray-800 mb-6 flex-grow">Loading question...</h3>
<div class="grid grid-cols-2 gap-4">
<button class="option-btn bg-indigo-50 hover:bg-indigo-100 text-indigo-700 font-medium py-3 px-4 rounded-lg transition-all" data-value="1">
Strongly Disagree
</button>
<button class="option-btn bg-indigo-50 hover:bg-indigo-100 text-indigo-700 font-medium py-3 px-4 rounded-lg transition-all" data-value="2">
Disagree
</button>
<button class="option-btn bg-indigo-50 hover:bg-indigo-100 text-indigo-700 font-medium py-3 px-4 rounded-lg transition-all" data-value="3">
Neutral
</button>
<button class="option-btn bg-indigo-50 hover:bg-indigo-100 text-indigo-700 font-medium py-3 px-4 rounded-lg transition-all" data-value="4">
Agree
</button>
<button class="option-btn bg-indigo-50 hover:bg-indigo-100 text-indigo-700 font-medium py-3 px-4 rounded-lg transition-all" data-value="5">
Strongly Agree
</button>
</div>
</div>
<!-- Back of Card (Explanation) -->
<div class="card-face card-back bg-indigo-50 p-6">
<div class="flex justify-between items-start mb-4">
<span class="text-sm font-medium text-indigo-600 bg-white px-3 py-1 rounded-full">Why we ask this</span>
<button id="flip-back-btn" class="text-gray-400 hover:text-indigo-500">
<i class="fas fa-times"></i>
</button>
</div>
<p id="question-explanation" class="text-gray-700">
This question helps us understand your behavioral tendencies in social situations.
There are no right or wrong answers - we're just trying to understand your natural inclinations.
</p>
</div>
</div>
</div>
<!-- Navigation -->
<div class="flex justify-between items-center">
<button id="prev-btn" class="text-gray-500 hover:text-indigo-600 font-medium py-2 px-4 rounded-lg disabled:opacity-50" disabled>
<i class="fas fa-arrow-left mr-2"></i> Previous
</button>
<button id="next-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-6 rounded-lg disabled:opacity-50" disabled>
Next <i class="fas fa-arrow-right ml-2"></i>
</button>
</div>
</div>
</div>
<!-- Results Screen -->
<div id="results-screen" class="hidden p-8 text-center">
<div class="w-32 h-32 mx-auto mb-6 bg-green-100 rounded-full flex items-center justify-center">
<i class="fas fa-chart-pie text-6xl text-green-500"></i>
</div>
<h2 class="text-2xl font-semibold text-gray-800 mb-4">Your Personality Results</h2>
<div id="results-container" class="mt-8 grid md:grid-cols-2 gap-6 text-left">
<!-- Results will be inserted here by JavaScript -->
</div>
<div class="mt-10">
<button id="restart-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-3 px-8 rounded-full transition-all transform hover:scale-105 shadow-md mr-4">
Take Again
</button>
<button id="share-btn" class="bg-white border border-indigo-200 hover:bg-indigo-50 text-indigo-600 font-medium py-3 px-8 rounded-full transition-all transform hover:scale-105 shadow-md">
<i class="fas fa-share-alt mr-2"></i> Share Results
</button>
</div>
</div>
</div>
<!-- Footer -->
<footer class="mt-12 text-center text-sm text-gray-500">
<p>© 2023 Personality Insights. All rights reserved.</p>
<p class="mt-1">This assessment is based on the Big Five personality traits model.</p>
</footer>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// DOM Elements
const welcomeScreen = document.getElementById('welcome-screen');
const assessmentScreen = document.getElementById('assessment-screen');
const resultsScreen = document.getElementById('results-screen');
const startBtn = document.getElementById('start-btn');
const prevBtn = document.getElementById('prev-btn');
const nextBtn = document.getElementById('next-btn');
const flipBtn = document.getElementById('flip-btn');
const flipBackBtn = document.getElementById('flip-back-btn');
const questionCard = document.getElementById('question-card');
const questionText = document.getElementById('question-text');
const questionExplanation = document.getElementById('question-explanation');
const questionNumber = document.getElementById('question-number');
const progressBar = document.getElementById('progress-bar');
const resultsContainer = document.getElementById('results-container');
const restartBtn = document.getElementById('restart-btn');
const shareBtn = document.getElementById('share-btn');
const optionBtns = document.querySelectorAll('.option-btn');
// Assessment Data
const questions = [
{
text: "I am the life of the party.",
explanation: "This question measures your level of extraversion. People who enjoy being the center of attention tend to score higher on extraversion.",
trait: "extraversion"
},
{
text: "I sympathize with others' feelings.",
explanation: "This helps assess your level of agreeableness, which relates to how compassionate and cooperative you are with others.",
trait: "agreeableness"
},
{
text: "I get chores done right away.",
explanation: "This evaluates your conscientiousness, indicating how disciplined and organized you tend to be.",
trait: "conscientiousness"
},
{
text: "I have frequent mood swings.",
explanation: "This question measures emotional stability (neuroticism), showing how easily you experience negative emotions.",
trait: "neuroticism"
},
{
text: "I have a vivid imagination.",
explanation: "This assesses openness to experience, which relates to your creativity and appreciation for new ideas.",
trait: "openness"
},
{
text: "I don't talk a lot.",
explanation: "Another measure of extraversion, with quiet people typically scoring lower on this trait.",
trait: "extraversion"
},
{
text: "I am interested in people.",
explanation: "This helps determine your level of agreeableness and social interest.",
trait: "agreeableness"
},
{
text: "I pay attention to details.",
explanation: "A measure of conscientiousness, showing how careful and precise you are.",
trait: "conscientiousness"
},
{
text: "I get stressed out easily.",
explanation: "This indicates emotional stability (neuroticism), with higher scores meaning more stress sensitivity.",
trait: "neuroticism"
},
{
text: "I have excellent ideas.",
explanation: "Another measure of openness to experience and creative thinking.",
trait: "openness"
},
{
text: "I feel comfortable around people.",
explanation: "This evaluates your comfort level in social situations, relating to extraversion.",
trait: "extraversion"
},
{
text: "I insult people.",
explanation: "A reverse-coded question for agreeableness, with disagreeing indicating higher agreeableness.",
trait: "agreeableness"
},
{
text: "I like order.",
explanation: "This measures your preference for structure and organization (conscientiousness).",
trait: "conscientiousness"
},
{
text: "I worry about things.",
explanation: "An indicator of emotional stability (neuroticism), with agreement suggesting higher neuroticism.",
trait: "neuroticism"
},
{
text: "I am full of ideas.",
explanation: "This final question assesses your openness to experience and creativity.",
trait: "openness"
}
];
// App State
let currentQuestion = 0;
let answers = Array(questions.length).fill(null);
let traitScores = {
extraversion: 0,
agreeableness: 0,
conscientiousness: 0,
neuroticism: 0,
openness: 0
};
let questionsPerTrait = {
extraversion: 0,
agreeableness: 0,
conscientiousness: 0,
neuroticism: 0,
openness: 0
};
// Count questions per trait
questions.forEach(q => {
questionsPerTrait[q.trait]++;
});
// Event Listeners
startBtn.addEventListener('click', startAssessment);
prevBtn.addEventListener('click', showPreviousQuestion);
nextBtn.addEventListener('click', showNextQuestion);
flipBtn.addEventListener('click', flipCard);
flipBackBtn.addEventListener('click', flipCard);
restartBtn.addEventListener('click', restartAssessment);
shareBtn.addEventListener('click', shareResults);
optionBtns.forEach(btn => {
btn.addEventListener('click', function() {
selectOption(this);
});
});
// Functions
function startAssessment() {
welcomeScreen.classList.add('hidden');
assessmentScreen.classList.remove('hidden');
updateQuestion();
}
function updateQuestion() {
const question = questions[currentQuestion];
questionText.textContent = question.text;
questionExplanation.textContent = question.explanation;
questionNumber.textContent = `Question ${currentQuestion + 1} of ${questions.length}`;
// Update progress bar
const progress = ((currentQuestion + 1) / questions.length) * 100;
progressBar.style.width = `${progress}%`;
// Update navigation buttons
prevBtn.disabled = currentQuestion === 0;
nextBtn.disabled = answers[currentQuestion] === null;
// Update selected option
optionBtns.forEach(btn => {
if (parseInt(btn.dataset.value) === answers[currentQuestion]) {
btn.classList.add('bg-indigo-200', 'text-indigo-800');
btn.classList.remove('bg-indigo-50');
} else {
btn.classList.remove('bg-indigo-200', 'text-indigo-800');
btn.classList.add('bg-indigo-50');
}
});
}
function showPreviousQuestion() {
if (currentQuestion > 0) {
currentQuestion--;
updateQuestion();
}
}
function showNextQuestion() {
if (answers[currentQuestion] !== null) {
if (currentQuestion < questions.length - 1) {
currentQuestion++;
updateQuestion();
} else {
calculateResults();
showResults();
}
}
}
function selectOption(selectedBtn) {
const selectedValue = parseInt(selectedBtn.dataset.value);
answers[currentQuestion] = selectedValue;
// Update UI for selected option
optionBtns.forEach(btn => {
if (parseInt(btn.dataset.value) === selectedValue) {
btn.classList.add('bg-indigo-200', 'text-indigo-800');
btn.classList.remove('bg-indigo-50');
} else {
btn.classList.remove('bg-indigo-200', 'text-indigo-800');
btn.classList.add('bg-indigo-50');
}
});
nextBtn.disabled = false;
}
function flipCard() {
questionCard.classList.toggle('flipped');
}
function calculateResults() {
// Reset scores
Object.keys(traitScores).forEach(trait => {
traitScores[trait] = 0;
});
// Calculate scores for each trait
questions.forEach((q, index) => {
// For reverse-coded questions (like "I insult people")
const isReverseCoded = q.text.includes("insult") || q.text.includes("don't talk");
const answerValue = isReverseCoded ? (6 - answers[index]) : answers[index];
traitScores[q.trait] += answerValue;
});
// Calculate average scores per trait
Object.keys(traitScores).forEach(trait => {
traitScores[trait] = Math.round((traitScores[trait] / questionsPerTrait[trait]) * 10) / 10;
});
}
function showResults() {
assessmentScreen.classList.add('hidden');
resultsScreen.classList.remove('hidden');
// Clear previous results
resultsContainer.innerHTML = '';
// Display results for each trait
const traitNames = {
extraversion: "Extraversion",
agreeableness: "Agreeableness",
conscientiousness: "Conscientiousness",
neuroticism: "Neuroticism",
openness: "Openness"
};
const traitDescriptions = {
extraversion: "How outgoing, energetic and talkative you are. High scorers enjoy socializing, while low scorers prefer solitude.",
agreeableness: "How compassionate, cooperative and trusting you are. High scorers are more altruistic, while low scorers are more competitive.",
conscientiousness: "How organized, disciplined and dependable you are. High scorers are careful and detail-oriented, while low scorers are more spontaneous.",
neuroticism: "How sensitive you are to stress and negative emotions. High scorers experience more anxiety, while low scorers are more emotionally stable.",
openness: "How curious, creative and open to new experiences you are. High scorers enjoy novelty, while low scorers prefer routine."
};
const traitIcons = {
extraversion: "fa-users",
agreeableness: "fa-handshake",
conscientiousness: "fa-clipboard-check",
neuroticism: "fa-cloud-rain",
openness: "fa-lightbulb"
};
const traitColors = {
extraversion: "bg-blue-100 text-blue-800",
agreeableness: "bg-green-100 text-green-800",
conscientiousness: "bg-yellow-100 text-yellow-800",
neuroticism: "bg-red-100 text-red-800",
openness: "bg-purple-100 text-purple-800"
};
for (const [trait, score] of Object.entries(traitScores)) {
const resultCard = document.createElement('div');
resultCard.className = 'bg-white rounded-lg shadow-md p-6 border-l-4 border-indigo-200';
const scorePercentage = Math.min(Math.max((score - 1) / 4 * 100, 0), 100);
const colorClass = score >= 3.5 ? 'bg-green-500' : score >= 2.5 ? 'bg-yellow-500' : 'bg-red-500';
resultCard.innerHTML = `
<div class="flex items-center mb-4">
<div class="w-12 h-12 rounded-full ${traitColors[trait]} flex items-center justify-center mr-4">
<i class="fas ${traitIcons[trait]} text-xl"></i>
</div>
<div>
<h3 class="font-semibold text-lg text-gray-800">${traitNames[trait]}</h3>
<p class="text-sm text-gray-500">Score: ${score}/5</p>
</div>
</div>
<p class="text-gray-600 text-sm mb-4">${traitDescriptions[trait]}</p>
<div class="w-full bg-gray-200 rounded-full h-2.5 mb-2">
<div class="h-2.5 rounded-full ${colorClass}" style="width: ${scorePercentage}%"></div>
</div>
<div class="flex justify-between text-xs text-gray-500">
<span>Low</span>
<span>Moderate</span>
<span>High</span>
</div>
`;
resultsContainer.appendChild(resultCard);
}
}
function restartAssessment() {
currentQuestion = 0;
answers = Array(questions.length).fill(null);
resultsScreen.classList.add('hidden');
welcomeScreen.classList.remove('hidden');
}
function shareResults() {
// In a real app, this would share to social media or copy to clipboard
alert("Results sharing feature would be implemented here. In a real app, this would allow sharing to social media or copying to clipboard.");
}
});
</script>
</html>