summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2013-08-05 00:18:25 -0400
committerczaks <marcin@6irc.net>2013-08-05 00:18:25 -0400
commit185e68de47210b9886d87196832d166ff85dc72c (patch)
tree9f3775291426a76c43bbd6f15d2823aeb4f7d10d /js
parent06d2dafa2a8eac89acc81103bfb48196d1ba7ba3 (diff)
post-hover.js: allow working between threads and boards (ukko patchset required!)
Diffstat (limited to 'js')
-rw-r--r--js/post-hover.js40
1 files changed, 31 insertions, 9 deletions
diff --git a/js/post-hover.js b/js/post-hover.js
index 1d0c2902..8d726003 100644
--- a/js/post-hover.js
+++ b/js/post-hover.js
@@ -17,20 +17,28 @@ onready(function(){
var $link = $(this);
var id;
-
- if(id = $link.text().match(/^>>(\d+)$/)) {
- id = id[1];
+ var matches;
+
+ if(matches = $link.text().match(/^>>(?:>\/([^\/]+)\/)?(\d+)$/)) {
+ id = matches[2];
} else {
return;
}
-
+
var board = $(this);
while (board.data('board') === undefined) {
board = board.parent();
}
- var threadid = board.attr('id');
+ var threadid = board.attr('id').replace("thread_", "");
board = board.data('board');
+ var parentboard = board;
+
+ if (matches[1] !== undefined) {
+ board = matches[1];
+ }
+
+
var $post = false;
var hovering = false;
var hovered_at;
@@ -76,11 +84,25 @@ onready(function(){
url: url,
context: document.body,
success: function(data) {
- $(data).find('div.post.reply').each(function() {
- if($('[data-board="' + board + '"] #' + $(this).attr('id')).length == 0)
- $('[data-board="' + board + '"]#' + threadid + " .post.reply:first").before($(this).css('display', 'none').addClass('hidden'));
+ var mythreadid = $(data).find('div[id^="thread_"]').attr('id').replace("thread_", "");
- });
+ if (mythreadid == threadid && parentboard == board) {
+ $(data).find('div.post.reply').each(function() {
+ if($('[data-board="' + board + '"] #' + $(this).attr('id')).length == 0) {
+ $('[data-board="' + board + '"]#thread_' + threadid + " .post.reply:first").before($(this).hide().addClass('hidden'));
+ }
+ });
+ }
+ else if ($('[data-board="' + board + '"]#thread_'+mythreadid).length > 0) {
+ $(data).find('div.post.reply').each(function() {
+ if($('[data-board="' + board + '"] #' + $(this).attr('id')).length == 0) {
+ $('[data-board="' + board + '"]#thread_' + mythreadid + " .post.reply:first").before($(this).hide().addClass('hidden'));
+ }
+ });
+ }
+ else {
+ $(data).find('div[id^="thread_"]').hide().attr('data-cached', 'yes').prependTo('form[name="postcontrols"]');
+ }
$post = $('[data-board="' + board + '"] div.post#reply_' + id);
if(hovering && $post.length > 0) {