File size: 8,951 Bytes
c6207dc
 
 
 
 
80f8c29
c6207dc
 
 
 
1bd4bc0
80f8c29
c6207dc
 
 
80f8c29
 
 
 
 
c6207dc
 
80f8c29
 
 
 
 
 
c6207dc
 
80f8c29
1bd4bc0
c6207dc
 
80f8c29
 
1bd4bc0
80f8c29
c6207dc
 
80f8c29
 
 
 
 
 
 
 
c6207dc
 
80f8c29
 
c6207dc
 
80f8c29
 
 
 
 
1bd4bc0
80f8c29
 
1bd4bc0
80f8c29
1bd4bc0
 
80f8c29
 
1bd4bc0
 
80f8c29
 
 
c6207dc
 
80f8c29
 
 
 
c6207dc
 
80f8c29
1bd4bc0
80f8c29
 
 
c6207dc
 
80f8c29
 
 
 
c6207dc
 
80f8c29
 
 
 
1bd4bc0
 
80f8c29
1bd4bc0
80f8c29
 
c6207dc
 
80f8c29
1bd4bc0
80f8c29
 
c6207dc
 
80f8c29
 
 
c6207dc
 
80f8c29
 
 
 
c6207dc
 
 
 
80f8c29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1bd4bc0
c6207dc
1bd4bc0
80f8c29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1bd4bc0
 
c6207dc
 
 
80f8c29
 
 
 
 
 
 
 
 
 
 
 
 
b5d652f
 
80f8c29
 
 
b5d652f
 
80f8c29
 
 
 
 
 
 
1bd4bc0
 
80f8c29
 
 
 
 
1bd4bc0
 
80f8c29
 
 
1bd4bc0
80f8c29
 
 
 
 
 
1bd4bc0
80f8c29
 
 
 
1bd4bc0
 
80f8c29
 
 
 
1bd4bc0
 
80f8c29
 
 
 
c6207dc
 
80f8c29
c6207dc
80f8c29
 
c6207dc
80f8c29
1bd4bc0
80f8c29
 
 
c6207dc
80f8c29
 
c6207dc
80f8c29
 
 
c6207dc
80f8c29
 
 
c6207dc
80f8c29
 
 
 
c6207dc
80f8c29
c6207dc
80f8c29
 
c6207dc
80f8c29
1bd4bc0
80f8c29
c6207dc
80f8c29
 
 
 
 
 
 
1bd4bc0
c6207dc
 
 
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
281
282
283
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login & Register</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: linear-gradient(45deg, #6b5b95, #feb236);
        }

        .container {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            padding: 40px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
            width: 400px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        h2 {
            text-align: center;
            color: #333;
            margin-bottom: 30px;
        }

        input {
            width: 100%;
            padding: 12px;
            border: 2px solid #ddd;
            border-radius: 8px;
            font-size: 16px;
            transition: all 0.3s ease;
            outline: none;
        }

        input:focus {
            border-color: #6b5b95;
        }

        button {
            width: 100%;
            padding: 12px;
            background: #6b5b95;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        button:hover {
            background: #574a7a;
        }

        .switch-form {
            text-align: center;
            margin-top: 20px;
        }

        .switch-form a {
            color: #6b5b95;
            text-decoration: none;
            font-weight: 600;
        }

        .alert {
            padding: 10px;
            margin: 10px 0;
            border-radius: 8px;
            display: none;
        }

        .alert-success {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .alert-error {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        .password-requirements {
            font-size: 12px;
            color: #666;
            margin-top: 5px;
        }

        .loading {
            display: none;
            text-align: center;
            margin-top: 10px;
        }

        .loading::after {
            content: "...";
            animation: dots 1s steps(5, end) infinite;
        }

        @keyframes dots {
            0%, 20% { content: "."; }
            40% { content: ".."; }
            60%, 100% { content: "..."; }
        }
    </style>
</head>
<body>
    <div class="container">
        <div id="loginForm">
            <h2>Login</h2>
            <div class="alert alert-error" id="loginError"></div>
            <form onsubmit="handleLogin(event)">
                <div class="form-group">
                    <input type="email" id="loginEmail" placeholder="Email" required>
                </div>
                <div class="form-group">
                    <input type="password" id="loginPassword" placeholder="Password" required>
                </div>
                <button type="submit">Login</button>
                <div class="loading" id="loginLoading">Processing</div>
            </form>
            <div class="switch-form">
                Don't have an account? <a href="#" onclick="toggleForms()">Register</a>
            </div>
        </div>

        <div id="registerForm" style="display: none;">
            <h2>Register</h2>
            <div class="alert alert-success" id="registerSuccess"></div>
            <div class="alert alert-error" id="registerError"></div>
            <form onsubmit="handleRegister(event)">
                <div class="form-group">
                    <input type="email" id="registerEmail" placeholder="Email" required>
                </div>
                <div class="form-group">
                    <input type="password" id="registerPassword" placeholder="Password" required>
                    <div class="password-requirements">
                        Password must be at least 8 characters long and contain letters and numbers
                    </div>
                </div>
                <div class="form-group">
                    <input type="password" id="confirmPassword" placeholder="Confirm Password" required>
                </div>
                <button type="submit">Register</button>
                <div class="loading" id="registerLoading">Processing</div>
            </form>
            <div class="switch-form">
                Already have an account? <a href="#" onclick="toggleForms()">Login</a>
            </div>
        </div>
    </div>

    <script>
        // Mock user database
        let users = [];

        function toggleForms() {
            const loginForm = document.getElementById('loginForm');
            const registerForm = document.getElementById('registerForm');
            
            if (loginForm.style.display === 'none') {
                loginForm.style.display = 'block';
                registerForm.style.display = 'none';
            } else {
                loginForm.style.display = 'none';
                registerForm.style.display = 'block';
            }

            // Clear all alerts and forms
            clearAlerts();
            document.querySelectorAll('form').forEach(form => form.reset());
        }

        function clearAlerts() {
            document.querySelectorAll('.alert').forEach(alert => {
                alert.style.display = 'none';
            });
            document.querySelectorAll('.loading').forEach(loading => {
                loading.style.display = 'none';
            });
        }

        function validatePassword(password) {
            const minLength = 8;
            const hasLetter = /[a-zA-Z]/.test(password);
            const hasNumber = /\d/.test(password);
            return password.length >= minLength && hasLetter && hasNumber;
        }

        async function handleRegister(event) {
            event.preventDefault();
            clearAlerts();

            const email = document.getElementById('registerEmail').value;
            const password = document.getElementById('registerPassword').value;
            const confirmPassword = document.getElementById('confirmPassword').value;
            const loading = document.getElementById('registerLoading');
            const success = document.getElementById('registerSuccess');
            const error = document.getElementById('registerError');

            if (!validatePassword(password)) {
                error.textContent = 'Password must be at least 8 characters long and contain both letters and numbers';
                error.style.display = 'block';
                return;
            }

            if (password !== confirmPassword) {
                error.textContent = 'Passwords do not match';
                error.style.display = 'block';
                return;
            }

            if (users.some(user => user.email === email)) {
                error.textContent = 'Email already registered';
                error.style.display = 'block';
                return;
            }

            loading.style.display = 'block';

            // Simulate API call
            await new Promise(resolve => setTimeout(resolve, 1500));

            users.push({ email, password });
            
            loading.style.display = 'none';
            success.textContent = 'Registration successful! Please login.';
            success.style.display = 'block';

            // Clear form
            event.target.reset();

            // Switch to login form after 2 seconds
            setTimeout(toggleForms, 2000);
        }

        async function handleLogin(event) {
            event.preventDefault();
            clearAlerts();

            const email = document.getElementById('loginEmail').value;
            const password = document.getElementById('loginPassword').value;
            const loading = document.getElementById('loginLoading');
            const error = document.getElementById('loginError');

            loading.style.display = 'block';

            // Simulate API call
            await new Promise(resolve => setTimeout(resolve, 1500));

            const user = users.find(u => u.email === email && u.password === password);

            loading.style.display = 'none';

            if (user) {
                alert('Login successful!');
                event.target.reset();
            } else {
                error.textContent = 'Invalid email or password';
                error.style.display = 'block';
            }
        }
    </script>
</body>
</html>