From 8fb98b785ac10fa2027b90bab95d4d60d0c1127a Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 18 May 2014 09:27:01 -0700 Subject: [PATCH] better solution to the loading problem --- src/General/Main.coffee | 13 +++++++------ src/General/lib/$.coffee | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 1d671ede9..2c628c82e 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -50,12 +50,7 @@ Main = Report.init() return when 'i.4cdn.org' - if Conf['Loop in New Tab'] and document.body and video = $ 'video' - Video.configure video - $.on video, 'click', -> - if !video.controls - if video.paused then video.play() else video.pause() - $.ready -> + onReady = -> if Conf['404 Redirect'] and d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found'] Redirect.init() pathname = location.pathname.split '/' @@ -63,6 +58,12 @@ Main = boardID: g.BOARD.ID filename: pathname[pathname.length - 1] location.replace URL if URL + else if Conf['Loop in New Tab'] and video = $ 'video' + Video.configure video + $.on video, 'click', -> + if !video.controls + if video.paused then video.play() else video.pause() + $.ready onReady, true return # c.time 'All initializations' diff --git a/src/General/lib/$.coffee b/src/General/lib/$.coffee index d1da366d2..7fe77e407 100755 --- a/src/General/lib/$.coffee +++ b/src/General/lib/$.coffee @@ -16,9 +16,9 @@ $.DAY = 24 * $.id = (id) -> d.getElementById id -$.ready = (fc) -> +$.ready = (fc, immediate) -> unless d.readyState is 'loading' - $.queueTask fc + if immediate then fc() else $.queueTask fc return cb = -> $.off d, 'DOMContentLoaded', cb