Repository navigation
Expand file tree
/
Copy pathcode.js
More file actions
109 lines (96 loc) · 3.89 KB
/
Copy pathcode.js
File metadata and controls
109 lines (96 loc) · 3.89 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
// script.js
document.addEventListener('DOMContentLoaded', () => {
// --- IMPORTANT: CONFIGURE THESE TWO VARIABLES ---
const EMAIL_FORM_ENDPOINT = 'YOUR_EMAIL_MARKETING_SERVICE_FORM_ENDPOINT_HERE';
const AFFILIATE_REDIRECT_URL = 'https://YOUR_CLICKBANK_AFFILIATE_LINK_HERE';
// ------------------------------------------------
const slides = document.querySelectorAll('.slide');
let currentSlideIndex = 0;
const userData = {};
function showSlide(index) {
slides.forEach((slide, i) => {
slide.classList.toggle('active', i === index);
});
}
// --- Event Listeners for Buttons ---
document.querySelectorAll('.next-btn, .option-btn, .icon-option').forEach(btn => {
btn.addEventListener('click', (e) => {
// Store data if available
const slideId = e.currentTarget.closest('.slide').id;
const value = e.currentTarget.dataset.value;
if (value) {
userData[slideId] = value;
}
if (e.currentTarget.classList.contains('icon-option')) {
document.querySelectorAll('.icon-option').forEach(opt => opt.classList.remove('selected'));
e.currentTarget.classList.add('selected');
}
// Go to the next slide after a short delay for animations
setTimeout(() => {
currentSlideIndex++;
showSlide(currentSlideIndex);
}, 200);
});
});
// --- Specific Logic for Date Input ---
document.getElementById('birthdate-next').addEventListener('click', () => {
const birthdate = document.getElementById('birthdate-input').value;
if (birthdate) {
userData['birthdate'] = birthdate;
currentSlideIndex++;
showSlide(currentSlideIndex);
} else {
alert('Please select your birth date.');
}
});
// --- Logic for Email Form Submission ---
const emailForm = document.getElementById('email-form');
emailForm.addEventListener('submit', (e) => {
e.preventDefault();
const formData = new FormData(emailForm);
const firstName = formData.get('first_name');
userData['firstName'] = firstName;
userData['email'] = formData.get('email');
// Post data to your email service
fetch(EMAIL_FORM_ENDPOINT, {
method: 'POST',
body: formData,
mode: 'no-cors' // Use 'no-cors' if submitting to a simple form endpoint that might block cross-origin requests.
}).catch(error => console.error('Error:', error));
// Transition to loading screen
currentSlideIndex++;
showSlide(currentSlideIndex);
startLoadingSequence();
});
// --- Loading and Redirect Sequence ---
function startLoadingSequence() {
const loadingText = document.getElementById('loading-text');
setTimeout(() => {
loadingText.textContent = 'Analyzing your planetary alignments...';
}, 1500);
setTimeout(() => {
loadingText.textContent = 'Decoding your unique karmic path...';
}, 3000);
setTimeout(() => {
// Move to the final redirect slide
currentSlideIndex++;
showSlide(currentSlideIndex);
document.getElementById('user-name').textContent = userData.firstName || 'friend';
startCountdown();
}, 4500);
}
function startCountdown() {
let count = 5;
const countdownElement = document.getElementById('countdown');
const interval = setInterval(() => {
count--;
countdownElement.textContent = count;
if (count <= 0) {
clearInterval(interval);
window.location.href = AFFILIATE_REDIRECT_URL;
}
}, 1000);
}
// Initialize first slide
showSlide(0);
});