PageSourceSearch

https://www.plastics.toray/news/js/news.js

js plastics.toray collected 2026-09-29 18:21:12 UTC 29,792 bytes, 911 lines download raw bytes

1(function ($, undefined) {
2  "use strict";
3
4  const { createClient } = microcms;
5
6  const FilterComp = function () {
7    this.client = createClient({
8      serviceDomain: "3kxo8u9nf1",
9      // apiKey: 'ac14fd9441e74441bf3d27c001e7ddb131fb',//本番用
10      apiKey: "c6086e40236a405c9410b8c52bed50b428f0", //画面プレビュー用
11    });
12    this.endpoint = "toray_news";
13    this.queryData = document.location.search;
14    this.resData = [];
15    this.offsetNum = 0;
16    this.limitNum = 10;
17    this.totalCountNum = 0;
18    this.paramQ = "";
19    this.paramYear = "";
20    this.paramLanguage = "";
21    this.paramRegion = [];
22    this.paramNewsCategory = [];
23    this.paramNewsTag = [];
24    this.parambusinessWebsites = "";
25    this.paramContentId = "";
26    this.filterValue = "";
27    this.flagFirst = true;
28    this.flagMore = false;
29    this.earliestYear = 2021;
30    this.beginsDate = "2021-01-01";
31  };
32
33  FilterComp.prototype.init = function () {
34    this.selector();
35    this.onCreate();
36    this.eventSet();
37  };
38
39  FilterComp.prototype.selector = function () {
40    this.filterType = $("#js_setFilter").data("type");
41    this.setFilter = $("#js_setFilter").data();
42    this.createType = $("#js_getCreateType").val();
43    this.setLimit = parseInt($("#js_limit").val());
44    this.loading = document.getElementById("js_newsloading");
45    this.paramLanguage = $("#js_language").val();
46    this.parambusinessWebsites = $("#js_businessWebsites").val();
47
48    //list
49    this.radioYear = $('[name="year"]');
50    this.radioCategory = $('[name="category"]');
51    this.inputSearch = $('[name="q"]');
52    this.radioLanguage = $('[name="language"]');
53    this.checkRegion = $('[name="region"]');
54    this.checknewsTag = $('[name="newsTag"]');
55    this.filterYear = $("#js_filter_year");
56    this.filterItems = $("#filterItems");
57    this.filterBoxToggle = $("#filterBoxToggle");
58    this.buttonBackFilter = $("#filterBackBtn");
59    this.detailLink = $("#js_detailLink");
60    this.resultWrap = $(".bl_resultWrap");
61    this.formBody = $("#dataFilterForm");
62    this.buttonSearch = $("#dataSearchBtn");
63    this.inputSearchText = $("#dataSearchInput");
64    this.buttonReset = $("#dataFilterReset");
65    this.buttonFilter = $("#dataFilterSumbmit");
66    this.listBody = $("#dataListBody");
67    this.buttonMore = $("#dataMoreList");
68    this.buttonCategory = "";
69    const dataFilterForm = document.getElementById("dataFilterForm");
70    if (dataFilterForm) {
71      this.tabpanelInput = dataFilterForm.querySelectorAll(
72        '[role="tabpanel"] input'
73      );
74    }
75
76    //article
77    this.targetArticle = document.getElementById("dy_article");
78    this.elmTitle = document.getElementsByTagName("title")[0];
79    this.elmHtml = document.getElementsByTagName("html")[0];
80    this.htmlLang = this.elmHtml.getAttribute("lang");
81  };
82
83  // ロードイベント
84  FilterComp.prototype.onCreate = function () {
85    const self = this;
86
87    // self.getQueryString();
88
89    // 年選択リスト生成
90    if (self.radioYear) {
91      const currentYear = new Date().getFullYear();
92      let yearlist = "";
93      for (var i = currentYear; i >= self.earliestYear; i--) {
94        yearlist += `<li><input type="radio" name="year" value="${i}" id="y_${i}"><label for="y_${i}">${i}</label></li>`;
95      }
96      self.filterYear.append(yearlist);
97    }
98
99    // データリクエスト数
100    // html側でリミット値の指定がある場合
101    if (self.setLimit) {
102      self.limitNum = parseInt(self.setLimit);
103    }
104
105    // ロード時にpageが2以上の場合、初回のリクエスト数を調整する
106    const url = new URL(location);
107    let pageNum = Number(url.searchParams.get("page"));
108    if (pageNum > 1) {
109      self.limitNum = parseInt(self.setLimit * pageNum);
110    }
111
112    switch (self.createType) {
113      case "list":
114        self.formAccessibility();
115        self.filterToggle();
116        self.queryDataCreate();
117        break;
118      case "article":
119        self.getQueryString();
120        self.apiRequest("");
121        break;
122    }
123  };
124
125  // 各種イベント
126  FilterComp.prototype.eventSet = function () {
127    const self = this;
128
129    // カテゴリ選択
130    self.radioCategory.on("change", function () {
131      // 他カテゴリに付随する項目のチェックを外す
132      self.tabpanelInput.forEach((element) => {
133        element.checked = false;
134      });
135    });
136
137    // 絞り込むボタン
138    self.buttonFilter.on("click", function () {
139      self.filterReset();
140      self.queryDataCreate();
141    });
142
143    // 検索窓
144    self.inputSearchText.on("keypress", function (e) {
145      if (e.code === "Enter") {
146        e.preventDefault();
147        self.filterReset();
148        self.queryDataCreate();
149      }
150    });
151
152    // 検索ボタン
153    self.buttonSearch.on("click", function () {
154      self.filterReset();
155      self.queryDataCreate();
156    });
157
158    // リセットボタン
159    self.buttonReset.on("click", function () {
160      self.filterReset();
161      self.formBody.get(0).reset();
162      self.queryDataCreate();
163    });
164
165    // もっと見るボタン
166    self.buttonMore.on("click", function (e) {
167      e.preventDefault();
168      // offset設定する
169      self.offsetNum = parseInt(self.offsetNum + self.limitNum);
170      // pageが2以上のとき初回ロードで変更したlimitNumをもとに戻す
171      if (self.setLimit) {
172        self.limitNum = parseInt(self.setLimit);
173      }
174      // flagMore
175      self.flagMore = true;
176      // APIリクエスト用
177      self.apiRequest(self.filterValue);
178      // クエリパラメータ制御(検索インデックス対応)
179      const url = new URL(location);
180      let pageNum = Number(url.searchParams.get("page"));
181      pageNum++;
182      url.searchParams.set("page", pageNum);
183      if (url.search.length > 0) {
184        history.pushState("", "", url.href);
185      }
186    });
187
188    // 絞り込みパネルへ戻るボタン
189    self.buttonBackFilter.on("click", function () {
190      self.scrolltoElm(self.filterItems);
191    });
192
193    // SNSシェアボタン
194    $(document).on("click", ".bl_snsShare a", function () {
195      window.open(
196        this.href,
197        "snswindow",
198        "width=550, height=450,personalbar=0,toolbar=0,scrollbars=1,resizable=1"
199      );
200      return false;
201    });
202  };
203
204  // クエリパラメータpageをリセット
205  FilterComp.prototype.filterReset = function () {
206    const self = this;
207    const url = new URL(location);
208    const page = url.searchParams.get("page");
209    const existingInput = $(".addParam");
210    url.searchParams.set("page", "1");
211    history.pushState("", "", url.search);
212    self.offsetNum = 0;
213    self.flagMore = false;
214    self.filterValue = "";
215    self.listBody.empty();
216    existingInput.remove();
217  };
218
219  // クエリパラメータをオブジェクトに変換
220  FilterComp.prototype.getQueryString = function () {
221    const self = this;
222    self.paramRegion = [];
223    self.paramNewsCategory = [];
224    self.paramNewsTag = [];
225
226    if (1 < document.location.search.length) {
227      let query = document.location.search.substring(1),
228        j = 0,
229        k = 0,
230        l = 0,
231        m = 0,
232        n = 0,
233        o = 0,
234        parameters = query.split("&");
235
236      for (let i = 0; i < parameters.length; i++) {
237        let element = parameters[i].split("="),
238          paramName = decodeURIComponent(element[0]),
239          paramValue = decodeURIComponent(element[1]);
240
241        self.formBody.find('input:not([type="text"])').each(function () {
242          let val = $(this).val(),
243            name = $(this).attr("name");
244          if (paramName === name && paramValue === val) {
245            $(this).prop("checked", true);
246          }
247        });
248
249        if (paramName == "contentId") {
250          self.paramContentId = paramValue;
251        }
252        if (paramName == "q") {
253          self.paramQ = paramValue;
254        }
255        if (paramName == "year") {
256          self.paramYear = paramValue;
257        }
258        if (paramName == "newsCategory") {
259          self.paramNewsCategory[j] = paramValue;
260          j++;
261        }
262        if (paramName == "newsTag") {
263          self.paramNewsTag[m] = paramValue;
264          m++;
265        }
266        if (paramName == "region") {
267          self.paramRegion[l] = paramValue;
268          l++;
269        }
270        // result[paramName] = decodeURIComponent(paramValue);
271      }
272      // return result;
273    }
274    return null;
275  };
276
277  // APIリクエスト用クエリ設定
278  FilterComp.prototype.queryDataCreate = function () {
279    const self = this;
280
281    // 初期化
282    self.filterValue = "";
283    let arrayFilter = [];
284
285    // クエリ変換
286    const setQueryStr = function (param, name) {
287      let str = "";
288      for (let i = 0; i < param.length; i++) {
289        str += "[or]" + name + "[contains]" + param[i];
290      }
291      if (str.slice(0, 4) === "[or]") {
292        str = str.slice(4);
293      }
294      self.filterValue += "[and](" + str + ")";
295    };
296
297    // クエリパラメータからpageを取得
298    const url = new URL(window.location.href);
299    const year = url.searchParams.get("year");
300
301    // yearが設定されていれば、対応する入力をcheckedにする
302    if (year > 1) {
303      self.radioYear.filter(`[value="${year}"]`).prop("checked", true);
304      self.paramYear = year;
305    }
306
307    // formの内容をシリアライズしてpageパラメータを追加
308    let query = `?${self.formBody.serialize()}`;
309
310    // page設定
311    if (self.filterType !== "index") {
312      const page = parseInt(url.searchParams.get("page") || "1");
313      // if (page === null || page <= 1 || page === '') {
314      //     query += '&page=1';
315      // } else {
316      //     const pageNum = url.searchParams.get('page');
317      //     query += `&page=${pageNum}`;
318      //     // self.offsetNum = parseInt(self.limitNum * pageNum - self.limitNum);
319      // }
320      if (page > 1) {
321        query += `&page=${page}`;
322      } else {
323        query += "&page=1";
324      }
325    }
326
327    // 更新されたクエリパラメータで履歴を更新
328    // ページロード時に更新するとyearパラメータが消えるので2回目以降で更新されるようにする
329    // クエリパラメータが存在しない場合pushStageしないとfiltersの設定が無効になる
330    if (self.flagFirst === false || url.search === "") {
331      history.pushState({}, "", url.pathname + query);
332    }
333
334    // URLクエリから設定
335    self.getQueryString();
336
337    // language
338    if (self.paramLanguage) {
339      arrayFilter.push(`language[contains]${self.paramLanguage}`);
340    }
341
342    // businessWebsites
343    if (self.parambusinessWebsites) {
344      arrayFilter.push(`businessWebsites[contains]${self.parambusinessWebsites}`);
345    }
346
347    // year
348    if (self.paramYear === "") {
349      // リクエストするデータの期間を設定
350      arrayFilter.push(`date[greater_than]${self.beginsDate}`);
351    } else {
352      arrayFilter.push(`date[contains]${self.paramYear}`);
353    }
354
355    self.filterValue = arrayFilter.join('[and]');
356
357    // value文字列整形
358    if (self.filterValue.slice(0, 5) === "[and]") {
359      self.filterValue = self.filterValue.slice(5);
360    }
361
362    // console.log(self.filterValue);
363    self.apiRequest(self.filterValue);
364
365    // TOPページでクエリパラメータを表示しない
366    if (self.filterType === "index") {
367      const url = new URL(window.location.href);
368      history.replaceState("", "", url.pathname);
369    }
370  };
371
372  // APIリクエスト
373  FilterComp.prototype.apiRequest = function (filtersValue) {
374    const self = this;
375
376    switch (self.createType) {
377      case "list":
378        //loading表示
379        self.loading.classList.add("is_show");
380        self.client
381          .get({
382            endpoint: self.endpoint,
383            queries: {
384              limit: self.limitNum,
385              offset: self.offsetNum,
386              q: self.paramQ,
387              orders: "-date,-publishedAt,-createdAt",
388              fields:
389                "id,date,language,region,newsCategory,newsTag,businessWebsites,title,directLink",
390              filters: filtersValue,
391            },
392          })
393          .then((res) => {
394            // console.log(res);
395            self.totalCountNum = res.totalCount;
396            self.filterListCreate(res.contents);
397          })
398          .catch((err) => console.log(err));
399        break;
400
401      case "article":
402        //loading表示
403        self.loading.classList.add("is_show");
404        self.client
405          .get({
406            endpoint: self.endpoint,
407            contentId: self.paramContentId,
408            fields:
409              "id,date,language,newsCategory,newsTag,title,author,article,importArticle",
410          })
411          .then((res) => {
412            self.totalCountNum = res.totalCount;
413            self.articleCreate(res);
414          })
415          .catch((err) => console.log(err));
416        break;
417    }
418  };
419
420  // 検索結果のリスト生成
421  FilterComp.prototype.filterListCreate = function (data) {
422    const self = this;
423    let str = "";
424    let listData = data;
425
426    // 値が存在しない場合は[aria-hidden="true"]で非表示にする
427    let dataBool = (val) => {
428      if (val === undefined || val === null) {
429        return true;
430      } else {
431        return false;
432      }
433    };
434
435    if (listData.length) {
436      for (let i in listData) {
437        //id,date,language,region,newsCategory,newsTag,title,directLink
438        let itemId = listData[i].id,
439          itemDate = listData[i].date,
440          // itemDatetime = String(listData[i].date.slice(0,10)),
441          itemDatetime = self.dateTimeTransformation(itemDate),
442          itemDateText = self.localTimeTransformation(itemDate),
443          itemLanguage = listData[i].language,
444          itemRegion = listData[i].region,
445          itemNewsCategory = listData[i].newsCategory,
446          itemNewsTag = listData[i].newsTag,
447          itembusinessWebsites = listData[i].businessWebsites,
448          itemTitle = listData[i].title,
449          itemDirectLink = listData[i].directLink,
450          elmTitle = "",
451          elmThumb = "",
452          elmNewsTag = "",
453          elmCategory = "";
454
455        // ニュースカテゴリボタン
456        if (itemNewsCategory !== undefined && itemNewsCategory !== null) {
457          const id = itemNewsCategory.id;
458          let categoryName = "";
459          if (self.htmlLang === "ja") {
460            categoryName = itemNewsCategory.name_ja;
461          } else {
462            categoryName = itemNewsCategory.name_en;
463          }
464          elmCategory = `<span class="cat" data-id="${id}">${categoryName}</span>`;
465        }
466
467        // プレスリリースカテゴリボタン
468        if (itemNewsTag !== undefined && itemNewsTag !== null) {
469          itemNewsTag.forEach((el) => {
470            const id = el.id;
471            let busSegName = "";
472            if (self.htmlLang === "ja") {
473              busSegName = el.name_ja;
474            } else {
475              busSegName = el.name_en;
476            }
477            elmNewsTag += `<span class="subcat" data-id="${id}">${busSegName}</span>`;
478          });
479        }
480
481        // URL
482        if (itemDirectLink !== undefined && itemDirectLink !== null) {
483          elmTitle = `<a href="${itemDirectLink}" target="_blank" rel="noreferrer" class="_iconWindow">${itemTitle}</a>`;
484        } else {
485          let directory = "";
486          if (self.htmlLang !== "en") {
487            if (self.htmlLang === "zh-cn") {
488              self.htmlLang = "zh";
489            }
490            directory = `/${self.htmlLang}`;
491          }
492
493          elmTitle = `<a href="${directory}/news/article.html?contentId=${itemId}">${itemTitle}</a>`;
494        }
495
496        str += `
497                <div class="item">
498                    <time class="date" datetime="${itemDatetime}">${itemDateText}</time>
499                    <p class="desc">${elmTitle}</p>
500                </div>`;
501      }
502    } else {
503      str = self.htmlItem("norecord");
504    }
505
506    // HTML書き出し
507    self.listBody.append(str);
508
509    // 「もっと見る」表示制御
510    if (self.totalCountNum > self.limitNum + self.offsetNum) {
511      const url = new URL(location);
512      let pageNum = Number(url.searchParams.get("page"));
513      pageNum++;
514      url.searchParams.set("page", pageNum);
515      self.buttonMore.addClass("is_show").attr("href", url.href);
516    } else {
517      self.buttonMore.removeClass("is_show");
518    }
519
520    // 検索結果にスクロール
521    if (!self.flagFirst && !self.flagMore) {
522      self.scrolltoElm(self.listBody);
523    }
524    self.flagFirst = false;
525
526    // loading非表示
527    // self.resultWrap.delay(800).removeClass('-nowloading');
528    self.loading.classList.remove("is_show");
529  };
530
531  // 記事詳細生成
532  FilterComp.prototype.articleCreate = function (data) {
533    const self = this;
534    let str = "";
535    let tags = "";
536    let post = '<div class="post">';
537
538    if (data) {
539      // id,date,language,region,newsCategory,newsTag,title,author,article,importArticle
540      let itemId = data.id,
541        itemDate = data.date,
542        itemDatetime = self.dateTimeTransformation(itemDate),
543        itemNewsCategory = data.newsCategory,
544        itemNewsTag = data.newsTag,
545        itemTitle = self.strTextBreak(data.title),
546        itemAuthor = self.strTextBreak(data.author),
547        itemArticle = data.article,
548        itemImportArticle = data.importArticle,
549        strTitle = "";
550      // 言語
551      let itemDateText = self.localTimeTransformation(itemDate);
552
553      // page title
554      if (self.createType === "article") {
555        self.elmTitle.innerHTML = itemTitle + self.elmTitle.textContent;
556      }
557
558      // title
559      if (itemTitle !== undefined) {
560        strTitle = itemTitle
561          .replace(/<br>/g, "")
562          .replace(/<sup>/g, "")
563          .replace(/<\/sup>/g, "");
564      }
565      // author
566      if (itemAuthor === undefined) {
567        itemAuthor = "";
568      }
569
570      // 特殊文字変換
571      const replaceSpecialEntities = (text) => {
572        return text
573          .replace(/&amp;reg;/g, "®")
574          .replace(/&amp;trade;/g, "™")
575          .replace(/&amp;copy;/g, "©")
576          .replace(/&amp;amp;/g, "&")
577          .replace(/&amp;quot;/g, '"')
578          .replace(/&amp;plusmn;/g, "±")
579          .replace(/&amp;lt;/g, "<")
580          .replace(/&amp;gt;/g, ">")
581          .replace(/&amp;le;/g, "≤")
582          .replace(/&amp;ge;/g, "≥")
583          .replace(/&amp;#9312;/g, "①")
584          .replace(/&amp;#9313;/g, "②")
585          .replace(/&amp;#9314;/g, "③")
586          .replace(/&amp;#9315;/g, "④")
587          .replace(/&amp;#9316;/g, "⑤")
588          .replace(/&amp;#9317;/g, "⑥")
589          .replace(/&amp;#9318;/g, "⑦")
590          .replace(/&amp;#9319;/g, "⑧")
591          .replace(/&amp;#9320;/g, "⑨")
592          .replace(/&amp;#9321;/g, "⑩");
593      };
594
595      // article
596      if (itemArticle !== null && itemArticle.length) {
597        for (let i = 0; i < itemArticle.length; i++) {
598          let id = itemArticle[i].fieldId;
599          switch (id) {
600            case "editor":
601              post += replaceSpecialEntities(itemArticle[i].html);
602              break;
603            case "html":
604              post += `<div class="fieldHtml">${itemArticle[i].html}</div>`;
605              break;
606            case "pdf":
607            case "pdfServer":
608              {
609                let text = itemArticle[i].text,
610                  pdfpath = itemArticle[i].path;
611                if (pdfpath === undefined) {
612                  pdfpath = itemArticle[i].file.url;
613                }
614                post += `<p><a href="${pdfpath}" class="_labelPDF" target="_blank">${text}</a></p>`;
615              }
616              break;
617            case "imageText":
618            case "imageTextServer":
619              {
620                let image = itemArticle[i].image,
621                  src = "",
622                  wrap = '<div class="bl_media -reverse">',
623                  alt = itemArticle[i].alt,
624                  text = itemArticle[i].text,
625                  caption = itemArticle[i].caption,
626                  position = itemArticle[i].position;
627                if (caption === undefined) {
628                  caption = "";
629                }
630                if (image === undefined) {
631                  src = itemArticle[i].path;
632                } else {
633                  src = image.url;
634                }
635                //画像位置
636                position ? (wrap = '<div class="bl_media">') : wrap;
637
638                post += `
639                                ${wrap}
640                                    <figure class="mediaImg">
641                                        <img class="lazyload" data-src="${src}" alt="${alt}">
642                                        <figcaption>${caption}</figcaption>
643                                    </figure>
644                                    <div class="mediaBody">${text}</div>
645                                </div>`;
646              }
647              break;
648            case "imageCol1":
649            case "imageCol1Server":
650              {
651                let image = itemArticle[i].path,
652                  alt = itemArticle[i].caption,
653                  caption = itemArticle[i].caption,
654                  src = "";
655                if (image === undefined) {
656                  src = itemArticle[i].media.url;
657                } else {
658                  src = image;
659                }
660                if (caption === undefined) {
661                  caption = "";
662                }
663                post += `
664                                <figure class="bl_imgWrap -slim">
665                                <img class="lazyload" data-src="${src}" alt="${alt}">
666                                <figcaption>${caption}</figcaption>
667                                </figure>`;
668              }
669              break;
670            case "imageCol2":
671            case "imageCol2Server":
672              {
673                let image1 = itemArticle[i].image1,
674                  image2 = itemArticle[i].image2,
675                  src1 = "",
676                  src2 = "",
677                  alt1 = itemArticle[i].alt1,
678                  alt2 = itemArticle[i].alt2,
679                  caption1 = itemArticle[i].caption1,
680                  caption2 = itemArticle[i].caption2;
681                if (alt1 === undefined) {
682                  alt1 = "";
683                }
684                if (alt2 === undefined) {
685                  alt2 = "";
686                }
687                if (caption1 === undefined) {
688                  caption1 = "";
689                }
690                if (caption2 === undefined) {
691                  caption2 = "";
692                }
693                if (image1 === undefined) {
694                  src1 = itemArticle[i].path1;
695                } else {
696                  src1 = image1.url;
697                }
698                if (image2 === undefined) {
699                  src2 = itemArticle[i].path2;
700                } else {
701                  src2 = image2.url;
702                }
703
704                post += `
705                            <div class="bl_cardUnit -col2">
706                                <div class="bl_card">
707                                    <figure class="cardImg">
708                                    <img class="lazyload" data-src="${src1}" alt="${alt1}">
709                                    <figcaption>${caption1}</figcaption>
710                                    </figure>
711                                </div>
712                                <div class="bl_card">
713                                    <figure class="cardImg">
714                                    <img class="lazyload" data-src="${src2}" alt="${alt2}">
715                                    <figcaption>${caption2}</figcaption>
716                                    </figure>
717                                </div>
718                            </div>`;
719              }
720              break;
721            case "linkButton":
722              {
723                let path = itemArticle[i].path,
724                  text = itemArticle[i].text,
725                  target = itemArticle[i].target,
726                  blankclass = "",
727                  targetAttr = "";
728                if (target) {
729                  targetAttr =
730                    ' target="_blank" rel="noopener noreferrer nofollow"';
731                  blankclass = " -blank";
732                }
733                post += `<div class="bl_btnWrap"><a href="${path}" class="el_btn -wide -stand${blankclass}"${targetAttr}>${text}</a></div>`;
734              }
735              break;
736            default:
737          }
738        }
739        post += "</div>";
740      } else {
741        post = "";
742      }
743
744      // importArticle
745      if (itemImportArticle === undefined) {
746        itemImportArticle = "";
747      }
748
749      // SNS
750      const encodeURL = encodeURIComponent(location.href);
751      let snsTitle = encodeURI(`${strTitle} | TORAY`);
752      let fbLink = `http://www.facebook.com/share.php?u=${encodeURL}&t=${snsTitle}`;
753      let twLink = `https://twitter.com/intent/tweet?text=${snsTitle}&url=${encodeURL}`;
754      let likedinLink = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURL}`;
755
756      // metaOGP
757      self.metaOGP(strTitle);
758
759      str += `
760                <div class="bl_headingWrap -news">
761                    <h1 class="bl_headingLv1">${itemTitle}</h1>
762                    <div class="itemRow">
763                        <div class="bl_snsShare">
764                            <a class="fb" href="${fbLink}" target="_blank" rel="nofollow"><img src="/shared/images/icon_fb.svg" alt="Share on facebook" /></a>
765                            <a class="tw" href="${twLink}" target="_blank" rel="nofollow"><img src="/shared/images/icon_x.svg" alt="Share on X" /></a>
766                            <a class="in" href="${likedinLink}" target="_blank" rel="nofollow"><img src="/shared/images/icon_linkedin.svg" alt="Share on Linkedin" /></a>
767                        </div>
768                    </div>
769                </div>
770                <div class="date"><time datetime=${itemDatetime}>${itemDateText}</time></div>
771                <div class="meta">${itemAuthor}</div>
772                ${post}
773                <div class="bl_importArticle">${itemImportArticle}</div>
774            `;
775    } else {
776      str = self.htmlItem("norecord");
777    }
778
779    // HTML書き出し
780    self.targetArticle.innerHTML = str;
781
782    // loading非表示
783    self.targetArticle.classList.add("is_loaded");
784    self.loading.classList.remove("is_show");
785  };
786
787  // HTMLソース
788  FilterComp.prototype.htmlItem = function (val) {
789    const self = this;
790    let item = "";
791
792    switch (val) {
793      case "norecord":
794        let errorMes = "";
795        if (self.htmlLang === "ja") {
796          errorMes = "該当する記事が見つかりません";
797        } else {
798          errorMes = "There is no news.";
799        }
800        item += '<div class="bl_searchNoResult">';
801        item += "<p>" + errorMes + "</p>";
802        item += "</div>";
803        break;
804    }
805    return item;
806  };
807
808  // OGP設定
809  FilterComp.prototype.metaOGP = function (title) {
810    const ogpTitle = `${title} | TORAY`;
811    const ogpURL = window.location.href;
812
813    const head = document.head;
814
815    let metaTitle = document.createElement("meta");
816    metaTitle.setAttribute("property", "og:title");
817    metaTitle.content = ogpTitle;
818    head.appendChild(metaTitle);
819
820    let metaURL = document.createElement("meta");
821    metaURL.setAttribute("property", "og:url");
822    metaURL.content = ogpURL;
823    head.appendChild(metaURL);
824  };
825
826  // 日付表記変換(現地時刻)
827  FilterComp.prototype.localTimeTransformation = function (str) {
828    const self = this;
829    const utcTime = new Date(str);
830    let localtime = "";
831
832    // UTC時刻を現地時刻に変換
833    switch (self.paramLanguage) {
834      case "JA":
835      case "ZH-CN":
836        localtime = new Intl.DateTimeFormat("ja-JP", {
837          year: "numeric",
838          month: "narrow",
839          day: "numeric",
840        }).format(utcTime);
841        break;
842      default:
843        localtime = new Intl.DateTimeFormat("en-US", {
844          dateStyle: "medium",
845        }).format(utcTime);
846        break;
847    }
848
849    return localtime;
850  };
851
852  // 日付表記変換(datetime)
853  FilterComp.prototype.dateTimeTransformation = function (str) {
854    const self = this;
855    const utcTime = new Date(str);
856    let datetime = new Intl.DateTimeFormat("ja", {
857      dateStyle: "medium",
858    }).format(utcTime);
859
860    datetime = datetime.replace(/\//g, "-");
861    return datetime;
862  };
863
864  // 改行コードをタグに変換
865  FilterComp.prototype.strTextBreak = function (str) {
866    if (str !== undefined) {
867      return str.replace(/\r?\n/g, "<br>");
868    }
869  };
870
871  // スクロール
872  FilterComp.prototype.scrolltoElm = function (el) {
873    const self = this;
874    const speed = 300;
875    let headerHeight = 0;
876    let position = 0;
877
878    MainComponent.windowSizeSp() ? (headerHeight = 160) : (headerHeight = 260);
879    position = parseInt(el.offset().top - headerHeight);
880    $("html, body").animate({ scrollTop: position }, speed, "easeOutQuad");
881    return false;
882  };
883
884  // Formアクセシビリティ
885  FilterComp.prototype.formAccessibility = function () {
886    const self = this;
887    self.radioYear.next("label").attr("tabindex", "0");
888  };
889
890  // filter toggle
891  FilterComp.prototype.filterToggle = function () {
892    const self = this;
893    const controls = self.filterBoxToggle.attr("aria-controls");
894    const panel = $("#" + controls);
895    const current = "is_open";
896    self.filterBoxToggle.on("click", function () {
897      if ($(this).hasClass(current)) {
898        panel.slideUp(300);
899        $(this).removeClass(current);
900      } else {
901        panel.slideDown(300);
902        $(this).addClass(current);
903      }
904    });
905  };
906
907  $(function () {
908    window.filtercomp = new FilterComp();
909    window.filtercomp.init();
910  });
911})(jQuery);

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.