CoolFace
Apppublic

SBanonymous/securegate-portal

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
script.js141 linesDownload Raw Back to root
1 2document.addEventListener('DOMContentLoaded', function() {3    // Handle registration form if it exists4    const registerForm = document.getElementById('registerForm');5    if (registerForm) {6        registerForm.addEventListener('submit', function(e) {7            e.preventDefault();8            9            const name = document.getElementById('name').value;10            const email = document.getElementById('email').value;11            const password = document.getElementById('password').value;12            const confirmPassword = document.getElementById('confirm-password').value;13            const terms = document.getElementById('terms').checked;14            15            // Validation16            if (!name || !email || !password || !confirmPassword) {17                alert('Please fill in all fields');18                return;19            }20            21            if (password !== confirmPassword) {22                alert('Passwords do not match');23                return;24            }25            26            if (!terms) {27                alert('You must agree to the terms and conditions');28                return;29            }30            31            // Show loading state32            const submitBtn = registerForm.querySelector('button[type="submit"]');33            const originalText = submitBtn.innerHTML;34            submitBtn.innerHTML = `35                <span class="absolute left-0 inset-y-0 flex items-center pl-3">36                    <i data-feather="loader" class="h-5 w-5 text-primary-200 animate-spin"></i>37                </span>38                Creating Account...39            `;40            feather.replace();41            42            // Simulate registration43            setTimeout(() => {44                alert('Account created successfully! Please sign in.');45                window.location.href = 'index.html';46            }, 2000);47        });48    }49 50    // Handle password reset form if it exists51const resetForm = document.getElementById('resetForm');52    if (resetForm) {53        resetForm.addEventListener('submit', function(e) {54            e.preventDefault();55            56            const email = document.getElementById('email').value;57            58            if (!email) {59                alert('Please enter your email address');60                return;61            }62            63            // Show loading state64            const submitBtn = resetForm.querySelector('button[type="submit"]');65            const originalText = submitBtn.innerHTML;66            submitBtn.innerHTML = `67                <span class="absolute left-0 inset-y-0 flex items-center pl-3">68                    <i data-feather="loader" class="h-5 w-5 text-primary-200 animate-spin"></i>69                </span>70                Sending...71            `;72            feather.replace();73            74            // Simulate sending reset email75            setTimeout(() => {76                alert(`Password reset link has been sent to ${email}`);77                submitBtn.innerHTML = originalText;78                feather.replace();79            }, 1500);80        });81    }82 83const loginForm = document.getElementById('loginForm');84    85    loginForm.addEventListener('submit', function(e) {86        e.preventDefault();87        88        // Get form values89        const email = document.getElementById('email').value;90        const password = document.getElementById('password').value;91        const rememberMe = document.getElementById('remember-me').checked;92        93        // Simple validation94        if (!email || !password) {95            alert('Please fill in all fields');96            return;97        }98        99        // Here you would typically make an API call to authenticate100        // For demo purposes, we'll simulate a successful login101        simulateLogin(email, password, rememberMe);102    });103    104    function simulateLogin(email, password, remember) {105        // Show loading state106        const submitBtn = loginForm.querySelector('button[type="submit"]');107        const originalText = submitBtn.innerHTML;108        submitBtn.innerHTML = `109            <span class="absolute left-0 inset-y-0 flex items-center pl-3">110                <i data-feather="loader" class="h-5 w-5 text-primary-200 animate-spin"></i>111            </span>112            Authenticating...113        `;114        feather.replace();115        116        // Simulate API call delay117        setTimeout(() => {118            // For demo, we'll consider any non-empty password as valid119            if (password.length > 0) {120                // Store login state if remember me is checked121                if (remember) {122                    localStorage.setItem('rememberedEmail', email);123                }124                125                // Redirect to your existing website126                window.location.href = 'your-existing-website.html'; // Change this to your actual website URL127            } else {128                alert('Invalid credentials');129                submitBtn.innerHTML = originalText;130                feather.replace();131            }132        }, 1500);133    }134    135    // Check for remembered email136    const rememberedEmail = localStorage.getItem('rememberedEmail');137    if (rememberedEmail) {138        document.getElementById('email').value = rememberedEmail;139        document.getElementById('remember-me').checked = true;140    }141});