-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
186 lines (155 loc) · 5.66 KB
/
index.js
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
function switchPage(pageId) {
let pageUrl;
switch(pageId) {
case 'Traders':
pageUrl = 'Trades.html';
break;
case 'FAQ':
pageUrl = 'Tradeshub.html';
break;
case 'LeaderBoard':
pageUrl = 'LeaderBoard.html';
break;
case 'index':
pageUrl = 'Tradeshub.html';
break;
case 'Terms':
pageUrl = 'Terms.html';
break;
case 'Privacy':
pageUrl = 'Privacy.html';
break;
case 'Contact':
pageUrl = 'Contact.html';
break;
default:
pageUrl = 'Tradeshub.html'; // Default to an error page if pageId is unrecognized
break;
}
// Redirect to the selected page
window.location.href = pageUrl;
}
function sendMail() {
// Get form input values
var name = document.getElementById("name").value.trim();
var email = document.getElementById("email").value.trim();
var message = document.getElementById("message").value.trim();
// Validate form inputs
if (name === "") {
alert("Please enter your name.");
return;
}
if (email === "") {
alert("Please enter your email address.");
return;
} else if (!isValidEmail(email)) {
alert("Please enter a valid email address.");
return;
}
if (message === "") {
alert("Please enter your message.");
return;
}
// If all inputs are valid, proceed to send email
var params = {
name: name,
email: email,
message: message,
};
const serviceID = "service_kdn514c"; // Replace with your EmailJS service ID
const templateID = "template_0gxeqvi"; // Replace with your EmailJS template ID
emailjs.send(serviceID, templateID, params)
.then(res => {
// Clear form fields and show thank you message
document.getElementById("name").value = "";
document.getElementById("email").value = "";
document.getElementById("message").value = "";
document.getElementById("thank_you").style.display = "block";
document.getElementById("contactForm").style.display = "none";
document.getElementById("contactform_title").style.display = "none";
document.getElementById("contactform_desc").style.display = "none";
})
.catch(err => console.error("Error sending email:", err));
}
// Function to validate email format
function isValidEmail(email) {
// Regular expression to validate email format
var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}
// add in toast validator
const accordions = document.querySelectorAll('.accordion');
accordions.forEach(accordion => {
const header = accordion.querySelector('.accordion-header');
const content = accordion.querySelector('.accordion-content');
header.addEventListener('click', () => {
// Close all open accordions first
accordions.forEach(acc => {
const accordionContent = acc.querySelector('.accordion-content');
if (accordionContent !== content) {
accordionContent.classList.remove('active');
accordionContent.style.display = 'none';
}
});
// Toggle the clicked accordion
content.classList.toggle('active');
if (content.style.display === 'block') {
content.style.display = 'none';
} else {
content.style.display = 'block';
}
});
});
document.addEventListener('DOMContentLoaded', function() {
const button = document.querySelector('.scroll-button');
const target = document.querySelector('.scroll-target');
button.addEventListener('click', function() {
target.scrollIntoView({ behavior: 'smooth' });
});
});
const amountInput = document.getElementById('amount');
const monthsInput = document.getElementById('months');
const earnedDisplay = document.getElementById('earnedDisplay');
const interestDisplay = document.getElementById('interestDisplay');
function calculate() {
const amount = parseInt(amountInput.value);
const months = parseInt(monthsInput.value);
let earned = amount;
for (let i = 0; i < months; i++) {
earned += earned * 0.10; // 10% growth
}
const compoundInterest = ((earned - amount) / amount) * 100;
earnedDisplay.textContent = '$' + earned.toFixed(2);
interestDisplay.textContent = '↑' + compoundInterest.toFixed(2) + '%';
}
amountInput.addEventListener('input', () => {
const amount = parseInt(amountInput.value);
document.getElementById('amountDisplay').textContent = '$' + amount;
calculate();
});
monthsInput.addEventListener('input', () => {
const months = parseInt(monthsInput.value);
document.getElementById('monthsDisplay').textContent = months + (months === 1 ? ' month' : ' months');
calculate();
});
calculate(); // Initial calculation
// Function to redirect to Instagram
function goToInstagram() {
window.location.href = "https://www.instagram.com/tradeshub.crypto?igsh=ZjB3eWpwczA2Zncx&utm_source=qr";
}
// Function to redirect to Twitter
function goToTwitter() {
window.location.href = "https://twitter.com/";
}
// Function to redirect to Facebook
function goToFacebook() {
window.location.href = "https://www.facebook.com/";
}
function goToCopyTrading() {
window.location.href = "https://i.bybit.com/OabQq5O?action=inviteToCopy";
}
// Add event listeners to each icon
document.getElementById("instagram").addEventListener("click", goToInstagram);
document.getElementById("twitter").addEventListener("click", goToTwitter);
document.getElementById("facebook").addEventListener("click", goToFacebook);
document.getElementById("CopyTrading").addEventListener("click",goToCopyTrading);