Use boards.json to determine whether to activate [code] and [math] tag related functions. #525

This commit is contained in:
ccd0 2019-04-08 03:50:18 -07:00
parent 45e5cda2da
commit c5d01ce6d6
4 changed files with 23 additions and 20 deletions

View File

@ -2,9 +2,6 @@ ExpandComment =
init: ->
return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] or Conf['JSON Index']
@callbacks.push Fourchan.code if g.BOARD.ID is 'g'
@callbacks.push Fourchan.math if g.BOARD.ID is 'sci'
Callbacks.Post.push
name: 'Comment Expansion'
cb: @node

View File

@ -1,8 +1,11 @@
Fourchan =
init: ->
return unless g.VIEW in ['index', 'thread', 'archive']
return unless Site.software is 'yotsuba' and g.VIEW in ['index', 'thread', 'archive']
BoardConfig.ready @initBoard
Main.ready @initReady
if g.BOARD.ID is 'g'
initBoard: ->
if g.BOARD.config.code_tags
$.on window, 'prettyprint:cb', (e) ->
return if not (post = g.posts[e.detail.ID])
return if not (pre = $$('.prettyprint', post.nodes.comment)[e.detail.i])
@ -21,10 +24,12 @@ Fourchan =
}, false);
'''
Callbacks.Post.push
name: 'Parse /g/ code'
cb: @code
name: 'Parse [code] tags'
cb: Fourchan.code
g.posts.forEach (post) -> Callbacks.Post.execute post, ['Parse [code] tags'], true
ExpandComment.callbacks.push Fourchan.code
if g.BOARD.ID is 'sci'
if g.BOARD.config.math_tags
$.global ->
window.addEventListener 'mathjax', (e) ->
if window.MathJax
@ -40,16 +45,18 @@ Fourchan =
, false
, false
Callbacks.Post.push
name: 'Parse /sci/ math'
cb: @math
name: 'Parse [math] tags'
cb: Fourchan.math
g.posts.forEach (post) -> Callbacks.Post.execute post, ['Parse [math] tags'], true
ExpandComment.callbacks.push Fourchan.math
# Disable 4chan's ID highlighting (replaced by IDHighlight) and reported post hiding.
Main.ready ->
$.global ->
window.clickable_ids = false
for node in document.querySelectorAll '.posteruid, .capcode'
node.removeEventListener 'click', window.idClick, false
return
# Disable 4chan's ID highlighting (replaced by IDHighlight) and reported post hiding.
initReady: ->
$.global ->
window.clickable_ids = false
for node in document.querySelectorAll '.posteruid, .capcode'
node.removeEventListener 'click', window.idClick, false
return
code: ->
return if @isClone

View File

@ -10,8 +10,8 @@ class Callbacks
@keys.push name unless @[name]
@[name] = cb
execute: (node, keys=@keys) ->
return if node.callbacksExecuted
execute: (node, keys=@keys, force) ->
return if node.callbacksExecuted and !force
node.callbacksExecuted = true
for name in keys
try

View File

@ -9,7 +9,6 @@ SW.tinyboard =
'Image Host Rewriting'
'Index Generator'
'Announcement Hiding'
'Fourchan thingies'
'Resurrect Quotes'
'Quick Reply Personas'
'Quick Reply'