diff --git a/LICENSE b/LICENSE index d40318abb..46d565a33 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.4.1 - 2014-03-23 +* 4chan X - Version 1.4.1 - 2014-03-24 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 0bbac0591..1c8265e08 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -24,7 +24,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.4.1 - 2014-03-23 +* 4chan X - Version 1.4.1 - 2014-03-24 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE @@ -5501,6 +5501,50 @@ } else if (mayReset) { return quotelink.textContent = text; } + }, + cb: { + seek: function(type) { + var post; + if (Conf['Mark Quotes of You'] && (post = QuotesYou.cb.findPost(type))) { + return Quotesyou.cb.scroll(post); + } + }, + findPost: function(type) { + var i, index, len, post, posts; + posts = $$('.quotesYou'); + if (!QuoteMarkers.lastRead) { + if (!(post = QuoteMarkers.lastRead = posts[0])) { + new Notice('warning', 'No posts are currently quoting you, loser.', 20); + return; + } + if (!Get.postFromRoot(post).isHidden) { + return post; + } + } else { + post = QuoteMarkers.lastRead; + } + len = posts.length - 1; + index = i = posts.indexOf(post); + while (true) { + if (index === (i = i === 0 ? len : i === len ? 0 : type === 'prev' ? i - 1 : i + 1)) { + break; + } + post = posts[i]; + if (!Get.postFromRoot(post).isHidden) { + return post; + } + } + }, + scroll: function(post) { + var highlight; + if (highlight = $('.highlight')) { + $.rmClass(highlight, 'highlight'); + } + QuoteMarkers.lastRead = post; + window.location.hash = "#" + post.id; + Header.scrollTo(post); + return $.addClass($('.post', post), 'highlight'); + } } }; @@ -11962,10 +12006,10 @@ PostHiding.toggle(thread.OP); break; case Conf['Previous Post Quoting You']: - QuoteYou.cb.seek('preceding'); + QuoteMarkers.cb.seek('preceding'); break; case Conf['Next Post Quoting You']: - QuoteYou.cb.seek('following'); + QuoteMarkers.cb.seek('following'); break; default: return; diff --git a/builds/crx/script.js b/builds/crx/script.js index ecd3c2dac..bec2367f9 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.4.1 - 2014-03-23 +* 4chan X - Version 1.4.1 - 2014-03-24 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE @@ -5555,6 +5555,50 @@ } else if (mayReset) { return quotelink.textContent = text; } + }, + cb: { + seek: function(type) { + var post; + if (Conf['Mark Quotes of You'] && (post = QuotesYou.cb.findPost(type))) { + return Quotesyou.cb.scroll(post); + } + }, + findPost: function(type) { + var i, index, len, post, posts; + posts = $$('.quotesYou'); + if (!QuoteMarkers.lastRead) { + if (!(post = QuoteMarkers.lastRead = posts[0])) { + new Notice('warning', 'No posts are currently quoting you, loser.', 20); + return; + } + if (!Get.postFromRoot(post).isHidden) { + return post; + } + } else { + post = QuoteMarkers.lastRead; + } + len = posts.length - 1; + index = i = posts.indexOf(post); + while (true) { + if (index === (i = i === 0 ? len : i === len ? 0 : type === 'prev' ? i - 1 : i + 1)) { + break; + } + post = posts[i]; + if (!Get.postFromRoot(post).isHidden) { + return post; + } + } + }, + scroll: function(post) { + var highlight; + if (highlight = $('.highlight')) { + $.rmClass(highlight, 'highlight'); + } + QuoteMarkers.lastRead = post; + window.location.hash = "#" + post.id; + Header.scrollTo(post); + return $.addClass($('.post', post), 'highlight'); + } } }; @@ -11978,10 +12022,10 @@ PostHiding.toggle(thread.OP); break; case Conf['Previous Post Quoting You']: - QuoteYou.cb.seek('preceding'); + QuoteMarkers.cb.seek('preceding'); break; case Conf['Next Post Quoting You']: - QuoteYou.cb.seek('following'); + QuoteMarkers.cb.seek('following'); break; default: return; diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 7886509e3..53df9ba90 100755 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -135,9 +135,9 @@ Keybinds = when Conf['Hide'] PostHiding.toggle thread.OP when Conf['Previous Post Quoting You'] - QuoteYou.cb.seek 'preceding' + QuoteMarkers.cb.seek 'preceding' when Conf['Next Post Quoting You'] - QuoteYou.cb.seek 'following' + QuoteMarkers.cb.seek 'following' else return e.preventDefault() diff --git a/src/Quotelinks/QuoteMarkers.coffee b/src/Quotelinks/QuoteMarkers.coffee index f1c1128d5..cb5e2304c 100644 --- a/src/Quotelinks/QuoteMarkers.coffee +++ b/src/Quotelinks/QuoteMarkers.coffee @@ -45,3 +45,43 @@ QuoteMarkers = quotelink.textContent = "#{text}\u00A0(#{markers.join '|'})" else if mayReset quotelink.textContent = text + + cb: + seek: (type) -> + if Conf['Mark Quotes of You'] and post = QuotesYou.cb.findPost type + Quotesyou.cb.scroll post + + findPost: (type) -> + posts = $$ '.quotesYou' + unless QuoteMarkers.lastRead + unless post = QuoteMarkers.lastRead = posts[0] + new Notice 'warning', 'No posts are currently quoting you, loser.', 20 + return + unless Get.postFromRoot(post).isHidden + return post + else + post = QuoteMarkers.lastRead + + len = posts.length - 1 + index = i = posts.indexOf post + while true + break if index is ( + i = if i is 0 + len + else if i is len + 0 + else if type is 'prev' + i - 1 + else + i + 1 + ) + post = posts[i] + return post unless Get.postFromRoot(post).isHidden + + scroll: (post) -> + $.rmClass highlight, 'highlight' if highlight = $ '.highlight' + QuoteMarkers.lastRead = post + window.location.hash = "##{post.id}" + Header.scrollTo post + $.addClass $('.post', post), 'highlight' +