PageSourceSearch

https://blockchain.news/bn/js/loadmore.js?v=gSZd-4Ewj3gvfrLc4ANmgfkTMjchjeLwdzq02fMb9ic

js blockchain.news collected 2026-09-24 08:28:58 UTC 4,098 bytes, 99 lines download raw bytes

1// document.addEventListener('DOMContentLoaded', function () {
2//     const loadMoreButton = document.getElementById('load-more-btn');
3//     let pageIndex = 0; // Start with the first page
4//     const pageSize = 8; // Posts per page
5//     const postContainer = document.getElementById('postContainer');
6
7//     // Function to load posts
8//     function loadPosts() {
9//         // Disable button temporarily to prevent multiple clicks
10//         loadMoreButton.disabled = true;
11
12//         var currentUrl = window.location.href;
13//         var langParam = "";
14
15//         // Check if the current URL contains '/zh'
16//         if (currentUrl.includes('/zh')) {
17//             langParam = "lang=zh";
18//         }
19
20//         fetch(`/MorePost?pageIndex=${pageIndex}&pageSize=${pageSize}&${langParam}`)
21//             .then(response => response.text()) // Assuming the response is HTML
22//             .then(html => {
23//                 postContainer.insertAdjacentHTML('beforeend', html);
24//                 pageIndex++; // Increment the page index for next load
25
26//                 // Enable the Load More button again
27//                 loadMoreButton.disabled = false;
28
29//                 // Check the number of posts returned
30//                 const posts = html.match(/class="col-sm-6"/g) || [];
31//                 if (posts.length < pageSize) {
32//                     // If fewer posts than the pageSize are returned, hide the Load More button
33//                     loadMoreButton.style.display = 'none';
34//                 }
35//             })
36//             .catch(error => {
37//                 console.error('Error loading posts:', error);
38//                 // Re-enable the button if there's an error but consider providing feedback to the user
39//                 loadMoreButton.disabled = false;
40//             });
41//     }
42
43//     // Initial load
44//     loadPosts();
45
46//     // Load more posts on button click
47//     loadMoreButton.addEventListener('click', loadPosts);
48// });
49
50
51document.addEventListener('DOMContentLoaded', function () {
52    const loadMoreButton = document.getElementById('load-more-btn');
53    const postContainer = document.getElementById('postContainer');
54    if (!loadMoreButton || !postContainer) return;
55
56    // Desktop 3 列:12 条/页;Mobile 2 列:10 条/页(与 md 断点一致)
57    function getPageSize() {
58        return window.matchMedia('(min-width: 768px)').matches ? 12 : 10;
59    }
60
61    // SSR 已渲染第 1 页(pageIndex=0),Load More 从第 2 页(pageIndex=1) 开始
62    let pageIndex = postContainer.dataset.ssrLoaded === 'true' ? 1 : 0;
63
64    function loadPosts() {
65        loadMoreButton.disabled = true;
66
67        var langParam = '';
68        if (window.location.href.includes('/zh')) {
69            langParam = 'lang=zh';
70        }
71
72        var pageSize = getPageSize();
73        fetch('/MorePost?pageIndex=' + pageIndex + '&pageSize=' + pageSize + (langParam ? '&' + langParam : ''))
74            .then(function (response) { return response.text(); })
75            .then(function (html) {
76                postContainer.insertAdjacentHTML('beforeend', html);
77                pageIndex++;
78
79                loadMoreButton.disabled = false;
80
81                // 后端在返回不足一页(少于 pageSize)时会输出 <input id="morePostEnd" ...> 作为“没有更多”的标记;
82                // 或返回内容为空。命中任一条件才隐藏按钮,否则保持可继续点击。
83                if (html.indexOf('id="morePostEnd"') !== -1 || html.trim() === '') {
84                    loadMoreButton.style.display = 'none';
85                }
86            })
87            .catch(function (error) {
88                console.error('Error loading posts:', error);
89                loadMoreButton.disabled = false;
90            });
91    }
92
93    // 仅在没有 SSR 首屏时才自动加载第 1 页
94    if (postContainer.dataset.ssrLoaded !== 'true') {
95        loadPosts();
96    }
97
98    loadMoreButton.addEventListener('click', loadPosts);
99});

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.