The version of vichan running on lainchan.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6KB

  1. /*
  2. * show-backlinks.js
  3. * https://github.com/savetheinternet/Tinyboard/blob/master/js/show-backlinks.js
  4. *
  5. * Released under the MIT license
  6. * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
  7. * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
  8. *
  9. * Usage:
  10. * $config['additional_javascript'][] = 'js/jquery.min.js';
  11. * // $config['additional_javascript'][] = 'js/post-hover'; (optional; must come first)
  12. * $config['additional_javascript'][] = 'js/show-backlinks.js';
  13. *
  14. */
  15. onready(function(){
  16. var showBackLinks = function() {
  17. var reply_id = $(this).attr('id').replace(/^reply_/, '');
  18. $(this).find('div.body a:not([rel="nofollow"])').each(function() {
  19. var id, post, $mentioned;
  20. if(id = $(this).text().match(/^>>(\d+)$/))
  21. id = id[1];
  22. else
  23. return;
  24. $post = $('#reply_' + id);
  25. if($post.length == 0)
  26. return;
  27. $mentioned = $post.find('p.intro span.mentioned');
  28. if($mentioned.length == 0)
  29. $mentioned = $('<span class="mentioned unimportant"></span>').appendTo($post.find('p.intro'));
  30. if ($mentioned.find('a.mentioned-' + reply_id).length != 0)
  31. return;
  32. var $link = $('<a class="mentioned-' + reply_id + '" onclick="highlightReply(\'' + reply_id + '\');" href="#' + reply_id + '">&gt;&gt;' +
  33. reply_id + '</a>');
  34. $link.appendTo($mentioned)
  35. if (window.init_hover) {
  36. $link.each(init_hover);
  37. }
  38. });
  39. };
  40. $('div.post.reply').each(showBackLinks);
  41. $(document).on('new_post', function(e, post) {
  42. if ($(post).hasClass("reply")) {
  43. showBackLinks.call(post);
  44. }
  45. else {
  46. $(post).find('div.post.reply').each(showBackLinks);
  47. }
  48. });
  49. });