From 935596722c52c718e04eef14ca799bcb5e6d3706 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 3 Jan 2015 14:27:59 -0800 Subject: [PATCH] Fix some errors from features run on 404 pages. --- src/General/Header.coffee | 2 +- src/General/Index.coffee | 2 ++ src/General/Main.coffee | 4 ++++ src/Miscellaneous/Banner.coffee | 2 +- src/Miscellaneous/Fourchan.coffee | 2 +- src/Monitoring/ThreadUpdater.coffee | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 5508e4d51..939582a8f 100755 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -91,7 +91,7 @@ Header = @setBarPosition Conf['Bottom Header'] @ - $.ready => + Main.ready => @footer = footer = $.id 'boardNavDesktopFoot' if a = $ "a[href*='/#{g.BOARD}/']", footer a.className = 'current' diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 0c289d25d..0221d569c 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -82,6 +82,7 @@ Index = @update() $.asap (-> $('.board > .thread > .postContainer', doc) or d.readyState isnt 'loading'), -> + return unless Main.isThisPageLegit() Index.hat = $ '.board > .thread > img:first-child' if Index.hat and Index.nodes for threadRoot in Index.nodes @@ -106,6 +107,7 @@ Index = $.before topNavPos, Index.navLinks $.asap (-> $('.pagelist', doc) or d.readyState isnt 'loading'), -> + return unless Main.isThisPageLegit() if pagelist = $('.pagelist') $.replace pagelist, Index.pagelist else diff --git a/src/General/Main.coffee b/src/General/Main.coffee index c887aa287..0c2c9d4aa 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -273,6 +273,10 @@ Main = d.title not in ['4chan - Temporarily Offline', '4chan - Error', '504 Gateway Time-out'] Main.thisPageIsLegit + ready: (cb) -> + $.ready -> + cb() if Main.isThisPageLegit() + css: """ <%= grunt.file.read('src/General/css/font-awesome.css').replace(/\s+/g, ' ').replace(/\\/g, '\\\\').trim() %> <%= grunt.file.read('src/General/css/style.css').replace(/\s+/g, ' ').trim() %> diff --git a/src/Miscellaneous/Banner.coffee b/src/Miscellaneous/Banner.coffee index 57fd444bb..b5654c10a 100644 --- a/src/Miscellaneous/Banner.coffee +++ b/src/Miscellaneous/Banner.coffee @@ -7,7 +7,7 @@ Banner = # Let 4chan's JS load the banner if enabled; otherwise, load it ourselves. if g.BOARD.ID isnt 'f' - $.ready -> $.queueTask Banner.load + Main.ready -> $.queueTask Banner.load ready: -> banner = $ ".boardBanner" diff --git a/src/Miscellaneous/Fourchan.coffee b/src/Miscellaneous/Fourchan.coffee index 25c3178c5..1fb44b326 100755 --- a/src/Miscellaneous/Fourchan.coffee +++ b/src/Miscellaneous/Fourchan.coffee @@ -36,7 +36,7 @@ Fourchan = cb: @math # Disable 4chan's ID highlighting (replaced by IDHighlight) and reported post hiding. - $.ready -> + Main.ready -> $.globalEval ''' (function() { window.clickable_ids = false; diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index 2477e86db..05aae44d5 100755 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -27,7 +27,7 @@ ThreadUpdater = updateLink = $.el 'span', className: 'brackets-wrap updatelink' $.extend updateLink, <%= html('Update') %> - $.ready -> + Main.ready -> $.add $('.navLinksBot'), [$.tn(' '), updateLink] $.on updateLink.firstElementChild, 'click', @update