-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
713 lines (669 loc) · 30.6 KB
/
index.html
File metadata and controls
713 lines (669 loc) · 30.6 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
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SNN Mass Collection</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Poppins', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
background: #f5f7fa;
min-height: 100vh;
margin: 0;
padding: 20px;
}
h1 {
color: #333;
font-size: 2em;
font-weight: 600;
margin: 30px 0;
}
#welcomePage {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
max-width: 600px;
width: 100%;
}
#welcomePage p {
color: #555;
font-size: 1em;
margin-bottom: 20px;
}
#emailInput, #chineseNameInput, #englishNameInput {
padding: 10px;
font-size: 1em;
width: 100%;
max-width: 300px;
border: 1px solid #e0e0e0;
border-radius: 6px;
margin-bottom: 10px;
}
#privacyNotice {
color: #777;
font-size: 0.9em;
margin-bottom: 20px;
}
#languageButtons {
display: flex;
gap: 10px;
}
.langButton {
padding: 12px 24px;
font-size: 1em;
font-weight: 500;
cursor: pointer;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 6px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: transform 0.1s ease, background-color 0.3s ease;
pointer-events: auto;
}
.langButton:hover {
background-color: #0056b3;
transform: translateY(-2px);
}
#videoPage {
display: none;
flex-direction: column;
align-items: center;
text-align: center;
max-width: 800px;
width: 100%;
}
#videoLink {
display: inline-block;
padding: 12px 24px;
font-size: 1em;
font-weight: 500;
cursor: pointer;
background-color: #ff4d4f;
color: #fff;
text-decoration: none;
border-radius: 6px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: transform 0.1s ease, background-color 0.3s ease;
margin: 20px 0;
}
#videoLink:hover {
background-color: #d9363e;
transform: translateY(-2px);
}
#watchButton {
padding: 12px 24px;
font-size: 1em;
font-weight: 500;
cursor: pointer;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 6px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: transform 0.1s ease, background-color 0.3s ease;
pointer-events: auto;
margin-bottom: 20px;
}
#watchButton:disabled {
cursor: not-allowed;
opacity: 0.6;
}
#watchButton:hover:not(:disabled) {
background-color: #0056b3;
transform: translateY(-2px);
}
#mainPage {
display: none;
width: 100%;
max-width: 1200px;
}
.container {
display: flex;
flex-direction: row;
align-items: flex-start;
gap: 20px;
width: 100%;
}
#rulesContainer {
border: 1px solid #e0e0e0;
border-radius: 8px;
background: #fff;
padding: 15px;
width: 200px;
min-height: 300px;
color: #555;
font-size: 0.9em;
}
#rulesContainer ol {
padding-left: 20px;
margin: 0;
}
#rulesContainer li {
margin-bottom: 10px;
}
#videoContainer {
border: 1px solid #e0e0e0;
border-radius: 8px;
background: #fff;
padding: 15px;
max-width: 600px;
width: 100%;
}
#frameDisplay {
max-width: 100%;
border-radius: 6px;
}
#inputPrompt {
background: #fff;
padding: 20px;
border: 1px solid #e0e0e0;
border-radius: 8px;
text-align: center;
display: none;
width: 150px;
}
#inputPrompt p {
margin: 0 0 15px;
color: #555;
font-weight: 500;
font-size: 1em;
}
#inputPrompt .button-grid {
display: flex;
flex-direction: column;
gap: 10px;
}
#inputPrompt button {
padding: 12px;
font-size: 1em;
font-weight: 500;
cursor: pointer;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 6px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: transform 0.1s ease, background-color 0.3s ease;
}
#inputPrompt button:hover {
background-color: #0056b3;
transform: translateY(-2px);
}
#loadingProgress, #currentProgress {
margin-top: 10px;
font-size: 0.9em;
color: #777;
}
#completionPage {
display: none;
text-align: center;
max-width: 600px;
width: 100%;
}
#completionPage p {
color: #555;
font-size: 1.2em;
margin: 20px 0;
}
#preloadStatus {
color: #777;
font-size: 0.9em;
margin-top: 10px;
}
</style>
</head>
<body>
<!-- Welcome Page -->
<div id="welcomePage">
<h1>Volunteer Data Collection</h1>
<p>Please enter your email</p>
<input type="email" id="emailInput" placeholder="example@email.com">
<p>Please enter your Chinese name (if applicable)<br>请输入您的中文名(如有)</p>
<input type="text" id="chineseNameInput" placeholder="陈大文">
<p>Please enter your English name</p>
<input type="text" id="englishNameInput" placeholder="CHAN Tai Man">
<p id="privacyNotice">*For research purposes only, your personal information will be kept strictly confidential</p>
<div id="languageButtons">
<button class="langButton" onclick="startExperiment('zh')">中文 (简体)</button>
<button class="langButton" onclick="startExperiment('en')">English</button>
</div>
<p id="preloadStatus"></p>
</div>
<!-- Video Page -->
<div id="videoPage">
<h1>Rules Explained </h1>
<a id="videoLink" href="" target="_blank"></a>
<button id="watchButton" onclick="proceedToMainPage()" disabled> I have watched carefully</button>
</div>
<!-- Main Page -->
<div id="mainPage">
<h1 id="mainTitle"></h1>
<div class="container">
<div id="rulesContainer">
<p id="rulesTitle"></p>
<ol id="rulesList"></ol>
</div>
<div id="videoContainer">
<img id="frameDisplay" src="" alt="Video Frame">
</div>
<div id="inputPrompt">
<p id="promptText"></p>
<div class="button-grid">
<button onclick="submitInput('0')">0</button>
<button onclick="submitInput('1')">1</button>
<button onclick="submitInput('2')">2</button>
<button onclick="submitInput('3')">3</button>
<button onclick="submitInput('4')">4</button>
<button onclick="submitInput('5')">5</button>
<button onclick="submitInput('6')">6</button>
<button onclick="submitInput('7')">7</button>
<button onclick="submitInput('8')">8</button>
<button onclick="submitInput('9')">9</button>
<button onclick="submitInput('n')">n</button>
</div>
</div>
</div>
<p id="loadingProgress"></p>
<p id="currentProgress"></p>
</div>
<!-- Completion Page -->
<div id="completionPage">
<h1 id="completionTitle"></h1>
<p id="completionMessage"></p>
</div>
<script>
let emailInput, chineseNameInput, englishNameInput, welcomePage, videoPage, mainPage, completionPage, frameDisplay, inputPrompt, loadingProgress, currentProgress, mainTitle, rulesTitle, rulesList, promptText, completionTitle, completionMessage, videoLink, watchButton;
let modules = [];
let selectedModules = [];
let currentModuleIndex = 0;
let currentFrameIndex = 0;
let collectedData = [];
let userEmail = '';
let chineseName = '无';
let englishName = '';
let language = 'en'; // Default language
let isLoadingComplete = false;
let loadedModulesCount = 0;
const MODULE_COUNT = 101;
const SELECTED_MODULE_COUNT = 100;
const FRAME_INTERVAL = 20;
const BASE_URL = 'https://pub-157150daba934ac3a4a79a4320fe036b.r2.dev/';
const GOOGLE_FORM_URL = 'https://docs.google.com/forms/u/0/d/e/1FAIpQLSfusBxX1cNbsastoKk1CwRMNt6lNvZ2290zl2XQe0zBWP1wQQ/formResponse';
const VIDEO_URLS = {
en: 'https://www.youtube.com/watch?v=C9lpa5mG3yo',
zh: 'https://www.bilibili.com/video/BV1ZYEjzzEio/?vd_source=11e61e0995cba4205ba764742292d687'
};
const VIDEO_LINK_TEXT = {
en: 'Click to Watch the Rules Video',
zh: '点击观看规则视频'
};
const translations = {
zh: {
mainTitle: '屏幕上正在写什么数字?(请不要刷新页面)',
rulesTitle: '规则说明',
rules: [
'我们将逐帧展示某个数字的书写过程。',
'请在书写过程中判断这个数字是什么。',
'如果信息不足,可以选择“n”跳到下一帧。',
'如果首次判断错误也没关系,您可以在后续帧中更改选择。'
],
promptText: '请选择你的判断结果:',
loadingImages: '加载图片中...',
loadingModules: (modules) => `加载模块 ${modules.join(', ')}...`,
firstModuleLoaded: '第一个模块加载完成,开始展示',
firstModuleFailed: '第一个模块加载失败,请检查图片路径',
allModulesLoaded: '所有模块加载完成',
moduleProgress: (progress, loaded, total) => `加载进度:${progress}% (${loaded}/${total} 模块)`,
currentProgress: (current, total) => `当前进度:${current}/${total}`,
moduleFailed: (moduleNum) => `模块 ${moduleNum} 加载失败,帧数为 0`,
allModulesDone: '所有模块已展示,数据已收集',
dataRecorded: (time, input) => `已记录:时间=${time}s, 选择=${input}`,
errorIndex: '错误:模块索引超出范围',
errorModule: '错误:当前模块未加载',
errorFrame: '错误:帧数据无效',
alertNoEmail: '请输入您的邮箱!',
alertNoChineseName: '请输入您的中文名!',
alertNoEnglishName: '请输入您的英文名!',
invalidInput: '无效输入,请仔细阅读规则并重新判断!',
loadingPrompt: '加载中,请稍候...',
completionTitle: '实验完成',
completionMessage: (email, chineseName, englishName) => `您已完成该实验,感谢参与<br>您的邮箱是:${email}<br>您的中文名是:${chineseName}<br>您的英文名是:${englishName}<br>请将本页面截屏与您的收款信息(如微信/银行收款码)发至<a href="mailto:sguoau@connect.ust.hk">sguoau@connect.ust.hk</a>以便后续支付薪酬`
},
en: {
mainTitle: 'What Number is Being Written on the Screen? (Please do not refresh the page)',
rulesTitle: 'Rules',
rules: [
'We will show the writing process of a number frame by frame.',
'Please identify the actual number being written.',
'If there’s not enough information, select “n” to skip to the next frame.',
'It’s okay if your first guess is wrong—you can change your choice in later frames.'
],
promptText: 'Please select your judgment result:',
loadingImages: 'Loading images...',
loadingModules: (modules) => `Loading modules ${modules.join(', ')}...`,
firstModuleLoaded: 'First module loaded, starting display',
firstModuleFailed: 'First module failed to load, please check image paths',
allModulesLoaded: 'All modules loaded',
moduleProgress: (progress, loaded, total) => `Loading progress: ${progress}% (${loaded}/${total} modules)`,
currentProgress: (current, total) => `Current Progress: ${current}/${total}`,
moduleFailed: (moduleNum) => `Module ${moduleNum} failed to load, frame count is 0`,
allModulesDone: 'All modules displayed, data collected',
dataRecorded: (time, input) => `Recorded: Time=${time}s, Selection=${input}`,
errorIndex: 'Error: Module index out of range',
errorModule: 'Error: Current module not loaded',
errorFrame: 'Error: Frame data invalid',
alertNoEmail: 'Please enter your email!',
alertNoChineseName: 'Please enter your Chinese name!',
alertNoEnglishName: 'Please enter your English name!',
invalidInput: 'Invalid input, please read the rules carefully and try again!',
loadingPrompt: 'Loading, please wait...',
completionTitle: 'Experiment Completed',
completionMessage: (email, chineseName, englishName) => `You have completed the experiment, thank you for your participation.<br>Your email is: ${email}<br>Your Chinese name is: ${chineseName}<br>Your English name is: ${englishName}<br>Please take a screenshot of this page and send it along with your payment information (e.g., WeChat/bank payment code) to <a href="mailto:sguoau@connect.ust.hk">sguoau@connect.ust.hk</a> for subsequent compensation.`
}
};
function initializeDOMElements() {
emailInput = document.getElementById('emailInput');
chineseNameInput = document.getElementById('chineseNameInput');
englishNameInput = document.getElementById('englishNameInput');
welcomePage = document.getElementById('welcomePage');
videoPage = document.getElementById('videoPage');
mainPage = document.getElementById('mainPage');
completionPage = document.getElementById('completionPage');
frameDisplay = document.getElementById('frameDisplay');
inputPrompt = document.getElementById('inputPrompt');
loadingProgress = document.getElementById('loadingProgress');
currentProgress = document.getElementById('currentProgress');
mainTitle = document.getElementById('mainTitle');
rulesTitle = document.getElementById('rulesTitle');
rulesList = document.getElementById('rulesList');
promptText = document.getElementById('promptText');
completionTitle = document.getElementById('completionTitle');
completionMessage = document.getElementById('completionMessage');
videoLink = document.getElementById('videoLink');
watchButton = document.getElementById('watchButton');
}
function updateMainPageContent() {
const t = translations[language];
mainTitle.textContent = t.mainTitle;
rulesTitle.textContent = t.rulesTitle;
rulesList.innerHTML = t.rules.map(rule => `<li>${rule}</li>`).join('');
promptText.textContent = t.promptText;
loadingProgress.textContent = t.loadingImages;
currentProgress.textContent = t.currentProgress(0, SELECTED_MODULE_COUNT);
}
function updateCompletionPageContent() {
const t = translations[language];
completionTitle.textContent = t.completionTitle;
completionMessage.innerHTML = t.completionMessage(userEmail, chineseName, englishName);
}
function extractModuleNumber(path) {
const match = path.match(/module_(\d+)/);
if (match && match[1]) {
return Number(match[1]);
}
console.error('Unable to extract module number from path:', path);
return 0;
}
function shuffleModules() {
const moduleIndices = Array.from({ length: MODULE_COUNT }, (_, i) => i + 1).filter(num => num !== 66);
for (let i = moduleIndices.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[moduleIndices[i], moduleIndices[j]] = [moduleIndices[j], moduleIndices[i]];
}
const selected = moduleIndices;
console.log('Selected modules:', selected);
return selected.map(num => Number(num));
}
async function loadModuleFrames(moduleNum) {
const frames = [];
let attemptIndex = 1;
const maxAttempts = 1000;
const failedFrames = [];
while (attemptIndex <= maxAttempts) {
const frameUrl = `${BASE_URL}module_${moduleNum}/module_${moduleNum}_frame_${attemptIndex}.png`;
const img = new Image();
img.src = frameUrl;
const loaded = await new Promise(resolve => {
img.onload = () => resolve(true);
img.onerror = () => resolve(false);
});
if (loaded) {
frames.push({
url: frameUrl,
time: (frames.length * FRAME_INTERVAL) / 1000,
module: moduleNum
});
console.log(`Loaded frame: ${frameUrl}`);
} else {
failedFrames.push(frameUrl);
console.log(`Frame ${frameUrl} not found (404), ending module ${moduleNum} at frame ${attemptIndex}`);
break; // Stop loading this module on the first failure
}
attemptIndex++;
}
if (frames.length === 0) {
console.error(`Module ${moduleNum} failed to load any frames. Attempted URLs:`, failedFrames);
} else {
console.log(`Module ${moduleNum} loaded successfully with ${frames.length} frames`);
}
return frames;
}
async function preloadFrames() {
const preloadStatus = document.getElementById('preloadStatus');
selectedModules = shuffleModules();
console.log('Selected modules:', selectedModules);
preloadStatus.textContent = translations[language].loadingModules(selectedModules);
loadedModulesCount = 0;
const totalModules = selectedModules.length;
const failedModules = [];
for (const moduleNum of selectedModules) {
const frames = await loadModuleFrames(moduleNum);
if (frames.length > 0) {
modules.push(frames);
loadedModulesCount++;
const progress = Math.round((loadedModulesCount / totalModules) * 100);
preloadStatus.textContent = translations[language].moduleProgress(progress, loadedModulesCount, totalModules);
if (mainPage.style.display === 'block') {
loadingProgress.textContent = translations[language].moduleProgress(progress, loadedModulesCount, totalModules);
if (loadedModulesCount === 1 && currentModuleIndex === 0) {
showNextFrame();
}
}
} else {
failedModules.push(moduleNum);
console.warn(`Module ${moduleNum} failed to load any frames`);
}
}
if (modules.length === 0) {
preloadStatus.textContent = `${translations[language].firstModuleFailed} Failed modules: ${failedModules.join(', ')}. Contact support: sguoau@connect.ust.hk`;
if (mainPage.style.display === 'block') {
loadingProgress.textContent = `${translations[language].firstModuleFailed} Contact support: sguoau@connect.ust.hk`;
}
} else {
isLoadingComplete = true;
preloadStatus.textContent = translations[language].allModulesLoaded;
if (mainPage.style.display === 'block') {
loadingProgress.textContent = translations[language].allModulesLoaded;
}
}
console.log('Loaded modules:', modules);
}
function showNextFrame() {
if (currentModuleIndex >= modules.length && !isLoadingComplete) {
frameDisplay.src = '';
inputPrompt.style.display = 'none';
loadingProgress.textContent = translations[language].loadingPrompt;
currentProgress.textContent = translations[language].currentProgress(currentModuleIndex + 1, SELECTED_MODULE_COUNT);
return;
}
if (currentModuleIndex >= modules.length && isLoadingComplete) {
console.log('Collected data:', collectedData);
mainPage.style.display = 'none';
completionPage.style.display = 'block';
updateCompletionPageContent();
return;
}
const currentModule = modules[currentModuleIndex];
if (!currentModule || currentModule.length === 0) {
frameDisplay.src = '';
inputPrompt.style.display = 'none';
loadingProgress.textContent = translations[language].loadingPrompt;
currentProgress.textContent = translations[language].currentProgress(currentModuleIndex + 1, SELECTED_MODULE_COUNT);
return;
}
if (currentFrameIndex >= currentModule.length) {
currentModuleIndex++;
currentFrameIndex = 0;
showNextFrame();
return;
}
const frame = currentModule[currentFrameIndex];
frameDisplay.src = frame.url;
inputPrompt.style.display = 'block';
if (!isLoadingComplete) {
loadingProgress.textContent = translations[language].moduleProgress(
Math.round((loadedModulesCount / SELECTED_MODULE_COUNT) * 100),
loadedModulesCount,
SELECTED_MODULE_COUNT
);
} else {
loadingProgress.textContent = translations[language].allModulesLoaded;
}
currentProgress.textContent = translations[language].currentProgress(currentModuleIndex + 1, SELECTED_MODULE_COUNT);
}
async function sendToGoogleSheets(data) {
try {
const moduleValue = data.module;
console.log('Module value sent:', moduleValue);
const formData = new FormData();
formData.append('entry.735277437', moduleValue.toString()); // Module
formData.append('entry.690842731', data.email); // Email
formData.append('entry.5521573744', data.videoTime); // Video Time
formData.append('entry.540771953', data.userInput); // User Input
formData.append('entry.1784624963', data.chineseName); // Chinese Name
formData.append('entry.869351757', data.englishName); // English Name
const response = await fetch(GOOGLE_FORM_URL, {
method: 'POST',
body: formData,
mode: 'no-cors'
});
console.log('Data sent to Google Forms:', data);
} catch (error) {
console.error('Error sending data to Google Forms:', error);
}
}
function submitInput(value) {
console.log(`Button clicked, value: ${value}`);
console.log(`Current module index: ${currentModuleIndex}, Selected module: ${selectedModules[currentModuleIndex]}`);
console.log(`Current email: ${userEmail}, Chinese name: ${chineseName}, English name: ${englishName}`);
if (currentModuleIndex >= modules.length || currentModuleIndex < 0) {
console.error('Module index out of range:', currentModuleIndex);
alert(translations[language].errorIndex);
return;
}
const currentModule = modules[currentModuleIndex];
if (!currentModule) {
console.error('Current module not loaded:', currentModuleIndex);
alert(translations[language].errorModule);
return;
}
if (currentFrameIndex >= currentModule.length || currentFrameIndex < 0) {
console.error('Frame index out of range:', { currentModuleIndex, currentFrameIndex, moduleLength: currentModule.length });
currentModuleIndex++;
currentFrameIndex = 0;
showNextFrame();
return;
}
const frame = currentModule[currentFrameIndex];
if (!frame) {
console.error('Invalid frame data:', frame);
alert(translations[language].errorFrame);
return;
}
if (currentFrameIndex === 0 && value !== 'n') {
alert(translations[language].invalidInput);
return;
}
const data = {
timestamp: new Date().toISOString(),
email: userEmail || 'unknown',
chineseName: chineseName || 'N/A',
englishName: englishName || 'N/A',
module: frame.module,
videoTime: frame.time ? frame.time.toFixed(2) : '0.00',
userInput: value
};
console.log('Data to send:', data);
collectedData.push(data);
console.log(translations[language].dataRecorded(data.videoTime, data.userInput));
sendToGoogleSheets(data);
currentFrameIndex++;
if (currentFrameIndex >= currentModule.length) {
currentModuleIndex++;
currentFrameIndex = 0;
}
showNextFrame();
}
function startExperiment(lang) {
try {
userEmail = emailInput.value.trim();
if (!chineseNameInput.value.trim()){
chineseName = '无';
}
else{
chineseName = chineseNameInput.value.trim();
}
englishName = englishNameInput.value.trim();
if (!userEmail) {
alert(translations[language].alertNoEmail);
return;
}
if (!chineseName) {
alert(translations[language].alertNoChineseName);
return;
}
if (!englishName) {
alert(translations[language].alertNoEnglishName);
return;
}
language = lang;
console.log('User email:', userEmail, 'Chinese name:', chineseName, 'English name:', englishName, 'Selected language:', language);
welcomePage.style.display = 'none';
videoPage.style.display = 'flex';
videoLink.href = VIDEO_URLS[language];
videoLink.textContent = VIDEO_LINK_TEXT[language];
watchButton.disabled = true;
console.log('Video link set to:', VIDEO_URLS[language]);
setTimeout(() => {
watchButton.disabled = false;
console.log('Video presumed watched, enabling button');
}, 30000);
} catch (error) {
console.error('Error in startExperiment:', error);
alert('发生错误,请检查控制台日志并联系支持团队:sguoau@connect.ust.hk');
}
}
function proceedToMainPage() {
if (!watchButton.disabled) {
videoPage.style.display = 'none';
mainPage.style.display = 'block';
updateMainPageContent();
showNextFrame();
} else {
alert('请观看视频至结束后再点击确认。/ Please watch the video until the end before proceeding.');
}
}
document.addEventListener('DOMContentLoaded', () => {
initializeDOMElements();
preloadFrames();
});
</script>
<script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'93e8e2b7dd3c458f',t:'MTc0NzA0MjEwMy4wMDAwMDA='};var a=document.createElement('script');a.nonce='';a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script>
</body>
</html>