From bf9d38019018a8c1dc28859d986b41c39094e43e Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 18 Oct 2015 00:32:16 -0700 Subject: [PATCH] jsMath -> MathJax on /sci/. --- src/General/css/style.css | 4 ---- src/General/css/tomorrow.css | 3 --- src/Miscellaneous/Fourchan.coffee | 31 +++++++++++++++++++------------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/General/css/style.css b/src/General/css/style.css index 6c5390e7c..4d0b2cabf 100755 --- a/src/General/css/style.css +++ b/src/General/css/style.css @@ -302,10 +302,6 @@ audio.controls-added { .current { font-weight: bold; } -:root.fixed.bottom-header #jsMath_button { - bottom: auto; - top: 1px; -} @media (min-width: 1300px) { :root.fixed:not(.centered-links) #header-bar { white-space: nowrap; diff --git a/src/General/css/tomorrow.css b/src/General/css/tomorrow.css index e36a028d0..855021077 100755 --- a/src/General/css/tomorrow.css +++ b/src/General/css/tomorrow.css @@ -3,9 +3,6 @@ background-color: #282A2E; border-color: #111; } -:root.tomorrow img[src*="//boards.4chan.org/js/jsMath/fonts/"] { - filter: invert(100%); -} /* Header */ :root.tomorrow #header-bar.dialog { diff --git a/src/Miscellaneous/Fourchan.coffee b/src/Miscellaneous/Fourchan.coffee index 5dd401e1a..9f7d1daa8 100755 --- a/src/Miscellaneous/Fourchan.coffee +++ b/src/Miscellaneous/Fourchan.coffee @@ -26,15 +26,18 @@ Fourchan = if g.BOARD.ID is 'sci' $.globalEval ''' - window.addEventListener('jsmath', function(e) { - if (!jsMath) return; - if (jsMath.loaded) { - // process one post - jsMath.ProcessBeforeShowing(e.target); - } else if (jsMath.Autoload && jsMath.Autoload.checked) { - // load jsMath and process whole document - jsMath.Autoload.Script.Push('ProcessBeforeShowing', [null]); - jsMath.Autoload.LoadJsMath(); + window.addEventListener('mathjax', function(e) { + if (window.MathJax) { + window.MathJax.Hub.Queue(function() { + if (!e.target.querySelector('.MathJax')) { + window.MathJax.Hub.Typeset(e.target); + } + }); + } else { + if (!document.querySelector('script[src^="//cdn.mathjax.org/"]')) { + window.loadMathJax(); + window.loadMathJax = function() {}; + } } }, false); ''' @@ -66,6 +69,10 @@ Fourchan = return math: -> - return if (@isClone and doc.contains @origin.nodes.root) or !$ '.math', @nodes.comment - $.asap (=> doc.contains @nodes.comment), => - $.event 'jsmath', null, @nodes.comment + return unless /\[(math|eqn)\]/.test(@nodes.comment.textContent) or $('.math:not([id])', @nodes.comment) + cb = => + return unless doc.contains @nodes.comment + $.off d, 'PostsInserted', cb + $.event 'mathjax', null, @nodes.comment + $.on d, 'PostsInserted', cb + cb()