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.

51 lines
1.1KB

  1. if (active_page == 'thread' || active_page == 'index') {
  2. $(document).ready(function(){
  3. function arrayRemove(a, v) { a.splice(a.indexOf(v) == -1 ? a.length : a.indexOf(v), 1); }
  4. var idshighlighted = [];
  5. function getPostsById(id){
  6. return $(".poster_id").filter(function(i){
  7. return $(this).text() == id;
  8. });
  9. }
  10. function getMasterPosts(parents){
  11. if(!parents.hasClass("post")) return;
  12. var toRet = [];
  13. $(parents).each(function(){
  14. if($(this).hasClass("post"))
  15. toRet.push($(this));
  16. });
  17. return toRet;
  18. }
  19. var id_highlighter = function(){
  20. var id = $(this).text();
  21. if($.inArray(id, idshighlighted) !== -1){
  22. arrayRemove(idshighlighted, id);
  23. $(getMasterPosts(getPostsById(id).parents())).each(function(i){
  24. $(this).removeClass("highlighted");
  25. });
  26. }else{
  27. idshighlighted.push(id);
  28. $(getMasterPosts(getPostsById(id).parents())).each(function(i){
  29. $(this).addClass("highlighted");
  30. });
  31. }
  32. }
  33. $(".poster_id").on('click', id_highlighter);
  34. $(document).on('new_post', function(e, post) {
  35. $(post).find('.poster_id').on('click', id_highlighter);
  36. });
  37. });
  38. }