| ... | ... | @@ -4013,9 +4013,10 @@ Happy writing! |
| 4013 | 4013 | return; |
| 4014 | 4014 | } |
| 4015 | 4015 | |
| 4016 | | let liDom = domListSearchResults.children[curSearchIndex]; |
| 4017 | | if (liDom == null && domListSearchResults.children.length !== 0) { |
| 4018 | | liDom = domListSearchResults.children[0]; |
| 4016 | const searchResults = domListSearchResults.getElementsByTagName("li"); |
| 4017 | let liDom = searchResults[curSearchIndex]; |
| 4018 | if (liDom == null && searchResults.length !== 0) { |
| 4019 | liDom = searchResults[0]; |
| 4019 | 4020 | } |
| 4020 | 4021 | if (liDom != null) { |
| 4021 | 4022 | let aDom = liDom.children[0]; |
| ... | ... | @@ -4110,14 +4111,15 @@ Happy writing! |
| 4110 | 4111 | } |
| 4111 | 4112 | |
| 4112 | 4113 | function moveSearchCursor(dir) { |
| 4114 | const searchResults = domListSearchResults.getElementsByTagName("li"); |
| 4113 | 4115 | if ( |
| 4114 | 4116 | curSearchIndex < 0 || |
| 4115 | | curSearchIndex >= domListSearchResults.children.length |
| 4117 | curSearchIndex >= searchResults.length |
| 4116 | 4118 | ) { |
| 4117 | 4119 | if (dir > 0) { |
| 4118 | 4120 | curSearchIndex = -1 + dir; |
| 4119 | 4121 | } else if (dir < 0) { |
| 4120 | | curSearchIndex = domListSearchResults.children.length + dir; |
| 4122 | curSearchIndex = searchResults.length + dir; |
| 4121 | 4123 | } |
| 4122 | 4124 | } else { |
| 4123 | 4125 | curSearchIndex += dir; |
| ... | ... | @@ -4125,8 +4127,8 @@ Happy writing! |
| 4125 | 4127 | if (curSearchIndex < 0) { |
| 4126 | 4128 | curSearchIndex = 0; |
| 4127 | 4129 | } |
| 4128 | | if (curSearchIndex >= domListSearchResults.children.length) { |
| 4129 | | curSearchIndex = domListSearchResults.children.length - 1; |
| 4130 | if (curSearchIndex >= searchResults.length) { |
| 4131 | curSearchIndex = searchResults.length - 1; |
| 4130 | 4132 | } |
| 4131 | 4133 | renderSearchCursor(); |
| 4132 | 4134 | } |
| ... | ... | @@ -4465,8 +4467,9 @@ Happy writing! |
| 4465 | 4467 | |
| 4466 | 4468 | |
| 4467 | 4469 | function renderSearchCursor() { |
| 4468 | | for (let i = 0; i < domListSearchResults.children.length; i += 1) { |
| 4469 | | let liDom = domListSearchResults.children[i]; |
| 4470 | const searchResults = domListSearchResults.getElementsByTagName("li"); |
| 4471 | for (let i = 0; i < searchResults.length; i += 1) { |
| 4472 | let liDom = searchResults[i]; |
| 4470 | 4473 | if (curSearchIndex === i) { |
| 4471 | 4474 | liDom.classList.add("selected"); |
| 4472 | 4475 | } else { |