-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
280 lines (240 loc) · 8.72 KB
/
script.js
File metadata and controls
280 lines (240 loc) · 8.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
document.addEventListener('DOMContentLoaded', () => {
console.log("Initializing mystical calculator...");
updateDateTime();
setInterval(updateDateTime, 1000);
setupEventListeners();
initializeFloatingElements();
});
function updateDateTime() {
const now = new Date();
const formatted = now.toISOString().replace('T', ' ').slice(0, 19);
document.getElementById('utcTime').textContent = formatted;
}
function setupEventListeners() {
const calculateBtn = document.getElementById('calculateBtn');
if (calculateBtn) {
calculateBtn.addEventListener('click', () => {
console.log("Calculate button clicked");
animateCalculation();
calculateNumerology();
});
} else {
console.error("Calculate button not found!");
}
}
function animateCalculation() {
const btn = document.getElementById('calculateBtn');
const btnText = btn.querySelector('.btn-text');
btn.disabled = true;
btnText.textContent = '✨ Consulting the Stars... ✨';
setTimeout(() => {
btn.disabled = false;
btnText.textContent = 'Reveal Your Destiny';
}, 2000);
}
// Fixed Numerology Calculations
function calculateDestinyNumber(name) {
console.log("Calculating destiny number for:", name);
const numerologyValue = {
'a': 1, 'j': 1, 's': 1,
'b': 2, 'k': 2, 't': 2,
'c': 3, 'l': 3, 'u': 3,
'd': 4, 'm': 4, 'v': 4,
'e': 5, 'n': 5, 'w': 5,
'f': 6, 'o': 6, 'x': 6,
'g': 7, 'p': 7, 'y': 7,
'h': 8, 'q': 8, 'z': 8,
'i': 9, 'r': 9
};
const cleanName = name.toLowerCase().replace(/[^a-z]/g, '');
let sum = 0;
for (let char of cleanName) {
sum += numerologyValue[char] || 0;
}
return reduceToSingleDigit(sum);
}
function calculateLifePathNumber(dateStr) {
console.log("Calculating life path number for:", dateStr);
const date = new Date(dateStr);
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();
const dayNum = reduceToSingleDigit(day);
const monthNum = reduceToSingleDigit(month);
const yearNum = reduceToSingleDigit(year);
return reduceToSingleDigit(dayNum + monthNum + yearNum);
}
function calculateSoulNumber(name) {
console.log("Calculating soul number for:", name);
const vowels = {'a': 1, 'e': 5, 'i': 9, 'o': 6, 'u': 3};
const cleanName = name.toLowerCase().replace(/[^a-z]/g, '');
let sum = 0;
for (let char of cleanName) {
if (vowels[char]) {
sum += vowels[char];
}
}
return reduceToSingleDigit(sum);
}
function reduceToSingleDigit(num) {
while (num > 9) {
num = String(num)
.split('')
.reduce((a, b) => parseInt(a) + parseInt(b), 0);
}
return num;
}
function animateNumber(elementId, finalNumber) {
const element = document.getElementById(elementId);
if (!element) {
console.error(`Element not found: ${elementId}`);
return;
}
const duration = 1500;
const steps = 20;
const stepDuration = duration / steps;
let currentStep = 0;
const interval = setInterval(() => {
if (currentStep === steps) {
clearInterval(interval);
element.textContent = finalNumber;
return;
}
const progress = currentStep / steps;
const currentNumber = Math.floor(finalNumber * progress);
element.textContent = currentNumber || '-';
currentStep++;
}, stepDuration);
}
function calculateNumerology() {
console.log("Starting numerology calculation...");
const fullName = document.getElementById('fullName').value.trim();
const birthDate = document.getElementById('birthDate').value;
if (!fullName || !birthDate) {
alert('✨ Please enter both your sacred name and star date ✨');
return;
}
// Show calculating state
const resultsSection = document.getElementById('results');
resultsSection.classList.remove('hidden');
try {
// Calculate numbers
const destinyNumber = calculateDestinyNumber(fullName);
const lifePathNumber = calculateLifePathNumber(birthDate);
const soulNumber = calculateSoulNumber(fullName);
console.log("Calculated numbers:", {
destiny: destinyNumber,
lifePath: lifePathNumber,
soul: soulNumber
});
// Animate numbers
animateNumber('destinyNumber', destinyNumber);
animateNumber('lifePathNumber', lifePathNumber);
animateNumber('soulNumber', soulNumber);
// Update meaning
updateNumerologyMeaning(destinyNumber, lifePathNumber, soulNumber);
// Show results with animation
resultsSection.style.opacity = '0';
resultsSection.classList.remove('hidden');
setTimeout(() => {
resultsSection.style.opacity = '1';
}, 100);
// Scroll to results
setTimeout(() => {
resultsSection.scrollIntoView({ behavior: 'smooth' });
}, 500);
} catch (error) {
console.error("Calculation error:", error);
alert('✨ The stars are misaligned. Please try again. ✨');
}
}
function initializeFloatingElements() {
const container = document.querySelector('.floating-elements');
if (!container) return;
// Create additional floating elements
for (let i = 0; i < 20; i++) {
const spirit = document.createElement('div');
spirit.className = 'spirit';
spirit.style.left = `${Math.random() * 100}%`;
spirit.style.top = `${Math.random() * 100}%`;
spirit.style.animationDelay = `${Math.random() * 4}s`;
spirit.textContent = Math.random() > 0.5 ? '✦' : '✧';
container.appendChild(spirit);
}
}
function updateNumerologyMeaning(destinyNumber, lifePathNumber, soulNumber) {
const meaningElement = document.getElementById('numerologyMeaning');
if (!meaningElement) return;
const meanings = {
1: {
destiny: "A natural leader and pioneer",
lifePath: "Independent and ambitious",
soul: "Creative and original"
},
2: {
destiny: "A diplomatic peacemaker",
lifePath: "Cooperative and sensitive",
soul: "Emotional and intuitive"
},
3: {
destiny: "A creative communicator",
lifePath: "Expressive and joyful",
soul: "Artistic and social"
},
4: {
destiny: "A practical builder",
lifePath: "Organized and reliable",
soul: "Stable and hardworking"
},
5: {
destiny: "An adventurous free spirit",
lifePath: "Versatile and progressive",
soul: "Freedom-loving and adaptable"
},
6: {
destiny: "A nurturing guardian",
lifePath: "Responsible and loving",
soul: "Harmonious and caring"
},
7: {
destiny: "A spiritual seeker",
lifePath: "Analytical and mystical",
soul: "Introspective and wise"
},
8: {
destiny: "A powerful achiever",
lifePath: "Ambitious and successful",
soul: "Material and influential"
},
9: {
destiny: "A humanitarian teacher",
lifePath: "Compassionate and wise",
soul: "Universal and giving"
}
};
const meaning = `
<div class="mystical-reading">
<p class="destiny-text">
✧ Your Destiny Number ${destinyNumber} reveals you as ${meanings[destinyNumber].destiny}.
The stars have aligned to guide you toward leadership and innovation.
</p>
<p class="life-path-text">
✧ Walking the Life Path of ${lifePathNumber}, you are ${meanings[lifePathNumber].lifePath}.
This path calls you to embrace change and growth.
</p>
<p class="soul-text">
✧ Your Soul Number ${soulNumber} whispers that you are ${meanings[soulNumber].soul}.
Your inner light shines with unique purpose.
</p>
<div class="synthesis">
<h4>✧ Mystical Synthesis ✧</h4>
<p>
The combination of these sacred numbers creates a unique cosmic signature.
Your destiny (${destinyNumber}) and life path (${lifePathNumber}) numbers dance together,
while your soul number (${soulNumber}) illuminates your inner truth.
</p>
</div>
</div>
`;
meaningElement.innerHTML = meaning;
}