diff --git a/css/futaba.css b/css/futaba.css index 2551e23..a351b79 100644 --- a/css/futaba.css +++ b/css/futaba.css @@ -155,8 +155,8 @@ hr { } .reply { - background: #F0E0D6; - color: #800000; + background: #F0E0D6 !important; + color: #800000 !important; } .replyhl { diff --git a/imgboard.php b/imgboard.php index 5c3b520..57ff69e 100644 --- a/imgboard.php +++ b/imgboard.php @@ -566,7 +566,7 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) die(__('This post requires moderation before it can be displayed')); } - $html = buildPost($post, isset($_GET['res'])); + $html = buildPost($post, isset($_GET['res']), true); if (isset($_GET['res'])) { $html = fixLinksInRes($html); } diff --git a/inc/defines.php b/inc/defines.php index 822bcd0..6aaac90 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -109,6 +109,9 @@ if (!defined('TINYIB_EXPANDWIDTH')) { if (!defined('TINYIB_TIMEZONE')) { define('TINYIB_TIMEZONE', ''); } +if (!defined('TINYIB_BACKLINKS')) { + define('TINYIB_BACKLINKS', true); +} if (!defined('TINYIB_CATALOG')) { define('TINYIB_CATALOG', true); } diff --git a/inc/functions.php b/inc/functions.php index 02c94ea..7a70031 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -441,6 +441,13 @@ function setParent() { return TINYIB_NEWTHREAD; } +function getParent($post) { + if ($post['parent'] == TINYIB_NEWTHREAD) { + return $post['id']; + } + return $post['parent']; +} + function isRawPost() { if (isset($_POST['rawpost'])) { list($loggedin, $isadmin) = manageCheckLogIn(false); diff --git a/inc/html.php b/inc/html.php index 4231a71..6afb8ea 100644 --- a/inc/html.php +++ b/inc/html.php @@ -413,7 +413,36 @@ EOF; return $output; } -function buildPost($post, $res) { +function backlinks($post) { + if (!TINYIB_BACKLINKS) { + return ''; + } + global $thread_cache; + + $parent_id = getParent($post); + + if (!isset($thread_cache[$parent_id])) { + $thread_cache[$parent_id] = postsInThreadByID($parent_id); + } + + $needle = '>>' . $post['id']; + + $return = ''; + foreach ($thread_cache[$parent_id] as $reply) { + if (strpos($reply['message'], $needle) !== false) { + if ($return != '') { + $return .= ', '; + } + $return .= postLink('>>' . $reply['id']); + } + } + if ($return != '') { + $return = ' ' . $return; + } + return ' ' . $return . ''; +} + +function buildPost($post, $res, $compact=false) { $return = ""; $threadid = ($post['parent'] == TINYIB_NEWTHREAD) ? $post['id'] : $post['parent']; @@ -509,17 +538,22 @@ EOF; } } if ($post['parent'] == TINYIB_NEWTHREAD) { + $return .= '
'; $return .= $filehtml; } else { - $return .= <<'; + } else { + $return .= << ¨ - + EOF; + } } $return .= << EOF; + if ($post['parent'] != TINYIB_NEWTHREAD) { + $return .= backlinks($post); + } + if ($post['parent'] != TINYIB_NEWTHREAD) { $return .= $filehtml; } - if ($post['parent'] == TINYIB_NEWTHREAD && $res == TINYIB_INDEXPAGE) { - $return .= " [" . __("Reply") . "]"; + if ($post['parent'] == TINYIB_NEWTHREAD) { + if ($res == TINYIB_INDEXPAGE) { + $return .= " [" . __("Reply") . "]"; + } + $return .= backlinks($post); } if (TINYIB_TRUNCATE > 0 && !$res && substr_count($post['message'], '
') > TINYIB_TRUNCATE) { // Truncate messages on board index pages for readability @@ -560,6 +601,7 @@ ${post["message"]} EOF; if ($post['parent'] == TINYIB_NEWTHREAD) { + $return .= '
'; if ($res == TINYIB_INDEXPAGE && $post['omitted'] > 0) { if ($post['omitted'] == 1) { $return .= '' . __('1 post omitted. Click Reply to view.') . ''; @@ -567,6 +609,8 @@ EOF; $return .= '' . sprintf(__('%d posts omitted. Click Reply to view.'), $post['omitted']) . ''; } } + } else if ($compact) { + $return .= ''; } else { $return .= << @@ -639,10 +683,14 @@ EOF; $postform = buildPostForm($parent) . '
'; } - $js_autorefresh = ''; + $js = ''; + $js .= 'var autoRefreshDelay = ' . TINYIB_AUTOREFRESH . ';'; + $js .= 'var autoRefreshThreadID = ' . $parent . ';'; + $js .= 'var autoRefreshPostID = ' . $lastpostid . ';'; } + $js .= ''; $txt_style = __('Style'); $txt_password = __('Password'); @@ -675,7 +723,7 @@ EOF;
$postingmode $postform - $js_autorefresh + $js
>>' + $(element).attr('postID') + ''); + setPostAttributes(reflinks, false); + } + } + $(this).attr('refID', m[1]); $(this).hover(function (e) { var preview = document.getElementById('ref' + $(this).attr('refID')); @@ -254,15 +263,21 @@ function setPostAttributes(element) { $(preview).attr('refID', $(this).attr('refID')); - var refpost = $('.post[postID="' + $(this).attr('refID') + '"]').first(); + var refpost = $('#post' + $(this).attr('refID')); var refid = $(this).attr('refID'); if (downloaded_posts[refid]) { preview.className = 'hoverpost'; $(preview).html(downloaded_posts[refid]); + if ($(preview).find('div:first').hasClass('reply')) { + $(preview).addClass('reply'); + } } else if (refpost.html() && refpost.html() != undefined) { preview.className = 'hoverpost'; $(preview).html(refpost.html()); + if (refpost.hasClass('reply')) { + $(preview).addClass('reply'); + } } else { $(preview).html('
Loading...
'); $(preview).fadeIn(125); @@ -273,12 +288,15 @@ function setPostAttributes(element) { downloaded_posts[refid] = response; preview.className = 'hoverpost'; $(preview).html(response); + if ($(preview).find('div:first').hasClass('reply')) { + $(preview).addClass('reply'); + } }, dataType: 'html' }); } - insertAfter(preview, this); + $(document.body).append(preview); } $(preview).css('left', mouseX+14).css('top', mouseY+7); }, function (e) { diff --git a/settings.default.php b/settings.default.php index 1e9dd74..b1d7304 100644 --- a/settings.default.php +++ b/settings.default.php @@ -46,6 +46,7 @@ define('TINYIB_TRUNCATE', 15); // Messages are truncated to this many lin define('TINYIB_WORDBREAK', 80); // Words longer than this many characters will be broken apart [0 to disable] define('TINYIB_EXPANDWIDTH', 85); // Expanded content size as a percentage of the screen's width define('TINYIB_TIMEZONE', 'UTC'); // See https://secure.php.net/manual/en/timezones.php - e.g. America/Los_Angeles +define('TINYIB_BACKLINKS', true); // Display reflinks to replies that reference a post define('TINYIB_CATALOG', true); // Generate catalog page define('TINYIB_JSON', true); // Generate JSON files define('TINYIB_DEFAULTSTYLE', 'futaba'); // Default page style