From b6890bfd2ca4d5500d5945f49001d9f84912ca04 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 20 Oct 2018 16:18:02 -0700 Subject: [PATCH] Combine logic for forward and backward shift-selects. --- frontends/etiquette_flask/static/js/photo_clipboard.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frontends/etiquette_flask/static/js/photo_clipboard.js b/frontends/etiquette_flask/static/js/photo_clipboard.js index 5d9814d..a6e1976 100644 --- a/frontends/etiquette_flask/static/js/photo_clipboard.js +++ b/frontends/etiquette_flask/static/js/photo_clipboard.js @@ -127,13 +127,11 @@ function on_photo_select(event) { slice = [current_photo_div]; } - else if (previous_index < current_index) - { - slice = photo_divs.slice(previous_index, current_index + 1); - } else { - slice = photo_divs.slice(current_index, previous_index + 1); + var left = Math.min(previous_index, current_index); + var right = Math.max(previous_index, current_index); + slice = photo_divs.slice(left, right + 1); } slice.forEach(action);