removed redundancy
This commit is contained in:
parent
d6ae451360
commit
f6e038a72e
@ -1,7 +1,7 @@
|
|||||||
PostJumper =
|
PostJumper =
|
||||||
init: ->
|
init: ->
|
||||||
@capcodesMap = new Map()
|
@capcodeMap = new Map()
|
||||||
@uniqueIDsMap = new Map()
|
@uniqueIDMap = new Map()
|
||||||
return unless g.VIEW in ['index', 'thread']
|
return unless g.VIEW in ['index', 'thread']
|
||||||
|
|
||||||
Callbacks.Post.push
|
Callbacks.Post.push
|
||||||
@ -10,43 +10,29 @@ PostJumper =
|
|||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
if @nodes.uniqueIDRoot and Conf['Unique ID Navigation'] and not @nodes.uniqueIDJumperRoot
|
if @nodes.uniqueIDRoot and Conf['Unique ID Navigation'] and not @nodes.uniqueIDJumperRoot
|
||||||
uniqueID = @nodes.uniqueID.innerText
|
PostJumper.addButtons @,'uniqueID'
|
||||||
IDButtons = PostJumper.makeButtons 'uniqueIDJumper'
|
|
||||||
$.after @nodes.uniqueIDRoot, IDButtons
|
|
||||||
$.on IDButtons.firstChild, 'click', PostJumper.clickUniqueID @,-1
|
|
||||||
$.on IDButtons.lastChild, 'click', PostJumper.clickUniqueID @,1
|
|
||||||
if not PostJumper.uniqueIDsMap.has uniqueID
|
|
||||||
PostJumper.uniqueIDsMap.set uniqueID, []
|
|
||||||
PostJumper.uniqueIDsMap.get(uniqueID).push @nodes.quote.innerText
|
|
||||||
|
|
||||||
if @nodes.capcode and Conf['Capcode Navigation'] and not @nodes.capcodeJumperRoot
|
if @nodes.capcode and Conf['Capcode Navigation'] and not @nodes.capcodeJumperRoot
|
||||||
capcode = @nodes.capcode.innerText
|
PostJumper.addButtons @,'capcode'
|
||||||
capcodeButtons = PostJumper.makeButtons 'capcodeJumper'
|
|
||||||
$.after @nodes.capcode, capcodeButtons
|
|
||||||
$.on capcodeButtons.firstChild, 'click', PostJumper.clickCapcode @,-1
|
|
||||||
$.on capcodeButtons.lastChild, 'click', PostJumper.clickCapcode @,1
|
|
||||||
if not PostJumper.capcodesMap.has capcode
|
|
||||||
PostJumper.capcodesMap.set capcode, []
|
|
||||||
PostJumper.capcodesMap.get(capcode).push @nodes.quote.innerText
|
|
||||||
|
|
||||||
clickUniqueID: (post,dir) -> ->
|
addButtons: (post,type) ->
|
||||||
return if PostJumper.uniqueIDsMap.size is 0
|
value = post.nodes[type].innerText
|
||||||
uniqueID = post.info.uniqueID
|
buttons = PostJumper.makeButtons type+'Jumper'
|
||||||
fromID = post.ID.toString()
|
$.after post.nodes[type+(if type is 'capcode' then '' else 'Root')], buttons
|
||||||
idx = PostJumper.uniqueIDsMap.get(uniqueID).indexOf(fromID);
|
$.on buttons.firstChild, 'click', PostJumper.buttonClick post,type,-1
|
||||||
return if idx is -1
|
$.on buttons.lastChild, 'click', PostJumper.buttonClick post,type,1
|
||||||
idx = (idx + dir) %% PostJumper.uniqueIDsMap.get(uniqueID).length
|
if not PostJumper[type+'Map'].has value
|
||||||
toID= PostJumper.uniqueIDsMap.get(uniqueID)[idx]
|
PostJumper[type+'Map'].set value, []
|
||||||
PostJumper.scroll fromID,toID
|
PostJumper[type+'Map'].get(value).push post.nodes.quote.innerText
|
||||||
|
|
||||||
clickCapcode: (post,dir) -> ->
|
buttonClick: (post,type,dir) -> ->
|
||||||
return if PostJumper.capcodesMap.size is 0
|
return if PostJumper[type+'Map'].size is 0
|
||||||
capcode = "## " + post.info.capcode
|
value = (if type is 'capcode' then '## ' else '') + post.info[type]
|
||||||
fromID = post.ID.toString()
|
fromID = post.ID.toString()
|
||||||
idx = PostJumper.capcodesMap.get(capcode).indexOf(fromID);
|
idx = PostJumper[type+'Map'].get(value).indexOf(fromID);
|
||||||
return if idx is -1
|
return if idx is -1
|
||||||
idx = (idx + dir) %% PostJumper.capcodesMap.get(capcode).length
|
idx = (idx + dir) %% PostJumper[type+'Map'].get(value).length
|
||||||
toID= PostJumper.capcodesMap.get(capcode)[idx]
|
toID= PostJumper[type+'Map'].get(value)[idx]
|
||||||
PostJumper.scroll fromID,toID
|
PostJumper.scroll fromID,toID
|
||||||
|
|
||||||
makeButtons: (cl) ->
|
makeButtons: (cl) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user