From 5823da664df623e27cac53be21e3c7827e1ab53a Mon Sep 17 00:00:00 2001 From: Jordan Bates Date: Mon, 22 Apr 2013 22:10:45 -0700 Subject: [PATCH] We (Still) Hate Console Errors 3.0 --- builds/4chan-X.js | 43 +++++++++++++-------------- builds/4chan-X.user.js | 43 +++++++++++++-------------- builds/crx/script.js | 43 +++++++++++++-------------- src/features/monitoring/unread.coffee | 29 +++++++++--------- 4 files changed, 74 insertions(+), 84 deletions(-) diff --git a/builds/4chan-X.js b/builds/4chan-X.js index c299bab16..ea65ca8d5 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -6413,8 +6413,7 @@ }); }, node: function() { - var ID, post, posts, _ref, - _this = this; + var ID, post, posts, _ref; Unread.thread = this; Unread.title = d.title; @@ -6437,31 +6436,29 @@ if (Conf['Unread Line']) { $.on(d, 'visibilitychange', Unread.setLine); } - if (Conf['Scroll to Last Read Post']) { - return $.on(window, 'load', function(posts) { - return Unread.scroll.apply(_this, posts); - }); - } - }, - scroll: function(posts) { - var hash, root; - - if ((hash = location.hash.match(/\d+/)) && hash[0] in this.posts) { + if (!Conf['Scroll to Last Read Post']) { return; } - if (Unread.posts.length) { - while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { - if (!(Get.postFromRoot(root)).isHidden) { - break; - } - } - if (!root) { + return $.on(window, 'load', function() { + var hash, root; + + if ((hash = location.hash.match(/\d+/)) && hash[0] in this.posts) { return; } - return root.scrollIntoView(false); - } else if (posts.length) { - return Header.scrollToPost(posts[post.length - 1].nodes.root); - } + if (Unread.posts.length) { + while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { + if (!(Get.postFromRoot(root)).isHidden) { + break; + } + } + if (!root) { + return; + } + return root.scrollIntoView(false); + } else if (posts.length) { + return Header.scrollToPost(posts[posts.length - 1].nodes.root); + } + }); }, sync: function() { var lastReadPost; diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 0658f2fd0..7e7b21a45 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -6404,8 +6404,7 @@ }); }, node: function() { - var ID, post, posts, _ref, - _this = this; + var ID, post, posts, _ref; Unread.thread = this; Unread.title = d.title; @@ -6428,31 +6427,29 @@ if (Conf['Unread Line']) { $.on(d, 'visibilitychange', Unread.setLine); } - if (Conf['Scroll to Last Read Post']) { - return $.on(window, 'load', function(posts) { - return Unread.scroll.apply(_this, posts); - }); - } - }, - scroll: function(posts) { - var hash, root; - - if ((hash = location.hash.match(/\d+/)) && hash[0] in this.posts) { + if (!Conf['Scroll to Last Read Post']) { return; } - if (Unread.posts.length) { - while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { - if (!(Get.postFromRoot(root)).isHidden) { - break; - } - } - if (!root) { + return $.on(window, 'load', function() { + var hash, root; + + if ((hash = location.hash.match(/\d+/)) && hash[0] in this.posts) { return; } - return root.scrollIntoView(false); - } else if (posts.length) { - return Header.scrollToPost(posts[post.length - 1].nodes.root); - } + if (Unread.posts.length) { + while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { + if (!(Get.postFromRoot(root)).isHidden) { + break; + } + } + if (!root) { + return; + } + return root.scrollIntoView(false); + } else if (posts.length) { + return Header.scrollToPost(posts[posts.length - 1].nodes.root); + } + }); }, sync: function() { var lastReadPost; diff --git a/builds/crx/script.js b/builds/crx/script.js index c568254b8..c7de30508 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6327,8 +6327,7 @@ }); }, node: function() { - var ID, post, posts, _ref, - _this = this; + var ID, post, posts, _ref; Unread.thread = this; Unread.title = d.title; @@ -6351,31 +6350,29 @@ if (Conf['Unread Line']) { $.on(d, 'visibilitychange', Unread.setLine); } - if (Conf['Scroll to Last Read Post']) { - return $.on(window, 'load', function(posts) { - return Unread.scroll.apply(_this, posts); - }); - } - }, - scroll: function(posts) { - var hash, root; - - if ((hash = location.hash.match(/\d+/)) && hash[0] in this.posts) { + if (!Conf['Scroll to Last Read Post']) { return; } - if (Unread.posts.length) { - while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { - if (!(Get.postFromRoot(root)).isHidden) { - break; - } - } - if (!root) { + return $.on(window, 'load', function() { + var hash, root; + + if ((hash = location.hash.match(/\d+/)) && hash[0] in this.posts) { return; } - return root.scrollIntoView(false); - } else if (posts.length) { - return Header.scrollToPost(posts[post.length - 1].nodes.root); - } + if (Unread.posts.length) { + while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { + if (!(Get.postFromRoot(root)).isHidden) { + break; + } + } + if (!root) { + return; + } + return root.scrollIntoView(false); + } else if (posts.length) { + return Header.scrollToPost(posts[posts.length - 1].nodes.root); + } + }); }, sync: function() { var lastReadPost; diff --git a/src/features/monitoring/unread.coffee b/src/features/monitoring/unread.coffee index cd6967aea..8ff735c2a 100644 --- a/src/features/monitoring/unread.coffee +++ b/src/features/monitoring/unread.coffee @@ -26,22 +26,21 @@ Unread = $.on d, 'ThreadUpdate', Unread.onUpdate $.on d, 'scroll visibilitychange', Unread.read $.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line'] - if Conf['Scroll to Last Read Post'] - $.on window, 'load', (posts) => - Unread.scroll.apply @, posts - scroll: (posts) -> - # Let the header's onload callback handle it. - return if (hash = location.hash.match /\d+/) and hash[0] of @posts - if Unread.posts.length - # Scroll to before the first unread post. - while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root - break unless (Get.postFromRoot root).isHidden - return unless root - root.scrollIntoView false - else if posts.length - # Scroll to the last read post. - Header.scrollToPost (posts[post.length - 1]).nodes.root + return unless Conf['Scroll to Last Read Post'] + + $.on window, 'load', -> + # Let the header's onload callback handle it. + return if (hash = location.hash.match /\d+/) and hash[0] of @posts + if Unread.posts.length + # Scroll to before the first unread post. + while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root + break unless (Get.postFromRoot root).isHidden + return unless root + root.scrollIntoView false + else if posts.length + # Scroll to the last read post. + Header.scrollToPost (posts[posts.length - 1]).nodes.root sync: -> lastReadPost = Unread.db.get