leftypol_vichan/js/show-op.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

2012-04-29 16:31:45 +00: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 19:26:04 +00:00
* Copyright (c) 2014 Marcin Łabanowski <marcin@6irc.net>
2012-04-29 16:31:45 +00:00
*
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/show-op.js';
*
*/
$(document).ready(function(){
var showOPLinks = function() {
var OP;
if ($('div.banner').length == 0) {
2014-04-19 19:23:35 +00:00
OP = parseInt($(this).parent().find('div.post.op a.post_no:eq(1)').text());
2012-04-29 16:31:45 +00:00
} else {
2014-04-19 19:23:35 +00:00
OP = parseInt($('div.post.op a.post_no:eq(1)').text());
2012-04-29 16:31:45 +00:00
}
2012-08-27 13:01:08 +00:00
$(this).find('div.body a:not([rel="nofollow"])').each(function() {
2012-04-29 16:31:45 +00:00
var postID;
if(postID = $(this).text().match(/^>>(\d+)$/))
postID = postID[1];
else
return;
if (postID == OP) {
$(this).after(' <small>(OP)</small>');
}
});
};
$('div.post.reply').each(showOPLinks);
// allow to work with auto-reload.js, etc.
$(document).on('new_post', function(e, post) {
2014-04-19 19:23:35 +00:00
if ($(post).is('div.post.reply')) {
$(post).each(showOPLinks);
}
else {
$(post).find('div.post.reply').each(showOPLinks);
}
2012-04-29 16:31:45 +00:00
});
});
2014-04-19 19:23:35 +00:00