From b9f2702daf6eba26de94d9dd6c7fc7fd18dd9eaa Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Mon, 6 Jan 2014 08:55:26 -0700 Subject: [PATCH] Consolidate and cleanup --- builds/4chan-X.user.js | 21 ++++----------------- builds/crx/script.js | 21 ++++----------------- src/Quotelinks/QuoteThreading.coffee | 24 +++++++----------------- 3 files changed, 15 insertions(+), 51 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index bc7d7c9ff..130f342a8 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4967,18 +4967,15 @@ if (this.isClone || !QuoteThreading.enabled) { return; } + if (Conf['Unread Count']) { + Unread.posts.push(this); + } if (this.thread.OP === this) { - if (Conf['Unread Count']) { - Unread.posts.push(this); - } return; } quotes = this.quotes, ID = this.ID, fullID = this.fullID; posts = g.posts; if (!(post = posts[fullID]) || post.isHidden) { - if (Conf['Unread Count']) { - Unread.posts.push(this); - } return; } keys = []; @@ -5005,18 +5002,12 @@ post = g.posts[this.threaded]; posts = Unread.posts; if (this.thread.OP === post) { - if (Conf['Unread Count']) { - posts.push(this); - } return false; } if (QuoteThreading.hasRun) { height = doc.clientHeight; _ref = post.nodes.root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top; if (!((posts != null ? posts[post.ID] : void 0) || ((bottom < height) && (top > 0)))) { - if (Conf['Unread Count']) { - posts.push(this); - } return false; } } @@ -5032,13 +5023,9 @@ post = Get.postFromRoot($.x('descendant::div[contains(@class,"postContainer")][last()]', threadContainer)); } $.add(threadContainer, this.nodes.root); - if (!Conf['Unread Count'] || this.ID < Unread.lastReadPost) { - this.prev = true; + if (!Conf['Unread Count']) { return true; } - if (!posts[this.ID]) { - posts.push(this); - } if (posts[post.ID]) { posts.after(post, this); return true; diff --git a/builds/crx/script.js b/builds/crx/script.js index ccd69b978..270b77c00 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4970,18 +4970,15 @@ if (this.isClone || !QuoteThreading.enabled) { return; } + if (Conf['Unread Count']) { + Unread.posts.push(this); + } if (this.thread.OP === this) { - if (Conf['Unread Count']) { - Unread.posts.push(this); - } return; } quotes = this.quotes, ID = this.ID, fullID = this.fullID; posts = g.posts; if (!(post = posts[fullID]) || post.isHidden) { - if (Conf['Unread Count']) { - Unread.posts.push(this); - } return; } keys = []; @@ -5008,18 +5005,12 @@ post = g.posts[this.threaded]; posts = Unread.posts; if (this.thread.OP === post) { - if (Conf['Unread Count']) { - posts.push(this); - } return false; } if (QuoteThreading.hasRun) { height = doc.clientHeight; _ref = post.nodes.root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top; if (!((posts != null ? posts[post.ID] : void 0) || ((bottom < height) && (top > 0)))) { - if (Conf['Unread Count']) { - posts.push(this); - } return false; } } @@ -5035,13 +5026,9 @@ post = Get.postFromRoot($.x('descendant::div[contains(@class,"postContainer")][last()]', threadContainer)); } $.add(threadContainer, this.nodes.root); - if (!Conf['Unread Count'] || this.ID < Unread.lastReadPost) { - this.prev = true; + if (!Conf['Unread Count']) { return true; } - if (!posts[this.ID]) { - posts.push(this); - } if (posts[post.ID]) { posts.after(post, this); return true; diff --git a/src/Quotelinks/QuoteThreading.coffee b/src/Quotelinks/QuoteThreading.coffee index 2cac9bbb0..1d25944d5 100755 --- a/src/Quotelinks/QuoteThreading.coffee +++ b/src/Quotelinks/QuoteThreading.coffee @@ -33,15 +33,13 @@ QuoteThreading = node: -> return if @isClone or not QuoteThreading.enabled - if @thread.OP is @ - Unread.posts.push @ if Conf['Unread Count'] - return + Unread.posts.push @ if Conf['Unread Count'] + + return if @thread.OP is @ {quotes, ID, fullID} = @ {posts} = g - if !(post = posts[fullID]) or post.isHidden # Filtered - Unread.posts.push @ if Conf['Unread Count'] - return + return if !(post = posts[fullID]) or post.isHidden # Filtered keys = [] len = "#{g.BOARD}".length + 1 @@ -59,18 +57,14 @@ QuoteThreading = post = g.posts[@threaded] {posts} = Unread - if @thread.OP is post - posts.push @ if Conf['Unread Count'] - return false + return false if @thread.OP is post if QuoteThreading.hasRun height = doc.clientHeight {bottom, top} = post.nodes.root.getBoundingClientRect() # Post is unread or is fully visible. - unless posts?[post.ID] or ((bottom < height) and (top > 0)) - posts.push @ if Conf['Unread Count'] - return false + return false unless posts?[post.ID] or ((bottom < height) and (top > 0)) {root} = post.nodes unless $.hasClass root, 'threadOP' @@ -84,11 +78,7 @@ QuoteThreading = $.add threadContainer, @nodes.root - if not Conf['Unread Count'] or @ID < Unread.lastReadPost - @prev = true # Force Unread Count to ignore this post - return true - - posts.push @ unless posts[@ID] + return true unless Conf['Unread Count'] if posts[post.ID] posts.after post, @