on master help sign in
Fix not jumping to results loaded by infinite scroll

Infinite scroll adds a `hr` tag to split up the sections loaded by it. The vim bindings `j` and `k`, which jump to the next and previous result respectively, search for a **direct** sibling with the class `result`. With the `hr` between results a direct sibling cannot be found. To fix this we remove the restriction of it having to be a direct sibling.

commit0ae86cd1685d244c83a6080a7816365096ab06f8 authorNick Espig <nickespig@gmail.com> dateTue 4 Jun 2019, 19:16 (7 years ago) parentfb6ff5a
1 file changed+10−2
searx/static/plugins/js/vim_hotkeys.js+10−2
searx/static/plugins/js/vim_hotkeys.js+10−2
@@ -125,6 +125,14 @@ $(document).ready(function() {
125125 }
126126 });
127127
128+ function nextResult(current, direction) {
129+ var next = current[direction]();
130+ while (!next.is('.result') && next.length !== 0) {
131+ next = next[direction]();
132+ }
133+ return next
134+ }
135+
128136 function highlightResult(which) {
129137 return function() {
130138 var current = $('.result[data-vim-selected]');
@@ -157,13 +165,13 @@ $(document).ready(function() {
157165 }
158166 break;
159167 case 'down':
160− next = current.next('.result');
168+ next = nextResult(current, 'next');
161169 if (next.length === 0) {
162170 next = $('.result:first');
163171 }
164172 break;
165173 case 'up':
166− next = current.prev('.result');
174+ next = nextResult(current, 'prev');
167175 if (next.length === 0) {
168176 next = $('.result:last');
169177 }