From 95a62e526c9a9a0fcc9f2c7198f4ee698f712cda Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Mon, 25 Sep 2017 17:02:45 +0200 Subject: [PATCH] stack.js: make getTarget take an offset Allows us to get the -1 target, -2 target etc. Signed-off-by: Nathan Cutler --- share/js/core/stack.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/share/js/core/stack.js b/share/js/core/stack.js index 651e533..c480a30 100644 --- a/share/js/core/stack.js +++ b/share/js/core/stack.js @@ -157,8 +157,13 @@ define ([ getState = function () { return _stack[_stack.length - 1].state; }, - getTarget = function () { - return _stack[_stack.length - 1].target; + getTarget = function (offset) { + // offset -1 for target under top target + // offset -2 for two targets down, etc. + if (offset === undefined) { + offset = 0; + } + return _stack[_stack.length + offset - 1].target; }, getXTarget = function () { return _stack[_stack.length - 1].xtarget;