Skip to content

Commit 12cd1ea

Browse files
新增切换类型按钮。
1 parent 67bd220 commit 12cd1ea

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

p/index.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
img:first-child, img.hidden{margin-top:0}
1515

1616
.mobile #tools{top:auto;bottom:0}
17-
.mobile #imgs{margin-top:0;padding-bottom:80px}
18-
.mobile #imgs img:last-child{margin-bottom:80px}
17+
.mobile #imgs{margin-top:0;padding-bottom:72px}
18+
.mobile #imgs img:last-child{margin-bottom:70px}
1919

2020
#configs{position:fixed;left:0;bottom:0;z-index:2;background-color:#efefef;border:1px solid #aaa;padding:5px;width:100%;display:none}
2121
.mobile #configs{top:0;bottom:auto}
@@ -33,15 +33,16 @@
3333
<div id="bottons">
3434
<input id="auto" type="button" value="手动"/>
3535

36-
<input id="save" type="button" value="收藏" style="margin-left:10px"/>
36+
<input id="save" type="button" value="收藏" style="margin-left:5px"/>
3737
<input id="remove" type="button" value="删除"/>
3838
<input id="first" type="button" value=""/>
3939
<input id="last" type="button" value=""/>
4040

41-
<input id="prev" type="button" value="上一张" style="margin-left:10px"/>
41+
<input id="changeType" type="button" value="仅收藏" style="margin-left:5px"/>
42+
<input id="prev" type="button" value="上一张"/>
4243
<input id="next" type="button" value="下一张"/>
4344

44-
<input id="openConfigBtn" type="button" value="配置" style="margin-left:10px"/>
45+
<input id="openConfigBtn" type="button" value="配置" style="margin-left:5px"/>
4546
</div>
4647
</div>
4748

p/index.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const save = document.getElementById("save"); // 收藏
1111
const remove = document.getElementById("remove"); // 删除
1212
const first = document.getElementById("first"); // 首:加载第一张收藏
1313
const last = document.getElementById("last"); // 尾:加载最后一张收藏
14+
const changeType = document.getElementById("changeType"); // 切换类型:仅收藏、全部的
1415
const prev = document.getElementById("prev"); // 上一张
1516
const next = document.getElementById("next"); // 下一张
1617

@@ -122,6 +123,15 @@ let inFocus = false; // 输入框是否获取到了焦点
122123
}
123124
});
124125

126+
// “切换类型” 按钮点击事件
127+
changeType.addEventListener("click", function () {
128+
if (changeType.value === '仅收藏') {
129+
changeType.value = '全部的';
130+
} else {
131+
changeType.value = '仅收藏';
132+
}
133+
});
134+
125135
// “上一张” 按钮点击事件
126136
prev.addEventListener("click", doPrev);
127137

@@ -418,7 +428,7 @@ function doPrev () {
418428
}
419429

420430
const savePidList = getSavePidList();
421-
if (savePidList.length > 0) {
431+
if (savePidList.length > 0 && changeType.value === '仅收藏') {
422432
let i = 0;
423433
for (; i < savePidList.length; i++) {
424434
const savePid = savePidList[i];
@@ -439,7 +449,11 @@ function doPrev () {
439449
}
440450
} else {
441451
input.value = pid - 1;
442-
input.style.backgroundColor = '';
452+
if (changeType.value === '全部的') {
453+
isInSavePidList();
454+
} else {
455+
input.style.backgroundColor = '';
456+
}
443457
}
444458
doEnter();
445459
}
@@ -452,7 +466,7 @@ function doNext () {
452466
}
453467

454468
const savePidList = getSavePidList();
455-
if (savePidList.length > 0) {
469+
if (savePidList.length > 0 && changeType.value === '仅收藏') {
456470
let i = savePidList.length - 1;
457471
for (; i >= 0; i--) {
458472
const savePid = savePidList[i];
@@ -473,7 +487,11 @@ function doNext () {
473487
}
474488
} else {
475489
input.value = pid + 1;
476-
input.style.backgroundColor = '';
490+
if (changeType.value === '全部的') {
491+
isInSavePidList();
492+
} else {
493+
input.style.backgroundColor = '';
494+
}
477495
}
478496
doEnter();
479497
}

0 commit comments

Comments
 (0)