diff --git a/js/show-op.js b/js/show-op.js index 7bb144cf..14dfe467 100644 --- a/js/show-op.js +++ b/js/show-op.js @@ -11,41 +11,40 @@ * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/show-op.js'; - * */ -$(document).ready(function(){ - var showOPLinks = function() { - var OP; - +$(document).ready(function() { + let showOPLinks = function() { + let OP; + if ($('div.banner').length == 0) { OP = parseInt($(this).parent().find('div.post.op a.post_no:eq(1)').text()); } else { OP = parseInt($('div.post.op a.post_no:eq(1)').text()); } - + $(this).find('div.body a:not([rel="nofollow"])').each(function() { - var postID; - - if(postID = $(this).text().match(/^>>(\d+)$/)) + let postID = $(this).text().match(/^>>(\d+)$/); + + if (postID) { postID = postID[1]; - else + } else { return; - + } + if (postID == OP) { $(this).after(' (OP)'); } }); }; - + $('div.post.reply').each(showOPLinks); - + // allow to work with auto-reload.js, etc. $(document).on('new_post', function(e, post) { if ($(post).is('div.post.reply')) { $(post).each(showOPLinks); - } - else { + } else { $(post).find('div.post.reply').each(showOPLinks); } });