2012-04-30 02:31:45 +10:00
|
|
|
/*
|
|
|
|
* show-op
|
|
|
|
* https://github.com/savetheinternet/Tinyboard/blob/master/js/show-op.js
|
|
|
|
*
|
|
|
|
* Adds "(OP)" to >>X links when the OP is quoted.
|
|
|
|
*
|
|
|
|
* Released under the MIT license
|
|
|
|
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
|
2014-04-19 21:26:04 +02:00
|
|
|
* Copyright (c) 2014 Marcin Łabanowski <marcin@6irc.net>
|
2012-04-30 02:31:45 +10:00
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
|
|
|
* $config['additional_javascript'][] = 'js/show-op.js';
|
|
|
|
*/
|
|
|
|
|
2024-08-21 12:00:41 +02:00
|
|
|
$(document).ready(function() {
|
2024-08-21 12:37:23 +02:00
|
|
|
let threadPageOp;
|
|
|
|
if (active_page === "thread") {
|
|
|
|
threadPageOp = parseInt($('div.post.op a.post_no:eq(1)').text());
|
|
|
|
}
|
2024-08-21 12:00:41 +02:00
|
|
|
|
2024-08-21 12:37:23 +02:00
|
|
|
let showOPLinks = function() {
|
|
|
|
// Use the cached op if we're in a thread, otherwise fetch it.
|
2024-08-21 12:51:57 +02:00
|
|
|
let localOp = threadPageOp ? threadPageOp : parseInt($(this).parent().parent().parent().find('div.post.op a.post_no:eq(1)').text());
|
2024-08-21 12:00:41 +02:00
|
|
|
|
2024-08-21 12:51:57 +02:00
|
|
|
let postID = $(this).text().match(/^>>(\d+)$/);
|
2024-08-21 12:00:41 +02:00
|
|
|
|
2024-08-21 12:51:57 +02:00
|
|
|
if (postID) {
|
|
|
|
postID = parseInt(postID[1]);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2024-08-21 12:00:41 +02:00
|
|
|
|
2024-08-21 12:51:57 +02:00
|
|
|
if (postID === localOp) {
|
|
|
|
$(this).after(' <small>(OP)</small>');
|
|
|
|
}
|
2012-04-30 02:31:45 +10:00
|
|
|
};
|
2024-08-21 12:00:41 +02:00
|
|
|
|
2024-08-21 12:51:57 +02:00
|
|
|
$('div.post.reply > div.body a:not([rel="nofollow"])').each(showOPLinks);
|
2024-08-21 12:00:41 +02:00
|
|
|
|
2012-04-30 02:31:45 +10:00
|
|
|
// allow to work with auto-reload.js, etc.
|
2014-01-21 19:25:11 +01:00
|
|
|
$(document).on('new_post', function(e, post) {
|
2024-08-21 12:51:57 +02:00
|
|
|
if ($(post).is('div.post.reply > div.body a:not([rel="nofollow"])')) {
|
2014-04-19 21:23:35 +02:00
|
|
|
$(post).each(showOPLinks);
|
2024-08-21 12:00:41 +02:00
|
|
|
} else {
|
2024-08-21 12:51:57 +02:00
|
|
|
$(post).find('div.post.reply > div.body a:not([rel="nofollow"])').each(showOPLinks);
|
2014-04-19 21:23:35 +02:00
|
|
|
}
|
2012-04-30 02:31:45 +10:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-04-19 21:23:35 +02:00
|
|
|
|