Personal website https://benkurtovic.com/
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

10 年前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. function fix_tag_links() {
  2. $(".post-tag").attr("href", function() {
  3. return "/#" + encodeURIComponent($(this).text());
  4. });
  5. }
  6. function load_tag_filters() {
  7. var filter_posts = function() {
  8. var filter = [];
  9. $(".tag-selected").each(function() {
  10. filter.push($(this).data("tag"))
  11. });
  12. $("#post-list li").show();
  13. $("#null-post").hide();
  14. if ($(".tag-selected").length == 0)
  15. return;
  16. $("#post-list li").each(function() {
  17. var tags = $(this).data("tags").split("|");
  18. for (var i in filter) {
  19. if ($.inArray(filter[i], tags) == -1) {
  20. $(this).hide();
  21. return;
  22. }
  23. }
  24. });
  25. if ($("#post-list li:not(:hidden)").length == 0)
  26. $("#null-post").show();
  27. }
  28. if (window.location.hash) {
  29. var tags = decodeURIComponent(window.location.hash.substr(1)).split("|");
  30. $(".tag").each(function() {
  31. if ($.inArray($(this).data("tag"), tags) != -1)
  32. $(this).toggleClass("tag-selected");
  33. });
  34. filter_posts();
  35. }
  36. $(".tag").click(function() {
  37. var tags = [];
  38. $(this).toggleClass("tag-selected");
  39. $(".tag-selected").each(function() {
  40. tags.push($(this).data("tag"))
  41. });
  42. if (tags.length > 0)
  43. window.location.hash = encodeURIComponent(tags.join("|"));
  44. else
  45. history.pushState("", "", window.location.pathname);
  46. filter_posts();
  47. });
  48. }
  49. function load_paragraph_links() {
  50. $("#post").find("h1, h2, h3, h4, h5, h6").hover(function() {
  51. $(this).append($("<a>")
  52. .attr("href", "#" + this.id)
  53. .attr("class", "para-link")
  54. .text("¶"));
  55. }, function() {
  56. $(this).find(".para-link").remove();
  57. });
  58. }
  59. $(document).ready(function() {
  60. fix_tag_links();
  61. load_tag_filters();
  62. load_paragraph_links();
  63. });