From a22356893727c9872bf4908740e481bc46ef7b10 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 2 Nov 2013 16:46:56 +0100 Subject: [PATCH] Fix pretty-printing on Chrome. --- src/Miscellaneous/Fourchan.coffee | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Miscellaneous/Fourchan.coffee b/src/Miscellaneous/Fourchan.coffee index 64b1f4562..1b78c17de 100644 --- a/src/Miscellaneous/Fourchan.coffee +++ b/src/Miscellaneous/Fourchan.coffee @@ -6,8 +6,9 @@ Fourchan = if board is 'g' $.globalEval """ window.addEventListener('prettyprint', function(e) { - var pre = e.detail; - pre.innerHTML = prettyPrintOne(pre.innerHTML); + window.dispatchEvent(new CustomEvent('prettyprint:cb', { + detail: prettyPrintOne(e.detail) + })); }, false); """ Post.callbacks.push @@ -32,9 +33,11 @@ Fourchan = cb: @math code: -> return if @isClone - for pre in $$ '.prettyprint:not(.prettyprinted)', @nodes.comment - $.event 'prettyprint', pre, window - $.addClass pre, 'prettyprinted' + apply = (e) -> pre.innerHTML = e.detail + $.on window, 'prettyprint:cb', apply + for pre in $$ '.prettyprint', @nodes.comment + $.event 'prettyprint', pre.innerHTML, window + $.off window, 'prettyprint:cb', apply return math: -> return if @isClone or !$ '.math', @nodes.comment