Add post type hint to reflinks

Resolves #226.
This commit is contained in:
Trevor Slocum 2021-06-11 00:31:40 -07:00
parent 306e3e5cf8
commit 4c2ec96e6b
5 changed files with 20 additions and 14 deletions

View File

@ -190,9 +190,9 @@ hr {
}
.reply {
background: #D6DAF0;
color: #000000;
font-family: serif;
background: #D6DAF0 !important;
color: #000000 !important;
font-family: serif !important;
}
.replyhl {

View File

@ -572,6 +572,7 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name'])
if (isset($_GET['res'])) {
$html = fixLinksInRes($html);
}
echo $html;
die();
// Check if the request is to auto-refresh a thread

View File

@ -176,7 +176,8 @@ function fixLinksInRes($html) {
function _postLink($matches) {
$post = postByID($matches[1]);
if ($post) {
return '<a href="res/' . ($post['parent'] == TINYIB_NEWTHREAD ? $post['id'] : $post['parent']) . '.html#' . $matches[1] . '">' . $matches[0] . '</a>';
$is_op = $post['parent'] == TINYIB_NEWTHREAD;
return '<a href="res/' . ($is_op ? $post['id'] : $post['parent']) . '.html#' . $matches[1] . '" class="' . ($is_op ? 'refop' : 'refreply') . '">' . $matches[0] . '</a>';
}
return $matches[0];
}

View File

@ -441,7 +441,7 @@ function backlinks($post) {
if ($return != '') {
$return = '&nbsp;' . $return;
}
return ' <small><span id="reflinks' . $post['id'] . '" class="reflink">' . $return . '</span></small>';
return ' <small><span id="backlinks' . $post['id'] . '" class="backlinks">' . $return . '</span></small>';
}
function buildPost($post, $res, $compact=false) {

View File

@ -240,15 +240,15 @@ function setPostAttributes(element, autorefresh) {
}
if (enablebacklinks && autorefresh) {
reflinks = $('#reflinks' + m[1]);
if (reflinks) {
if (reflinks.html() == '') {
reflinks.append('&nbsp;');
backlinks = $('#backlinks' + m[1]);
if (backlinks) {
if (backlinks.html() == '') {
backlinks.append('&nbsp;');
} else {
reflinks.append(', ');
backlinks.append(', ');
}
reflinks.append('<a href="' + $(element).attr('postLink') + '">&gt;&gt;' + $(element).attr('postID') + '<a>');
setPostAttributes(reflinks, false);
backlinks.append('<a href="' + $(element).attr('postLink') + '">&gt;&gt;' + $(element).attr('postID') + '<a>');
setPostAttributes(backlinks, false);
}
}
@ -275,11 +275,15 @@ function setPostAttributes(element, autorefresh) {
} else if (refpost.html() && refpost.html() != undefined) {
preview.className = 'hoverpost';
$(preview).html(refpost.html());
if (refpost.hasClass('reply')) {
if (refpost.prop("tagName").toLowerCase() == 'td') {
$(preview).addClass('reply');
}
} else {
$(preview).html('<div class="hoverpost" style="padding: 14px;">Loading...</div>');
extraclasses = '';
if ($(this).hasClass('refreply')) {
extraclasses = ' reply';
}
$(preview).html('<div class="hoverpost' + extraclasses + '" style="padding: 14px;">Loading...</div>');
$(preview).fadeIn(125);
$.ajax({
url: base_url + $(this).attr('refID'),