PageSourceSearch

https://www.link-ss.co.jp/data/top_render.js

js link-ss.co.jp collected 2026-10-04 19:03:29 UTC 2,522 bytes, 106 lines download raw bytes

1// MT Cloud インデックステンプレート
2// 出力ファイル: data/top_render.js
3(function () {
4  function resolveLink(item) {
5    var href = '#';
6    var target = '';
7
8    if (item.link_type === 'url') {
9      href = item.url;
10      target = '_blank';
11    }
12
13    if (item.link_type === 'detail') {
14      href = item.permalink;
15    }
16
17    if (item.link_type === 'file') {
18      href = item.file_url;
19      target = '_blank';
20    }
21
22    return {
23      href: href,
24      target: target,
25      hasLink: item.link_type !== 'none'
26    };
27  }
28
29  function renderNewsItem(item) {
30    var link = resolveLink(item);
31    var categoryClass = item.category_basename === 'press-release' ? 'default' : 'is-media';
32
33    var li = document.createElement('li');
34
35    var a = document.createElement('a');
36    a.className = 'newsItem';
37
38    if (link.hasLink) {
39      a.setAttribute('href', link.href);
40
41      if (link.target) {
42        a.setAttribute('target', link.target);
43      }
44    }
45
46    var category = document.createElement('span');
47    category.className = 'newsCategory ' + categoryClass;
48    category.innerHTML = '<span>' + item.category + '</span>';
49
50    var date = document.createElement('span');
51    date.className = 'newsDate';
52    date.innerHTML = '<time>' + item.date + '</time>';
53
54    var text = document.createElement('span');
55    text.className = 'newsText';
56
57    item.title.split(/\r?\n/).forEach(function (line, index) {
58      if (index > 0) {
59        text.appendChild(document.createElement('br'));
60      }
61      text.appendChild(document.createTextNode(line));
62    });
63
64    if (item.file_url) {
65      var file = document.createElement('span');
66      file.className = 'newsFile';
67      file.innerHTML =
68        '<span><img src="/common/img/icon_pdf.svg" alt="PDF"></span>' +
69        item.file_size +
70        'KB';
71
72      text.appendChild(file);
73    }
74
75    a.appendChild(category);
76    a.appendChild(date);
77    a.appendChild(text);
78
79    li.appendChild(a);
80
81    return li;
82  }
83
84  function render(news) {
85    var container = document.getElementById('news-container');
86
87    if (!container) {
88      return;
89    }
90
91    news.slice(0, 3).forEach(function (item) {
92      container.appendChild(renderNewsItem(item));
93    });
94  }
95
96  window.addEventListener('load', function () {
97    fetch('/data/news.json?t=' + Date.now())
98      .then(function (res) {
99        return res.json();
100      })
101      .then(render)
102      .catch(function (err) {
103        console.error('[top_render] news.json FAILED', err);
104      });
105  });
106})();

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.