diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 7dda466891..b4249b961f 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -87,17 +87,21 @@ selected_tag = '

' var allow_hotkeys = true; function select_zephyr(next_zephyr) { - p = $("#selected"); - td = $(p).closest("td"); - if (next_zephyr.length != 0) { // We are not at the bottom or top of the zephyrs. - td.empty(); // Clear the previous arrow. - next_zephyr.children("td:first").html(selected_tag); - $.post("update", {pointer: next_zephyr.attr("id")}); + if (next_zephyr.length == 0) { + // No match, e.g. bottom or top of page + return; + } - if (($(next_zephyr).offset().top < $("#main_div").offset().top) || - ($(next_zephyr).offset().top + $(next_zephyr).height() > $("#main_div").offset().top + $("#main_div").height())) { - scroll_to_selected(); - } + // Clear the previous arrow. + $("#selected").closest("td").empty(); + + next_zephyr.children("td:first").html(selected_tag); + $.post("update", {pointer: next_zephyr.attr("id")}); + + if (($(next_zephyr).offset().top < $("#main_div").offset().top) || + ($(next_zephyr).offset().top + $(next_zephyr).height() > + $("#main_div").offset().top + $("#main_div").height())) { + scroll_to_selected(); } }