PageSourceSearch

https://spacewaves2.net/template/default/js/comments-lazy.js?v=2

js spacewaves2.net collected 2026-09-26 03:39:20 UTC 2,075 bytes, 70 lines download raw bytes

1/**
2 * 评论列表延迟到评论区进入视口后再加载。红点在 HTML 里写死,不发请求。
3 */
4(function () {
5  var el = document.getElementById('comments-container');
6  if (!el || el.getAttribute('data-comments-lazy-init') === '1') return;
7  el.setAttribute('data-comments-lazy-init', '1');
8
9  var target = document.getElementById('comments') ||
10    document.getElementById('discuss-space-waves') ||
11    el;
12
13  var ds = el.dataset;
14  var typeid = parseInt(ds.commentTypeid || '1', 10) || 1;
15  var loginNeeded = parseInt(ds.commentLoginNeeded || '0', 10) || 0;
16
17  function boot() {
18    if (typeof CommentSystem !== 'function') return;
19    new CommentSystem({
20      container: '#comments-container',
21      pagination: '.comments__pagination-show',
22      typeid: typeid,
23      source_title: ds.commentSourceTitle || document.title || '',
24      source_uri: ds.commentSourceUri || window.location.pathname || '/',
25      type: ds.commentType || 'tool',
26      loginNeeded: loginNeeded,
27      currentPage: 1,
28    });
29  }
30
31  function injectAjax() {
32    if (window.__commentsAjaxBooted) return;
33    window.__commentsAjaxBooted = true;
34    if (window.CommentSystem) {
35      boot();
36      return;
37    }
38    var s = document.createElement('script');
39    s.src = '/template/default/js/comments_ajax.js?v=2';
40    s.async = true;
41    s.onload = boot;
42    document.head.appendChild(s);
43  }
44
45  function isInView(node) {
46    var rect = node.getBoundingClientRect();
47    return rect.top < window.innerHeight && rect.bottom > 0;
48  }
49
50  if (!('IntersectionObserver' in window)) {
51    function onScroll() {
52      if (!isInView(target)) return;
53      window.removeEventListener('scroll', onScroll);
54      injectAjax();
55    }
56    window.addEventListener('scroll', onScroll, { passive: true });
57    onScroll();
58    return;
59  }
60
61  var io = new IntersectionObserver(
62    function (entries, o) {
63      if (!entries[0] || !entries[0].isIntersecting) return;
64      o.disconnect();
65      injectAjax();
66    },
67    { rootMargin: '80px 0px', threshold: 0.01 }
68  );
69  io.observe(target);
70})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.