-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
397 lines (354 loc) · 14.3 KB
/
Copy pathindex.html
File metadata and controls
397 lines (354 loc) · 14.3 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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User-Study Server</title>
<link rel="stylesheet" href="/css/cube.css">
<link rel="stylesheet" href="/style.css">
<style>
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
margin: 20px;
background-color: #e9ecef; /* 使用更柔和的背景颜色 */
}
h1 {
color: #343a40; /* 深色标题 */
text-align: center;
margin-bottom: 30px;
}
option {
color: #495057;
}
output {
margin: 20px auto;
background: #f8f9fa; /* 更加柔和的结果背景 */
border-radius: 5px;
padding: 15px;
color: #495057; /* 深色结果文字 */
border: 1px solid #ced4da; /* 添加边框 */
}
.container {
max-width: 1000px; /* 限制宽度 */
}
.link-section {
display: flex;
justify-content: space-between; /* 中间填充 */
align-items: center;
flex-direction: row;
margin-bottom: 10px; /* 各个链接区域之间的间隔 */
}
.vertical-section {
display: flex;
flex-direction: column;
}
select {
padding: 10px;
border: 1px solid #ced4da;
color: #495057;
border-radius: 5px;
width: 150px;
transition: border-color 0.3s; /* 添加过渡效果 */
}
select:focus {
border-color: #80bdff; /* 当前输入框边框高亮 */
}
/* before after image slider */
.slider-container {
position: relative;
width: 600px;
height: 400px;
margin: 20px auto;
border: 2px solid white;
display: flex;
justify-content: center;
align-items: center;
.img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-size: 600px 100%;
display: flex;
}
.background-img {
background-image: none;
}
.foreground-img {
background-image: none;
width: calc(50% - 2px);
}
.slider {
position: absolute;
-webkit-appearance: none;
appearance: none;
width: 100%;
height: 100%;
background: #f2f2f211;
outline: none;
margin: 0;
transition: all 0.2s;
display: flex;
justify-content: center;
align-items: center;
&:hover {
background: #f2f2f200;
}
&::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 4px;
height: 400px;
background: white;
cursor: pointer;
}
&::-moz-range-thumb {
width: 4px;
height: 400px;
background: white;
cursor: pointer;
}
}
.slider-button {
pointer-events: none;
position: absolute;
width: 30px;
height: 30px;
border-radius: 50%;
background-color: white;
left: calc(50% - 19px);
top: calc(50% - 19px);
display: flex;
justify-content: center;
align-items: center;
&:after {
content: "";
padding: 3px;
display: inline-block;
border: solid #5d5d5d;
border-width: 0 2px 2px 0;
transform: rotate(-45deg);
}
&:before {
content: "";
padding: 3px;
display: inline-block;
border: solid #5d5d5d;
border-width: 0 2px 2px 0;
transform: rotate(135deg);
}
}
}
</style>
<script src="/js/cube.js"></script>
<script>
function populateGroups(html_id) {
const groupSelect = document.getElementById(html_id);
fetch('/image_groups')
.then(response => response.json())
.then(data => {
data.groups.forEach(group => {
const option = document.createElement('option');
option.value = group;
option.textContent = group;
groupSelect.appendChild(option);
});
})
.catch(error => {
console.error("获取数据时出错:", error); // 错误处理
});
}
function populateIds(group, html_id) {
const idSelect = document.getElementById(html_id);
// 获取当前选择的 id
const currentValue = idSelect.value;
// 清空之前的内容
idSelect.innerHTML = ''; // 清空之前的内容
if (!group) return;
fetch(`/image_ids?group=${group}`)
.then(response => response.json())
.then(data => {
let anyExists = false;
data.ids.forEach(id => {
const option = document.createElement('option');
option.value = id;
option.textContent = id;
idSelect.appendChild(option);
if (id === currentValue) {
anyExists = true;
}
});
// 如果 data 中包含之前选择的 id,则还原之前选择的 id
if (currentValue && anyExists) {
idSelect.value = currentValue;
}
})
.catch(error => {
console.error("获取数据时出错:", error); // 错误处理
});
}
function updateLink1() {
// const groupValue = document.getElementById('groupInput-1').value;
// const idValue = document.getElementById('idInput-1').value;
const groupValue = document.getElementById('groupSelect-1').value;
const idValue = document.getElementById('idSelect-1').value;
let beforeImageUrl = `/image?group=input&id=${idValue || '00690'}`;
let afterImageUrl = `/image?group=${groupValue || 'FourLLIE'}&id=${idValue || '00690'}`;
document.getElementById('link-1').href = afterImageUrl
document.getElementById('group-name-1').textContent = groupValue || 'FourLLIE';
document.getElementById('image-id-1').textContent = idValue || '00690';
// 获取并显示图片
displayBeforeAfterImage('output-1', beforeImageUrl, afterImageUrl);
}
function updateLink2() {
const groupValue = document.getElementById('groupSelect-2').value;
const idValue = document.getElementById('idSelect-2').value;
let beforeImageUrl = `/image?group=input&id=${idValue || '00690'}`;
let afterImageUrl = `/images/${groupValue || 'FourLLIE'}/${idValue ? idValue + '.png' : '00690.png'}`;
document.getElementById('link-2').href = afterImageUrl
document.getElementById('group-name-2').textContent = groupValue || 'FourLLIE';
document.getElementById('image-id-2').textContent = (idValue ? idValue + '.png' : '00690.png');
// 获取并显示图片
displayBeforeAfterImage('output-2', beforeImageUrl, afterImageUrl);
}
function fetchImageIds() {
const output = document.getElementById('output-3');
const groupValue = document.getElementById('groupInput-3').value;
let _url = `/image_ids`;
if (groupValue) {
_url = `/image_ids?group=${groupValue}`;
document.getElementById('group-name-3').textContent = groupValue;
}
else {
_url = `/image_ids`;
document.getElementById('group-name-3').textContent = '';
}
document.getElementById('link-3').textContent = _url;
fetch(_url)
.then(response => response.text())
.then(text => {
output.innerHTML = text;
})
.catch(error => {
output.innerHTML = "请求失败:" + error;
});
}
function fetchImageGroups() {
const output = document.getElementById('output-4');
const link = document.getElementById('link-4');
fetch(link.href)
.then(response => response.text())
.then(text => {
output.innerHTML = text;
})
.catch(error => {
output.innerHTML = "请求失败:" + error;
});
}
function displayBeforeAfterImage(outputId, beforeImageUrl, afterimageUrl) {
const output = document.getElementById(outputId);
output.innerHTML = `
<div class='center'>
<div class='slider-container' id="slider-container-${outputId}">
<div class='img background-img' style="background-image: url(${afterimageUrl})" id="before-${outputId}"></div>
<div class='img foreground-img' style="background-image: url(${beforeImageUrl})" id="after-${outputId}"></div>
<input type="range" min="1" max="100" value="50" class="slider" name='slider' id="slider-${outputId}">
<div class='slider-button' id="slider-button-${outputId}"></div>
</div>
</div>`;
/* before after image slider */
const slider = document.getElementById(`slider-${outputId}`);
const afterImage = document.getElementById(`after-${outputId}`);
const sliderButton = document.getElementById(`slider-button-${outputId}`);
slider.addEventListener('input', (e) => {
const sliderPos = e.target.value;
// 更新前景图像的宽度
afterImage.style.width = `calc(${sliderPos}% - 2px)`;
// 更新滑动按钮的位置
sliderButton.style.left = `calc(${sliderPos}% - 18px)`;
});
}
window.onload = () => {
populateGroups('groupSelect-1');
document.getElementById('groupSelect-1').addEventListener('change', (event) => {
populateIds(event.target.value, 'idSelect-1');
});
populateGroups('groupSelect-2');
document.getElementById('groupSelect-2').addEventListener('change', (event) => {
populateIds(event.target.value, 'idSelect-2');
});
updateLink1();
updateLink2();
fetchImageIds();
fetchImageGroups();
// 正方体动画
cubeInit();
}
</script>
</head>
<body>
<h1>User-Study Server</h1>
<div class="container">
<div class="vertical-section">
<div class="link-section">
<h4>链接:<a id="link-1" href="/image?group=FourLLIE&id=00690">/image?group=<span id="group-name-1">FourLLIE</span>&id=<span id="image-id-1">00690</span></a></h4>
<div>
<select id="groupSelect-1" onchange="updateLink1()">
<option value="">选择 group</option>
</select>
<select id="idSelect-1" onchange="updateLink1()">
<option value="">选择 id</option>
</select>
<button onclick="updateLink1()">更新链接</button>
</div>
</div>
<div class="divider"></div>
<div id="output-1"></div>
</div>
</div>
<div class="container">
<div class="vertical-section">
<div class="link-section">
<h4>链接:<a id="link-2" href="/images/FourLLIE/00690.png">/images/<span id="group-name-2">FourLLIE</span>/<span id="image-id-2">00690.png</span></a></h4>
<div>
<select id="groupSelect-2" onchange="updateLink2()">
<option value="">选择 group</option>
</select>
<select id="idSelect-2" onchange="updateLink2()">
<option value="">选择 id</option>
</select>
<button onclick="updateLink2()">更新链接</button>
</div>
</div>
<div class="divider"></div>
<div id="output-2"></div>
</div>
</div>
<div class="container">
<div class="vertical-section">
<div class="link-section">
<h4>链接:<a id="link-3" href="/image_ids">/image_ids<span id="group-name-3"></span></a></h4>
<div>
<input class="input-text" type="text" id="groupInput-3" placeholder="输入 group" />
<button onclick="fetchImageIds()">更新结果</button>
</div>
</div>
<div class="divider"></div>
<output id="output-3"></output>
</div>
</div>
<div class="container">
<div class="vertical-section">
<div class="link-section">
<h4>链接:<a id="link-4" href="/image_groups">/image_groups</a></h4>
<div>
<button onclick="fetchImageGroups()">更新结果</button>
</div>
</div>
<div class="divider"></div>
<output id="output-4"></output>
</div>
</div>
</body>
</html>