-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfeedback.html
More file actions
502 lines (452 loc) · 26.9 KB
/
feedback.html
File metadata and controls
502 lines (452 loc) · 26.9 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title data-i18n="feedback.title">Feedback - AddressGen</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<!-- EmailJS SDK -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@emailjs/browser@3/dist/email.min.js"></script>
<style>
body {
font-family: 'Inter', sans-serif;
}
.dropdown:hover .dropdown-menu {
display: block;
}
/* 添加加载状态样式 */
.loading {
opacity: 0.6;
pointer-events: none;
}
.success-message {
background-color: #d1fae5;
color: #065f46;
border: 1px solid #a7f3d0;
}
.error-message {
background-color: #fee2e2;
color: #991b1b;
border: 1px solid #fca5a5;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<!-- Navigation Bar -->
<nav class="bg-white shadow-md fixed w-full z-10">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex">
<div class="flex-shrink-0 flex items-center">
<span class="text-2xl font-bold text-indigo-600">AddressGen</span>
</div>
<div class="hidden sm:ml-6 sm:flex sm:space-x-8">
<a href="index.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" data-i18n="nav.home">
Home
</a>
<a href="blog.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" data-i18n="nav.blog">
Blog
</a>
<a href="faq.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" data-i18n="nav.faq">
FAQ
</a>
<a href="about.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" data-i18n="nav.about">
About
</a>
<a href="feedback.html" class="border-indigo-500 text-gray-900 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" data-i18n="nav.feedback">
Feedback
</a>
</div>
</div>
<div class="hidden sm:ml-6 sm:flex sm:items-center">
<!-- Language Selector -->
<div class="ml-3 relative" style="position: relative; display: inline-block;">
<button type="button" id="lang-button" class="flex text-sm border-2 border-transparent rounded-full focus:outline-none focus:border-gray-300 transition duration-150 ease-in-out">
<span class="px-2 py-1 rounded-md text-gray-700 bg-gray-100 hover:bg-gray-200">
<i class="fas fa-globe mr-1"></i> <span id="current-lang">English</span>
</span>
</button>
<div id="lang-dropdown" style="display: none; position: absolute; top: 100%; right: 0; margin-top: 0.5rem; width: 12rem; background-color: white; border-radius: 0.375rem; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); z-index: 50;">
<a href="javascript:void(0)" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onclick="changeLanguage('en')">English</a>
<a href="javascript:void(0)" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onclick="changeLanguage('zh-CN')">简体中文</a>
</div>
</div>
</div>
<div class="-mr-2 flex items-center sm:hidden">
<!-- Mobile menu button -->
<button type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500" aria-expanded="false" id="mobile-menu-button">
<span class="sr-only">Open main menu</span>
<i class="fas fa-bars"></i>
</button>
</div>
</div>
</div>
<!-- Mobile menu, show/hide based on menu state. -->
<div class="sm:hidden hidden" id="mobile-menu">
<div class="pt-2 pb-3 space-y-1">
<a href="index.html" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Home</a>
<a href="blog.html" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Blog</a>
<a href="faq.html" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">FAQ</a>
<a href="about.html" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">About</a>
<a href="feedback.html" class="bg-indigo-50 border-indigo-500 text-indigo-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Feedback</a>
<div class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">
<span class="font-medium text-gray-500">Language:</span>
<div class="mt-1 flex space-x-2">
<a href="#" class="text-sm text-gray-700 hover:text-indigo-500" onclick="changeLanguage('en')">English</a>
<a href="#" class="text-sm text-gray-700 hover:text-indigo-500" onclick="changeLanguage('zh-CN')">简体中文</a>
</div>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<div class="pt-16 pb-12">
<!-- Feedback Header -->
<div class="bg-indigo-700 text-white">
<div class="max-w-7xl mx-auto py-16 px-4 sm:py-24 sm:px-6 lg:px-8">
<div class="text-center">
<h1 class="text-4xl font-extrabold tracking-tight sm:text-5xl lg:text-6xl" data-i18n="feedback.title">Feedback</h1>
<p class="mt-6 text-xl max-w-3xl mx-auto" data-i18n="feedback.subtitle">
We value your feedback and suggestions. Help us improve AddressGen by sharing your thoughts.
</p>
<p class="mt-4 text-lg text-indigo-200 max-w-2xl mx-auto">
<i class="fas fa-shield-alt mr-2"></i>
<span data-i18n="feedback.ip.limit">每个IP地址每天限制提交一次反馈,感谢您的理解与配合</span>
</p>
</div>
</div>
</div>
<!-- Feedback Form -->
<div class="max-w-7xl mx-auto py-16 px-4 sm:px-6 lg:px-8">
<div class="max-w-3xl mx-auto">
<!-- 用户提示信息 -->
<div class="mb-8 p-4 bg-blue-50 border border-blue-200 rounded-lg">
<div class="flex items-start">
<div class="flex-shrink-0">
<i class="fas fa-info-circle text-blue-400 mt-1"></i>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-blue-800" data-i18n="feedback.instructions.title">反馈提交说明</h3>
<div class="mt-2 text-sm text-blue-700">
<ul class="list-disc pl-5 space-y-1">
<li data-i18n="feedback.instructions.limit">为了防止垃圾邮件,每个IP地址每天只能提交一次反馈</li>
<li data-i18n="feedback.instructions.complete">请确保您的反馈内容准确完整,提交后当天无法再次修改</li>
<li data-i18n="feedback.instructions.response">我们会认真查看每一条反馈,并尽快回复您</li>
</ul>
</div>
</div>
</div>
</div>
<!-- 状态消息区域 -->
<div id="status-message" class="hidden mb-6 p-4 rounded-md"></div>
<form id="feedback-form" class="space-y-6">
<div>
<label for="name" class="block text-sm font-medium text-gray-700" data-i18n="feedback.form.name">Name</label>
<div class="mt-1">
<input type="text" name="name" id="name" required class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" placeholder="Your name" data-i18n-placeholder="feedback.form.placeholder.name">
</div>
</div>
<div>
<label for="email" class="block text-sm font-medium text-gray-700" data-i18n="feedback.form.email">Email</label>
<div class="mt-1">
<input type="email" name="email" id="email" required class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" placeholder="your.email@example.com" data-i18n-placeholder="feedback.form.placeholder.email">
</div>
</div>
<div>
<label for="subject" class="block text-sm font-medium text-gray-700" data-i18n="feedback.form.subject">Subject</label>
<div class="mt-1">
<input type="text" name="subject" id="subject" required class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" placeholder="What is this regarding?" data-i18n-placeholder="feedback.form.placeholder.subject">
</div>
</div>
<div>
<label for="message" class="block text-sm font-medium text-gray-700" data-i18n="feedback.form.message">Message</label>
<div class="mt-1">
<textarea id="message" name="message" rows="4" required class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" placeholder="Tell us what you think..." data-i18n-placeholder="feedback.form.placeholder.message"></textarea>
</div>
</div>
<div>
<button type="submit" id="submit-btn" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" data-i18n="feedback.form.submit">
<span id="submit-text">Submit Feedback</span>
<span id="loading-spinner" class="hidden ml-2">
<i class="fas fa-spinner fa-spin"></i>
</span>
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Footer -->
<footer class="bg-white">
<div class="max-w-7xl mx-auto py-12 px-4 overflow-hidden sm:px-6 lg:px-8">
<nav class="-mx-5 -my-2 flex flex-wrap justify-center" aria-label="Footer">
<div class="px-5 py-2">
<a href="index.html" class="text-base text-gray-500 hover:text-gray-900" data-i18n="footer.nav.home">Home</a>
</div>
<div class="px-5 py-2">
<a href="blog.html" class="text-base text-gray-500 hover:text-gray-900" data-i18n="footer.nav.blog">Blog</a>
</div>
<div class="px-5 py-2">
<a href="faq.html" class="text-base text-gray-500 hover:text-gray-900" data-i18n="footer.nav.faq">FAQ</a>
</div>
<div class="px-5 py-2">
<a href="about.html" class="text-base text-gray-500 hover:text-gray-900" data-i18n="footer.nav.about">About</a>
</div>
<div class="px-5 py-2">
<a href="feedback.html" class="text-base text-gray-500 hover:text-gray-900" data-i18n="footer.nav.feedback">Feedback</a>
</div>
</nav>
<p class="mt-8 text-center text-base text-gray-400" data-i18n="footer.copyright">© 2023 AddressGen. All rights reserved.</p>
</div>
</footer>
<!-- JavaScript -->
<script src="js/i18n.js"></script>
<script>
// 等待DOM完全加载
document.addEventListener('DOMContentLoaded', function() {
console.log('DOM loaded');
// Language dropdown toggle
const langButton = document.getElementById('lang-button');
const langDropdown = document.getElementById('lang-dropdown');
if (langButton && langDropdown) {
// 点击语言按钮时切换下拉菜单的显示状态
langButton.addEventListener('click', function(event) {
event.preventDefault();
event.stopPropagation();
console.log('Language button clicked');
console.log('Current dropdown display:', langDropdown.style.display);
langDropdown.style.display = langDropdown.style.display === 'none' ? 'block' : 'none';
console.log('New dropdown display:', langDropdown.style.display);
});
// 点击页面其他地方时关闭下拉菜单
document.addEventListener('click', function(event) {
if (!langButton.contains(event.target) && !langDropdown.contains(event.target)) {
console.log('Clicking outside, hiding dropdown');
langDropdown.style.display = 'none';
}
});
// 阻止下拉菜单内的点击事件冒泡
langDropdown.addEventListener('click', function(event) {
event.stopPropagation();
});
// 更新当前语言显示
const currentLang = document.getElementById('current-lang');
if (currentLang) {
const lang = localStorage.getItem('language') || 'en';
currentLang.textContent = lang === 'en' ? 'English' : '简体中文';
}
}
// 初始化 EmailJS
if (typeof emailjs !== 'undefined') {
emailjs.init("FrgVrzets8zHdLcMX");
} else {
console.error('EmailJS library not loaded');
}
// 获取用户IP地址
let userIP = null;
async function getUserIP() {
try {
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
userIP = data.ip;
// 检查今天是否已经发送过反馈
checkDailyLimit();
} catch (error) {
console.error('获取IP失败:', error);
// 如果获取IP失败,使用备用方案
try {
const response2 = await fetch('https://httpbin.org/ip');
const data2 = await response2.json();
userIP = data2.origin;
checkDailyLimit();
} catch (error2) {
console.error('备用IP获取也失败:', error2);
userIP = 'unknown';
checkDailyLimit();
}
}
}
function checkDailyLimit() {
const today = new Date().toDateString();
const storageKey = `feedback_${userIP}_${today}`;
const hasSubmittedToday = localStorage.getItem(storageKey);
if (hasSubmittedToday) {
showLimitMessage();
disableForm();
}
}
function showLimitMessage() {
const statusMessage = document.getElementById('status-message');
if (statusMessage) {
statusMessage.innerHTML = `
<div class="flex items-center">
<div class="flex-shrink-0">
<i class="fas fa-check-circle text-yellow-600 text-xl"></i>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-yellow-800">今日反馈已提交</h3>
<p class="text-sm text-yellow-700 mt-1">
您今天已经提交过反馈了。每个IP地址每天只能提交一次反馈,明天您可以再次提交新的反馈。感谢您的理解!
</p>
</div>
</div>
`;
statusMessage.className = 'mb-6 p-4 rounded-md bg-yellow-50 border border-yellow-200';
statusMessage.classList.remove('hidden');
}
}
function disableForm() {
const feedbackForm = document.getElementById('feedback-form');
const submitBtn = document.getElementById('submit-btn');
if (feedbackForm) {
const inputs = feedbackForm.querySelectorAll('input, textarea, button');
inputs.forEach(input => {
input.disabled = true;
});
}
if (submitBtn) {
submitBtn.textContent = '今日已提交';
submitBtn.classList.add('opacity-50', 'cursor-not-allowed');
}
}
function markAsSubmittedToday() {
const today = new Date().toDateString();
const storageKey = `feedback_${userIP}_${today}`;
localStorage.setItem(storageKey, 'true');
}
// 清理过期的localStorage数据(可选)
function cleanupOldData() {
const today = new Date().toDateString();
for (let i = localStorage.length - 1; i >= 0; i--) {
const key = localStorage.key(i);
if (key && key.startsWith('feedback_') && !key.includes(today)) {
localStorage.removeItem(key);
}
}
}
// 获取IP地址
getUserIP();
cleanupOldData();
// Mobile menu toggle
const mobileMenuButton = document.getElementById('mobile-menu-button');
const mobileMenu = document.getElementById('mobile-menu');
if (mobileMenuButton && mobileMenu) {
mobileMenuButton.addEventListener('click', function() {
mobileMenu.classList.toggle('hidden');
});
}
// 表单提交处理
const feedbackForm = document.getElementById('feedback-form');
if (feedbackForm) {
feedbackForm.addEventListener('submit', function(event) {
event.preventDefault();
// 再次检查每日限制
const today = new Date().toDateString();
const storageKey = `feedback_${userIP}_${today}`;
const hasSubmittedToday = localStorage.getItem(storageKey);
if (hasSubmittedToday) {
showStatusMessage('您今天已经提交过反馈了,每个IP地址每天只能提交一次。', 'error');
return;
}
try {
const submitBtn = document.getElementById('submit-btn');
const submitText = document.getElementById('submit-text');
const loadingSpinner = document.getElementById('loading-spinner');
const statusMessage = document.getElementById('status-message');
// 显示加载状态
if (submitBtn) submitBtn.classList.add('loading');
if (submitText) submitText.textContent = 'Sending...';
if (loadingSpinner) loadingSpinner.classList.remove('hidden');
if (statusMessage) statusMessage.classList.add('hidden');
// 收集表单数据
const nameInput = document.getElementById('name');
const emailInput = document.getElementById('email');
const subjectInput = document.getElementById('subject');
const messageInput = document.getElementById('message');
const formData = {
from_name: nameInput ? nameInput.value : '',
from_email: emailInput ? emailInput.value : '',
subject: subjectInput ? subjectInput.value : '',
message: messageInput ? messageInput.value : '',
user_ip: userIP, // 添加IP信息到邮件
to_email: 'lmkbnb0@gmail.com'
};
// 发送邮件
if (typeof emailjs !== 'undefined') {
emailjs.send('service_ynu15lm', 'template_5gpty4a', formData)
.then(function(response) {
// 成功后标记为已提交
markAsSubmittedToday();
showStatusMessage('感谢您的反馈!我们已收到您的消息,会尽快回复。今天您已达到提交限制。', 'success');
feedbackForm.reset();
// 延迟禁用表单,让用户看到成功信息
setTimeout(() => {
disableForm();
}, 2000);
}, function(error) {
// 失败
console.error('邮件发送失败:', error);
showStatusMessage('抱歉,发送失败。请稍后重试或直接联系我们。', 'error');
})
.finally(function() {
restoreButtonState();
});
} else {
console.error('EmailJS not available');
showStatusMessage('邮件服务不可用,请稍后重试。', 'error');
restoreButtonState();
}
function restoreButtonState() {
if (submitBtn) submitBtn.classList.remove('loading');
if (submitText) submitText.textContent = 'Submit Feedback';
if (loadingSpinner) loadingSpinner.classList.add('hidden');
}
} catch (error) {
console.error('Form submission error:', error);
showStatusMessage('提交时发生错误,请稍后重试。', 'error');
}
});
}
});
function showStatusMessage(message, type) {
const statusMessage = document.getElementById('status-message');
if (statusMessage) {
statusMessage.textContent = message;
statusMessage.className = `mb-6 p-4 rounded-md ${type === 'success' ? 'success-message' : 'error-message'}`;
statusMessage.classList.remove('hidden');
// 3秒后自动隐藏成功消息
if (type === 'success') {
setTimeout(() => {
statusMessage.classList.add('hidden');
}, 3000);
}
}
}
// 语言切换函数
function changeLanguage(lang) {
console.log('Changing language to:', lang);
// 保存语言选择到localStorage
localStorage.setItem('language', lang);
// 更新当前语言显示
const currentLang = document.getElementById('current-lang');
if (currentLang) {
currentLang.textContent = lang === 'en' ? 'English' : '简体中文';
}
// 关闭下拉菜单
const langDropdown = document.getElementById('lang-dropdown');
if (langDropdown) {
langDropdown.style.display = 'none';
}
// 如果有i18n.js文件,调用相应的函数
if (typeof window.i18n !== 'undefined' && typeof window.i18n.changeLanguage === 'function') {
window.i18n.changeLanguage(lang);
}
// 延迟一小段时间后刷新页面,确保语言设置已保存
setTimeout(() => {
window.location.reload();
}, 100);
}
</script>
</body>
</html>