From 39fe93e73cf84c80478a3dd3e5873da6a0d731d0 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 6 Jul 2019 15:34:23 -0700 Subject: [PATCH] Get button details from page instead of making new listener function for every button. #2282 --- src/Miscellaneous/PostJumper.coffee | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Miscellaneous/PostJumper.coffee b/src/Miscellaneous/PostJumper.coffee index d043dcec6..ecad7702b 100644 --- a/src/Miscellaneous/PostJumper.coffee +++ b/src/Miscellaneous/PostJumper.coffee @@ -21,15 +21,19 @@ PostJumper = addButtons: (post,type) -> value = post.nodes[type].innerText buttons = PostJumper.buttons.cloneNode(true) + buttons.dataset.type = type $.after post.nodes[type+(if type is 'capcode' then '' else 'Root')], buttons - $.on buttons.firstChild, 'click', PostJumper.buttonClick post,type,-1 - $.on buttons.lastChild, 'click', PostJumper.buttonClick post,type,1 + $.on buttons.firstChild, 'click', PostJumper.buttonClick + $.on buttons.lastChild, 'click', PostJumper.buttonClick if value not of PostJumper.maps[type] PostJumper.maps[type][value] = [] PostJumper.maps[type][value].push {key: post.ID, val: post.fullID} PostJumper.maps[type][value].sort (first,second) -> first.key-second.key - buttonClick: (post,type,dir) -> -> + buttonClick: -> + post = Get.postFromNode @ + {type} = @parentNode.dataset + dir = if $.hasClass(@, 'prev') then -1 else 1 value = (if type is 'capcode' then '## ' else '') + post.info[type] fromID = post.ID idx = PostJumper.indexOfPair PostJumper.maps[type][value],fromID