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