-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
290 lines (284 loc) · 11.9 KB
/
index.html
File metadata and controls
290 lines (284 loc) · 11.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
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>User Study For Methodxxx</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
.case-block { margin-bottom: 32px; border: 1px solid #ccc; padding: 16px; border-radius: 8px; }
.case-title { font-weight: bold; margin-bottom: 12px; }
.videos {
display: flex;
gap: 24px;
margin-bottom: 12px;
flex-wrap: wrap;
justify-content: center;
}
.video-item {
flex: 1 1 320px;
min-width: 260px;
max-width: 500px;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
}
select {
font-size: 14px;
padding: 4px 6px;
border: 1px solid #bbb;
border-radius: 6px;
background: #fff;
color: #333;
margin-top: 8px;
margin-bottom: 8px;
outline: none;
transition: border 0.2s, box-shadow 0.2s;
box-shadow: none;
}
select:focus {
border: 1.5px solid #888;
box-shadow: 0 0 4px #e0e0e0;
}
label {
font-size: 15px;
color: #444;
font-weight: 500;
}
.submit-btn { font-size: 18px; padding: 10px 30px; margin-top: 30px; }
video {
width: 100%;
height: auto;
display: block;
margin: 0 auto;
max-width: 500px;
}
.small-video {
max-width: 380px !important;
}
</style>
</head>
<body>
<h1>User Study For Methodxxx</h1>
<div style="color: #000000; font-size: 18px; margin-bottom: 18px;">
注意事项:<br>
1. 每个Case下有3个视频,顺序为A、B、C,但每个字母对应的算法是随机的。<br>
2. 请根据您的主观感受为每个视频选择排序(第一名、第二名、第三名)。<br>
3. 请根据以下标准进行评价:<b>xxx</b>的改善程度,以及<b>xxxx</b>的xxxxx。<br>
4. 所有排序填写完毕后再点击“提交”。<br>
5. 提交后不可更改,请认真填写。
</div>
<form id="userStudyForm">
<div id="casesContainer"></div>
<div style="text-align:center;">
<button type="submit" class="submit-btn">提交</button>
</div>
</form>
<script>
// 随机分配算法到A/B/C
function shuffle(arr) {
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr;
}
// 算法与文件夹名映射
const algorithms = ['Method3', 'Method1', 'Method2'];
const algoFolderMap = { 'Method3': 'Method3', 'Method1': 'Method1', 'Method2': 'Method2' };
// n个视频名,顺序与case一一对应
const videoNameList = [
'case-1',
'case-2',
'case-3',
'case-4',
'case-5',
'case-6',
'case-7',
'case-8',
'case-9',
'case-10'
];
const cases = Array.from({length: videoNameList.length}, (_, i) => `Case-${i+1}`);
const casesContainer = document.getElementById('casesContainer');
const caseAlgoMaps = [];
cases.forEach((caseName, idx) => {
const algoOrder = shuffle(['A', 'B', 'C']);
const algoMap = {};
shuffle([...algorithms]).forEach((alg, i) => algoMap[algoOrder[i]] = alg);
caseAlgoMaps.push({...algoMap});
const block = document.createElement('div');
block.className = 'case-block';
block.innerHTML = `<div class="case-title">${caseName}</div>`;
const videoName = videoNameList[idx];
const originalDiv = document.createElement('div');
originalDiv.style = 'margin-bottom: 10px; text-align: center;';
const btn = document.createElement('button');
btn.type = 'button';
btn.textContent = '查看原视频';
btn.style = [
'margin-bottom: 8px;',
'padding: 6px 18px;',
'font-size: 14px;',
'border: 1px solid #ddd;',
'border-radius: 6px;',
'background: #fff;',
'color: #333;',
'cursor: pointer;',
'transition: background 0.2s, border 0.2s;',
'box-shadow: none;',
'outline: none;'
].join(' ');
btn.onmouseover = function() {
btn.style.background = '#f5f5f5';
btn.style.border = '1.5px solid #bbb';
};
btn.onmouseout = function() {
btn.style.background = '#fff';
btn.style.border = '1px solid #ddd';
};
const oriVideo = document.createElement('video');
oriVideo.style.display = 'none';
oriVideo.controls = true;
oriVideo.addEventListener('loadedmetadata', function() {
if (oriVideo.videoWidth > oriVideo.videoHeight) {
oriVideo.width = 500;
} else {
oriVideo.width = 400;
}
});
if (videoName.includes('dance') || videoName.includes('HPW') || videoName.includes('running')) {
oriVideo.classList.add('small-video');
}
oriVideo.width = 500;
oriVideo.innerHTML = `<source src="videos/original/${videoName}.mp4" type="video/mp4">您的浏览器不支持 video 标签。`;
btn.addEventListener('click', () => {
if (oriVideo.style.display === 'none') {
oriVideo.style.display = '';
btn.textContent = '隐藏原视频';
} else {
oriVideo.style.display = 'none';
btn.textContent = '查看原视频';
}
});
originalDiv.appendChild(btn);
originalDiv.appendChild(document.createElement('br'));
originalDiv.appendChild(oriVideo);
block.appendChild(originalDiv);
const videosDiv = document.createElement('div');
videosDiv.className = 'videos';
algoOrder.forEach((label, i) => {
const videoDiv = document.createElement('div');
videoDiv.className = 'video-item';
const algo = algoMap[label];
videoDiv.setAttribute('data-algo', algo);
const folder = algoFolderMap[algo];
const videoName = videoNameList[idx];
let extraClass = 'dance';
if (videoName.includes('dance') || videoName.includes('HPW') || videoName.includes('running')) {
extraClass = ' small-video';
}
const videoId = `algo_video_${idx}_${i}`;
videoDiv.innerHTML = `
<div>视频 ${['A','B','C'][i]}</div>
<video id="${videoId}" class="algo-video${extraClass}" controls>
<source src="videos/${folder}/${videoName}.mp4" type="video/mp4">
您的浏览器不支持 video 标签。
</video>
<div>
<label>排序:
<select name="case${idx+1}_${label}" required>
<option value="">请选择</option>
<option value="1">第一名</option>
<option value="2">第二名</option>
<option value="3">第三名</option>
</select>
</label>
</div>
`;
setTimeout(() => {
const algoVideo = document.getElementById(videoId);
if (algoVideo) {
algoVideo.addEventListener('loadedmetadata', function() {
if (algoVideo.videoWidth > algoVideo.videoHeight) {
algoVideo.width = 500;
} else {
algoVideo.width = 400;
}
});
}
}, 0);
videosDiv.appendChild(videoDiv);
});
block.appendChild(videosDiv);
casesContainer.appendChild(block);
});
document.querySelectorAll('.case-block').forEach(block => {
const selects = block.querySelectorAll('select');
selects.forEach(sel => {
sel.addEventListener('change', () => {
const values = Array.from(selects).map(s => s.value).filter(v => v);
selects.forEach(s => {
Array.from(s.options).forEach(opt => {
if(opt.value && values.includes(opt.value) && s.value !== opt.value) {
opt.disabled = true;
} else {
opt.disabled = false;
}
});
});
});
});
});
document.getElementById('userStudyForm').addEventListener('submit', function(e) {
e.preventDefault();
const data = {};
cases.forEach((caseName, idx) => {
const algoRank = {};
['A','B','C'].forEach(label => {
const sel = document.querySelector(`[name=case${idx+1}_${label}]`);
const algo = caseAlgoMaps[idx][label];
algoRank[algo] = sel.value;
});
const sortedAlgoRank = Object.keys(algoRank).sort().reduce((acc, key) => {
acc[key] = algoRank[key];
return acc;
}, {});
data[caseName] = sortedAlgoRank;
});
fetch('/save_result', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
}).then(res => {
if (res.ok) {
alert('感谢您的参与!\n您的排序结果已提交到服务器。');
window.location.reload(); // 提交成功后刷新页面,防止重复提交
} else {
alert('提交失败,请重试。');
}
}).catch(() => {
alert('提交失败,请检查网络或联系管理员。');
});
console.log(data);
});
const submitBtn = document.querySelector('.submit-btn');
if (submitBtn) {
submitBtn.style.background = '#fff';
submitBtn.style.color = '#333';
submitBtn.style.border = '1px solid #ddd';
submitBtn.style.borderRadius = '6px';
submitBtn.style.boxShadow = 'none';
submitBtn.style.transition = 'background 0.2s, border 0.2s';
submitBtn.onmouseover = function() {
submitBtn.style.background = '#f5f5f5';
submitBtn.style.border = '1.5px solid #bbb';
};
submitBtn.onmouseout = function() {
submitBtn.style.background = '#fff';
submitBtn.style.border = '1px solid #ddd';
};
}
</script>
</body>
</html>