-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.html
More file actions
308 lines (238 loc) · 11.5 KB
/
signup.html
File metadata and controls
308 lines (238 loc) · 11.5 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
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign Up - GreenFarm</title>
<style>
*{margin:0; padding:0; box-sizing:border-box; font-family:Arial, Helvetica, sans-serif;}
body{background:#e3efe7; min-height:100vh; display:flex; justify-content:center; align-items:center; padding:20px;}
.auth-container{background:#fff; padding:40px; width:100%; max-width:420px; border-radius:20px; box-shadow:0 20px 60px rgba(0,0,0,0.1);}
.logo{font-size:24px; font-weight:bold; color:#2f8f57; margin-bottom:10px; text-align:center;}
h2{margin-bottom:25px; color:#1a2e23; text-align:center; font-size:28px;}
.input-group{margin-bottom:18px;}
label{display:block; font-size:14px; font-weight:600; color:#1a2e23; margin-bottom:8px;}
input{width:100%; padding:14px 16px; border-radius:12px; border:2px solid #e8ede8; outline:none; font-size:15px; transition:0.3s;}
input:focus{border-color:#2f8f57; box-shadow:0 0 0 3px rgba(47,143,87,0.1);}
input::placeholder{color:#9ca3af;}
.password-field{position:relative;}
.toggle-password{position:absolute; right:16px; top:50%; transform:translateY(-50%); cursor:pointer; font-size:20px; user-select:none;}
.password-strength{margin-top:8px; height:4px; background:#e8ede8; border-radius:2px; overflow:hidden;}
.password-strength-bar{height:100%; width:0; transition:0.3s;}
.password-hint{font-size:12px; color:#6b7280; margin-top:6px;}
button{width:100%; margin-top:20px; padding:15px; border:none; border-radius:12px; background:#2f8f57; color:white; font-weight:bold; cursor:pointer; font-size:16px; transition:0.3s;}
button:hover{background:#1f6b42; transform:translateY(-2px); box-shadow:0 6px 20px rgba(47,143,87,0.3);}
button:disabled{background:#9ca3af; cursor:not-allowed; transform:none;}
.divider{display:flex; align-items:center; margin:25px 0; color:#6b7280; font-size:14px;}
.divider::before, .divider::after{content:''; flex:1; border-bottom:1px solid #e8ede8;}
.divider span{padding:0 15px;}
.google-btn{background:#fff; color:#333; border:2px solid #e8ede8; display:flex; align-items:center; justify-content:center; gap:12px; margin-top:15px;}
.google-btn:hover{background:#f9fafb; border-color:#2f8f57;}
.guest-btn{background:#f3f6f4; color:#5a7b69; border:2px solid #e8ede8; margin-top:12px;}
.guest-btn:hover{background:#e8ede8; color:#2f8f57; border-color:#2f8f57;}
.google-icon{width:20px; height:20px;}
.switch{margin-top:20px; text-align:center; font-size:14px; color:#6b7280;}
.switch a{color:#2f8f57; text-decoration:none; font-weight:600;}
.switch a:hover{text-decoration:underline;}
.error-message, .success-message{padding:12px 16px; border-radius:10px; margin-bottom:18px; font-size:14px; display:none; animation:slideIn 0.3s ease;}
.error-message{background:#fee2e2; color:#dc2626; border:1px solid #fecaca;}
.success-message{background:#d7efe1; color:#2f8f57; border:1px solid #bbf7d0;}
@keyframes slideIn{from{opacity:0; transform:translateY(-10px);} to{opacity:1; transform:translateY(0);}}
.terms{font-size:13px; color:#6b7280; margin-top:20px; text-align:center; line-height:1.6;}
.terms a{color:#2f8f57; text-decoration:none;}
@media(max-width:480px){
.auth-container{padding:30px 25px;}
h2{font-size:24px;}
}
</style>
</head>
<body>
<div class="auth-container">
<div class="logo">🌱 GreenFarm</div>
<h2>Create Account</h2>
<div id="errorMessage" class="error-message"></div>
<div id="successMessage" class="success-message"></div>
<form id="signupForm">
<div class="input-group">
<label for="fullName">Full Name</label>
<input type="text" id="fullName" placeholder="Enter your full name" required autocomplete="name">
</div>
<div class="input-group">
<label for="email">Email Address</label>
<input type="email" id="email" placeholder="Enter your email" required autocomplete="email">
</div>
<div class="input-group">
<label for="password">Password</label>
<div class="password-field">
<input type="password" id="password" placeholder="Create a password (min 6 characters)" required autocomplete="new-password">
<span class="toggle-password" onclick="togglePassword('password')">👁️</span>
</div>
<div class="password-strength">
<div class="password-strength-bar" id="strengthBar"></div>
</div>
<div class="password-hint" id="strengthText">Use 6+ characters with letters and numbers</div>
</div>
<div class="input-group">
<label for="confirmPassword">Confirm Password</label>
<div class="password-field">
<input type="password" id="confirmPassword" placeholder="Confirm your password" required autocomplete="new-password">
<span class="toggle-password" onclick="togglePassword('confirmPassword')">👁️</span>
</div>
</div>
<button type="submit" id="submitBtn">Create Account</button>
</form>
<div class="divider"><span>OR</span></div>
<button class="google-btn" onclick="handleGoogleSignup()">
<svg class="google-icon" viewBox="0 0 24 24">
<path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/>
<path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/>
<path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/>
<path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/>
</svg>
Continue with Google
</button>
<button class="guest-btn" onclick="handleGuestSignup()">
👤 Continue as Guest
</button>
<p class="switch">
Already have an account? <a href="signin.html">Sign In</a>
</p>
<p class="terms">
By creating an account, you agree to our <a href="#">Terms</a> and <a href="#">Privacy Policy</a>
</p>
</div>
<script src="auth.js"></script>
<script>
// Password toggle
function togglePassword(fieldId) {
const field = document.getElementById(fieldId);
const type = field.type === 'password' ? 'text' : 'password';
field.type = type;
event.target.textContent = type === 'password' ? '👁️' : '🙈';
}
// Password strength checker
document.getElementById('password').addEventListener('input', function() {
const password = this.value;
const strengthBar = document.getElementById('strengthBar');
const strengthText = document.getElementById('strengthText');
let strength = 0;
if (password.length >= 6) strength += 25;
if (password.length >= 10) strength += 25;
if (/[a-z]/.test(password) && /[A-Z]/.test(password)) strength += 25;
if (/\d/.test(password)) strength += 15;
if (/[^a-zA-Z0-9]/.test(password)) strength += 10;
strengthBar.style.width = strength + '%';
if (strength < 25) {
strengthBar.style.background = '#dc2626';
strengthText.textContent = 'Weak password';
strengthText.style.color = '#dc2626';
} else if (strength < 50) {
strengthBar.style.background = '#f59e0b';
strengthText.textContent = 'Fair password';
strengthText.style.color = '#f59e0b';
} else if (strength < 75) {
strengthBar.style.background = '#3b82f6';
strengthText.textContent = 'Good password';
strengthText.style.color = '#3b82f6';
} else {
strengthBar.style.background = '#10b981';
strengthText.textContent = 'Strong password';
strengthText.style.color = '#10b981';
}
});
// Form submission
document.getElementById('signupForm').addEventListener('submit', function(e) {
e.preventDefault();
const submitBtn = document.getElementById('submitBtn');
submitBtn.disabled = true;
submitBtn.textContent = 'Creating Account...';
const fullName = document.getElementById('fullName').value.trim();
const email = document.getElementById('email').value.trim();
const password = document.getElementById('password').value;
const confirmPassword = document.getElementById('confirmPassword').value;
// Validation
if (!fullName || fullName.length < 2) {
showError('Please enter your full name (at least 2 characters)');
submitBtn.disabled = false;
submitBtn.textContent = 'Create Account';
return;
}
if (!email || !validateEmail(email)) {
showError('Please enter a valid email address');
submitBtn.disabled = false;
submitBtn.textContent = 'Create Account';
return;
}
if (!password || password.length < 6) {
showError('Password must be at least 6 characters long');
submitBtn.disabled = false;
submitBtn.textContent = 'Create Account';
return;
}
if (password !== confirmPassword) {
showError('Passwords do not match');
submitBtn.disabled = false;
submitBtn.textContent = 'Create Account';
return;
}
// Register user
const result = registerUser(fullName, email, password);
if (result.success) {
showSuccess('Account created successfully! Redirecting...');
setTimeout(() => {
redirectAfterLogin();
}, 1500);
} else {
showError(result.message);
submitBtn.disabled = false;
submitBtn.textContent = 'Create Account';
}
});
// Google signup
function handleGoogleSignup() {
const result = initiateGoogleSignIn();
if (result.success) {
showSuccess(result.isNewUser ? 'Account created with Google! Redirecting...' : 'Signed in with Google! Redirecting...');
setTimeout(() => {
redirectAfterLogin();
}, 1500);
} else if (result.message) {
showError(result.message);
}
}
// Guest signup
function handleGuestSignup() {
const guestId = 'guest_' + Date.now();
const result = registerUser('Guest User', guestId + '@guest.local', 'guest-password', false, true);
if (result.success) {
showSuccess('Continuing as guest... Redirecting...');
setTimeout(() => {
redirectAfterLogin();
}, 1000);
} else {
showError('Unable to continue as guest. Please try again.');
}
}
// Show error message
function showError(message) {
const errorDiv = document.getElementById('errorMessage');
const successDiv = document.getElementById('successMessage');
errorDiv.textContent = message;
errorDiv.style.display = 'block';
successDiv.style.display = 'none';
// Auto-hide after 5 seconds
setTimeout(() => {
errorDiv.style.display = 'none';
}, 5000);
}
// Show success message
function showSuccess(message) {
const errorDiv = document.getElementById('errorMessage');
const successDiv = document.getElementById('successMessage');
successDiv.textContent = message;
successDiv.style.display = 'block';
errorDiv.style.display = 'none';
}
</script>
</body>
</html>