Use Object.create(null) instead of Map for now to support old browsers. #2282

This commit is contained in:
ccd0 2019-07-06 14:26:18 -07:00
parent b85bffeae9
commit 4aacfe520d

View File

@ -1,7 +1,7 @@
PostJumper = PostJumper =
init: -> init: ->
@capcode = new Map() @capcode = Object.create(null)
@uniqueID = new Map() @uniqueID = Object.create(null)
return unless g.VIEW in ['index', 'thread'] return unless g.VIEW in ['index', 'thread']
Callbacks.Post.push Callbacks.Post.push
@ -23,20 +23,19 @@ PostJumper =
$.after post.nodes[type+(if type is 'capcode' then '' else 'Root')], buttons $.after post.nodes[type+(if type is 'capcode' then '' else 'Root')], buttons
$.on buttons.firstChild, 'click', PostJumper.buttonClick post,type,-1 $.on buttons.firstChild, 'click', PostJumper.buttonClick post,type,-1
$.on buttons.lastChild, 'click', PostJumper.buttonClick post,type,1 $.on buttons.lastChild, 'click', PostJumper.buttonClick post,type,1
if not PostJumper[type].has value if value not of PostJumper[type]
PostJumper[type].set value, [] PostJumper[type][value] = []
PostJumper[type].get(value).push {key: post.ID, val: post.fullID} PostJumper[type][value].push {key: post.ID, val: post.fullID}
PostJumper[type].get(value).sort (first,second) -> first.key-second.key PostJumper[type][value].sort (first,second) -> first.key-second.key
buttonClick: (post,type,dir) -> -> buttonClick: (post,type,dir) -> ->
return if PostJumper[type].size is 0
value = (if type is 'capcode' then '## ' else '') + post.info[type] value = (if type is 'capcode' then '## ' else '') + post.info[type]
fromID = post.ID fromID = post.ID
idx = PostJumper.indexOfPair PostJumper[type].get(value),fromID idx = PostJumper.indexOfPair PostJumper[type][value],fromID
fromID = PostJumper[type].get(value)[idx].val fromID = PostJumper[type][value][idx].val
return if idx is -1 return if idx is -1
idx = (idx + dir) %% PostJumper[type].get(value).length idx = (idx + dir) %% PostJumper[type][value].length
toID= PostJumper[type].get(value)[idx].val toID= PostJumper[type][value][idx].val
PostJumper.scroll fromID,toID PostJumper.scroll fromID,toID
makeButtons: -> makeButtons: ->