From 4aacfe520d2082c9f9026c9a5a7582b5d1331344 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 6 Jul 2019 14:26:18 -0700 Subject: [PATCH] Use Object.create(null) instead of Map for now to support old browsers. #2282 --- src/Miscellaneous/PostJumper.coffee | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Miscellaneous/PostJumper.coffee b/src/Miscellaneous/PostJumper.coffee index 50526f86b..d16cd1833 100644 --- a/src/Miscellaneous/PostJumper.coffee +++ b/src/Miscellaneous/PostJumper.coffee @@ -1,7 +1,7 @@ PostJumper = init: -> - @capcode = new Map() - @uniqueID = new Map() + @capcode = Object.create(null) + @uniqueID = Object.create(null) return unless g.VIEW in ['index', 'thread'] Callbacks.Post.push @@ -23,20 +23,19 @@ PostJumper = $.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 - if not PostJumper[type].has value - PostJumper[type].set value, [] - PostJumper[type].get(value).push {key: post.ID, val: post.fullID} - PostJumper[type].get(value).sort (first,second) -> first.key-second.key + if value not of PostJumper[type] + PostJumper[type][value] = [] + PostJumper[type][value].push {key: post.ID, val: post.fullID} + PostJumper[type][value].sort (first,second) -> first.key-second.key buttonClick: (post,type,dir) -> -> - return if PostJumper[type].size is 0 value = (if type is 'capcode' then '## ' else '') + post.info[type] fromID = post.ID - idx = PostJumper.indexOfPair PostJumper[type].get(value),fromID - fromID = PostJumper[type].get(value)[idx].val + idx = PostJumper.indexOfPair PostJumper[type][value],fromID + fromID = PostJumper[type][value][idx].val return if idx is -1 - idx = (idx + dir) %% PostJumper[type].get(value).length - toID= PostJumper[type].get(value)[idx].val + idx = (idx + dir) %% PostJumper[type][value].length + toID= PostJumper[type][value][idx].val PostJumper.scroll fromID,toID makeButtons: ->