Clean up select_zephyr

Eliminate some global variables, and other style fixes.

(imported from commit 95dfbaa024d709f5b98238afcf904f3e92c8a260)
This commit is contained in:
Keegan McAllister
2012-09-05 10:56:10 -04:00
parent 20215eef86
commit 49704b84f3

View File

@@ -87,19 +87,23 @@ selected_tag = '<p id="selected">&#x25b6;</p>'
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.
if (next_zephyr.length == 0) {
// No match, e.g. bottom or top of page
return;
}
// 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())) {
($(next_zephyr).offset().top + $(next_zephyr).height() >
$("#main_div").offset().top + $("#main_div").height())) {
scroll_to_selected();
}
}
}
// NB: This just binds to current elements, and won't bind to elements
// created after ready() is called.