@@ -11,6 +11,7 @@ const save = document.getElementById("save"); // 收藏
1111const remove = document . getElementById ( "remove" ) ; // 删除
1212const first = document . getElementById ( "first" ) ; // 首:加载第一张收藏
1313const last = document . getElementById ( "last" ) ; // 尾:加载最后一张收藏
14+ const changeType = document . getElementById ( "changeType" ) ; // 切换类型:仅收藏、全部的
1415const prev = document . getElementById ( "prev" ) ; // 上一张
1516const 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