Skip to content

Commit

Permalink
新增切换类型按钮。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed May 18, 2024
1 parent 67bd220 commit 12cd1ea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
11 changes: 6 additions & 5 deletions p/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
img:first-child, img.hidden{margin-top:0}

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

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

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

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

<input id="openConfigBtn" type="button" value="配置" style="margin-left:10px"/>
<input id="openConfigBtn" type="button" value="配置" style="margin-left:5px"/>
</div>
</div>

Expand Down
26 changes: 22 additions & 4 deletions p/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const save = document.getElementById("save"); // 收藏
const remove = document.getElementById("remove"); // 删除
const first = document.getElementById("first"); // 首:加载第一张收藏
const last = document.getElementById("last"); // 尾:加载最后一张收藏
const changeType = document.getElementById("changeType"); // 切换类型:仅收藏、全部的
const prev = document.getElementById("prev"); // 上一张
const next = document.getElementById("next"); // 下一张

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

// “切换类型” 按钮点击事件
changeType.addEventListener("click", function () {
if (changeType.value === '仅收藏') {
changeType.value = '全部的';
} else {
changeType.value = '仅收藏';
}
});

// “上一张” 按钮点击事件
prev.addEventListener("click", doPrev);

Expand Down Expand Up @@ -418,7 +428,7 @@ function doPrev () {
}

const savePidList = getSavePidList();
if (savePidList.length > 0) {
if (savePidList.length > 0 && changeType.value === '仅收藏') {
let i = 0;
for (; i < savePidList.length; i++) {
const savePid = savePidList[i];
Expand All @@ -439,7 +449,11 @@ function doPrev () {
}
} else {
input.value = pid - 1;
input.style.backgroundColor = '';
if (changeType.value === '全部的') {
isInSavePidList();
} else {
input.style.backgroundColor = '';
}
}
doEnter();
}
Expand All @@ -452,7 +466,7 @@ function doNext () {
}

const savePidList = getSavePidList();
if (savePidList.length > 0) {
if (savePidList.length > 0 && changeType.value === '仅收藏') {
let i = savePidList.length - 1;
for (; i >= 0; i--) {
const savePid = savePidList[i];
Expand All @@ -473,7 +487,11 @@ function doNext () {
}
} else {
input.value = pid + 1;
input.style.backgroundColor = '';
if (changeType.value === '全部的') {
isInSavePidList();
} else {
input.style.backgroundColor = '';
}
}
doEnter();
}
Expand Down

0 comments on commit 12cd1ea

Please sign in to comment.