Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Numerology Calculator #1733

Merged
merged 13 commits into from
Aug 3, 2024
19 changes: 19 additions & 0 deletions Calculators/Numerology-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# <p align="center">Numerology Calculator</p>

## Description :-

A Numerology Calculator helps users discover their core numerology numbers based on their birth date and full name. These numbers can provide insights into personality traits, life purpose, and potential future outcomes.


## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

![image](https://github.com/user-attachments/assets/e8da02e5-24d3-456c-9371-9115b510ecf9)
![image](https://github.com/user-attachments/assets/18c60ada-2de8-4fcb-b843-4d944044231c)


76 changes: 76 additions & 0 deletions Calculators/Numerology-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Numerology Calculator</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Numerology Calculator</h1>
<form id="numerologyForm">
<div class="form-group">
<label for="fullName">Full Name:</label>
<input type="text" id="fullName" required>
<span id="nameError" class="error-message"></span>
</div>

<div class="form-group">
<label for="birthDate">Birth Date:</label>
<input type="date" id="birthDate" required>
<span id="dateError" class="error-message"></span>
</div>

<button type="button" onclick="validateForm()">Calculate</button>
</form>

<div id="results" class="hidden">
<h2>Results</h2>
<div class="result">
<h3>Life Path Number</h3>
<p id="lifePathNumber"></p>
<p id="lifePathDescription"></p>
</div>
<div class="result">
<h3>Expression Number</h3>
<p id="expressionNumber"></p>
<p id="expressionDescription"></p>
</div>
<div class="result">
<h3>Soul Urge Number</h3>
<p id="soulUrgeNumber"></p>
<p id="soulUrgeDescription"></p>
</div>
<div class="result">
<h3>Personality Number</h3>
<p id="personalityNumber"></p>
<p id="personalityDescription"></p>
</div>
<button onclick="downloadReport()">Download Report</button>
</div>

<div id="compatibility" class="hidden">
<h2>Compatibility Analysis</h2>
<form id="compatibilityForm">
<div class="form-group">
<label for="partnerFullName">Partner's Full Name:</label>
<input type="text" id="partnerFullName">
</div>

<div class="form-group">
<label for="partnerBirthDate">Partner's Birth Date:</label>
<input type="date" id="partnerBirthDate">
</div>

<button type="button" onclick="calculateCompatibility()">Check Compatibility</button>
</form>
<div id="compatibilityResults" class="hidden">
<p id="compatibilityDescription"></p>
</div>
</div>
</div>

<script src="script.js"></script>
</body>
</html>
181 changes: 181 additions & 0 deletions Calculators/Numerology-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
// Function to validate form inputs
function validateForm() {
const fullName = document.getElementById('fullName').value.trim();
const birthDate = document.getElementById('birthDate').value;

const nameError = document.getElementById('nameError');
const dateError = document.getElementById('dateError');

nameError.style.display = 'none';
dateError.style.display = 'none';

let isValid = true;

if (fullName === '') {
nameError.textContent = 'Full name is required.';
nameError.style.display = 'block';
isValid = false;
} else if (!/^[a-zA-Z\s]+$/.test(fullName)) {
nameError.textContent = 'Full name can only contain letters and spaces.';
nameError.style.display = 'block';
isValid = false;
}

if (birthDate === '') {
dateError.textContent = 'Birth date is required.';
dateError.style.display = 'block';
isValid = false;
}

if (isValid) {
calculateNumerology(fullName, birthDate);
}
}

// Function to calculate numerology numbers
function calculateNumerology(fullName, birthDate) {
const lifePathNumber = calculateLifePathNumber(birthDate);
const expressionNumber = calculateExpressionNumber(fullName);
const soulUrgeNumber = calculateSoulUrgeNumber(fullName);
const personalityNumber = calculatePersonalityNumber(fullName);

document.getElementById('lifePathNumber').textContent = `Life Path Number: ${lifePathNumber}`;
document.getElementById('expressionNumber').textContent = `Expression Number: ${expressionNumber}`;
document.getElementById('soulUrgeNumber').textContent = `Soul Urge Number: ${soulUrgeNumber}`;
document.getElementById('personalityNumber').textContent = `Personality Number: ${personalityNumber}`;

document.getElementById('results').classList.remove('hidden');

document.getElementById('lifePathDescription').textContent = getLifePathDescription(lifePathNumber);
document.getElementById('expressionDescription').textContent = getExpressionDescription(expressionNumber);
document.getElementById('soulUrgeDescription').textContent = getSoulUrgeDescription(soulUrgeNumber);
document.getElementById('personalityDescription').textContent = getPersonalityDescription(personalityNumber);
}

// Helper function to reduce numbers to a single digit
function reduceToSingleDigit(number) {
while (number > 9 && number !== 11 && number !== 22 && number !== 33) {
number = number.toString().split('').reduce((sum, num) => sum + parseInt(num), 0);
}
return number;
}

// Function to calculate Life Path Number
function calculateLifePathNumber(birthDate) {
const dateNumbers = birthDate.replace(/-/g, '').split('');
const sum = dateNumbers.reduce((acc, num) => acc + parseInt(num), 0);
return reduceToSingleDigit(sum);
}

// Function to calculate Expression Number
function calculateExpressionNumber(fullName) {
const nameNumbers = fullName.toUpperCase().replace(/[^A-Z]/g, '').split('').map(letter => letter.charCodeAt(0) - 64);
const sum = nameNumbers.reduce((acc, num) => acc + num, 0);
return reduceToSingleDigit(sum);
}

// Function to calculate Soul Urge Number
function calculateSoulUrgeNumber(fullName) {
const vowels = ['A', 'E', 'I', 'O', 'U'];
const vowelNumbers = fullName.toUpperCase().replace(/[^A-Z]/g, '').split('').filter(letter => vowels.includes(letter)).map(letter => letter.charCodeAt(0) - 64);
const sum = vowelNumbers.reduce((acc, num) => acc + num, 0);
return reduceToSingleDigit(sum);
}

// Function to calculate Personality Number
function calculatePersonalityNumber(fullName) {
const vowels = ['A', 'E', 'I', 'O', 'U'];
const consonantNumbers = fullName.toUpperCase().replace(/[^A-Z]/g, '').split('').filter(letter => !vowels.includes(letter)).map(letter => letter.charCodeAt(0) - 64);
const sum = consonantNumbers.reduce((acc, num) => acc + num, 0);
return reduceToSingleDigit(sum);
}

// Placeholder functions for descriptions
function getLifePathDescription(number) {
const descriptions = {
1: "Leader, independent, pioneering.",
2: "Diplomatic, sensitive, cooperative.",
3: "Creative, expressive, sociable.",
4: "Practical, disciplined, reliable.",
5: "Adventurous, dynamic, freedom-loving.",
6: "Responsible, caring, nurturing.",
7: "Analytical, introspective, spiritual.",
8: "Ambitious, authoritative, efficient.",
9: "Compassionate, humanitarian, idealistic.",
11: "Visionary, intuitive, inspiring.",
22: "Master builder, practical visionary.",
33: "Master teacher, compassionate, healer."
};
return descriptions[number] || "Unique and special qualities.";
}

function getExpressionDescription(number) {
// Add descriptions for each Expression Number
// Example:
return `Expression Number ${number}: This number signifies the talents, abilities, and shortcomings that you bring into this lifetime. It is derived from the name given to you at birth.`;
}

function getSoulUrgeDescription(number) {
// Add descriptions for each Soul Urge Number
// Example:
return `Soul Urge Number ${number}: This number reveals your innermost desires, likes, and dislikes. It is derived from the vowels in your full name.`;
}

function getPersonalityDescription(number) {
// Add descriptions for each Personality Number
// Example:
return `Personality Number ${number}: This number indicates how others perceive you. It is derived from the consonants in your full name.`;
}

// Function to download the report
function downloadReport() {
const lifePathNumber = document.getElementById('lifePathNumber').textContent;
const expressionNumber = document.getElementById('expressionNumber').textContent;
const soulUrgeNumber = document.getElementById('soulUrgeNumber').textContent;
const personalityNumber = document.getElementById('personalityNumber').textContent;

const reportContent = `
Numerology Report
-----------------
${lifePathNumber}
${expressionNumber}
${soulUrgeNumber}
${personalityNumber}
`;

const blob = new Blob([reportContent], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'Numerology_Report.txt';
link.click();
URL.revokeObjectURL(url);
}

// Function to calculate compatibility
function calculateCompatibility() {
const partnerFullName = document.getElementById('partnerFullName').value.trim();
const partnerBirthDate = document.getElementById('partnerBirthDate').value;

if (partnerFullName === '' || partnerBirthDate === '') {
return;
}

const partnerLifePathNumber = calculateLifePathNumber(partnerBirthDate);
const partnerExpressionNumber = calculateExpressionNumber(partnerFullName);

const userLifePathNumber = parseInt(document.getElementById('lifePathNumber').textContent.split(': ')[1]);
const userExpressionNumber = parseInt(document.getElementById('expressionNumber').textContent.split(': ')[1]);

let compatibilityMessage = 'Compatibility Analysis:\n';
compatibilityMessage += `Your Life Path Number: ${userLifePathNumber}\n`;
compatibilityMessage += `Partner's Life Path Number: ${partnerLifePathNumber}\n`;
compatibilityMessage += `Your Expression Number: ${userExpressionNumber}\n`;
compatibilityMessage += `Partner's Expression Number: ${partnerExpressionNumber}\n`;

// Add your compatibility logic here
compatibilityMessage += `You and your partner have a strong potential for a harmonious relationship.`;

document.getElementById('compatibilityResults').classList.remove('hidden');
document.getElementById('compatibilityDescription').textContent = compatibilityMessage;
}
69 changes: 69 additions & 0 deletions Calculators/Numerology-Calculator/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}

.container {
max-width: 700px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}

h1, h2 {
text-align: center;
}

.form-group {
margin-top: 10px;
}

label {
display: block;
margin-bottom: 5px;
}

input[type="text"], input[type="date"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
box-sizing: border-box;
}

button {
display: block;
width: 100%;
padding: 10px;
margin-top: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

.error-message {
color: red;
font-size: 0.875em;
display: none;
}

.hidden {
display: none;
}

.result {
margin-top: 20px;
}

.result h3 {
margin-bottom: 5px;
}
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,21 @@ <h3>Converts binary to decimal, octal, hexadecimal and vice versa.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Numerology Calculator</h2>
<h3>Discover your core numerology numbers and insights into personality, life purpose, and future outcomes.</h3>
<div class="card-footer">
<a href="./Calculators/Numerology-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/mahek0620/CalcDiverse/tree/Numerology/Calculators/Numerology-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>

<div class="box">
<div class="content">
<h2>Nutrition Calculator</h2>
Expand Down