on master help sign in
Fix not jumping to results loaded by infinite scroll
0ae86cdNick Espig
searx/static/plugins/js/vim_hotkeys.js+10−2
@@ -125,6 +125,14 @@ $(document).ready(function() {
125 }
125 }
126 });
126 });
127
127
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+
128 function highlightResult(which) {
136 function highlightResult(which) {
129 return function() {
137 return function() {
130 var current = $('.result[data-vim-selected]');
138 var current = $('.result[data-vim-selected]');
@@ -157,13 +165,13 @@ $(document).ready(function() {
157 }
165 }
158 break;
166 break;
159 case 'down':
167 case 'down':
160− next = current.next('.result');
168+ next = nextResult(current, 'next');
161 if (next.length === 0) {
169 if (next.length === 0) {
162 next = $('.result:first');
170 next = $('.result:first');
163 }
171 }
164 break;
172 break;
165 case 'up':
173 case 'up':
166− next = current.prev('.result');
174+ next = nextResult(current, 'prev');
167 if (next.length === 0) {
175 if (next.length === 0) {
168 next = $('.result:last');
176 next = $('.result:last');
169 }
177 }