' + json[i].title + '
' + json[i].date + '' + json[i].category + '';
}
insertNews3.insertAdjacentHTML('beforeend', insertEl);
} else {
insertNews3.remove();
}
}
};
xhr.send();
}
/**
* ã¢ã¹ãªã¼ããµãã¼ããã¥ã¼ã¹ç¨
*/
const insertNews4 = document.getElementById('js-insert-news-4');
if (insertNews4) {
const timestamp = Math.floor(Date.now() / 1000);
const category = insertNews4.dataset.category;
const jsonPath = '/assets/news-json/' + category + '.json?' + timestamp;
const xhr = new XMLHttpRequest();
xhr.open('GET', jsonPath);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
const json = JSON.parse(xhr.responseText);
if (json.length != 0) {
let l = json.length;
if (l > 4) {
l = 4;
}
for (i = 0; i < l; i++) {
const ccardlist8__item = makeElmForAthletesSupport('li', ["c-card-list-8__item"], insertNews4, "", "", "", "", "", "", "");
let newsUrl;
if (json[i].externalurl) {
newsUrl = json[i].externalurl;
} else {
newsUrl = window.location.origin + json[i].url;
}
let target = "";
if (json[i].targetblank == "1") {
target = "_blank";
}
const ccardlist8__itemlink = makeElmForAthletesSupport('a', ["c-card-list-8__item-link"], ccardlist8__item, "", newsUrl, "", "", "", "", target);
const ccardlist8__img = makeElmForAthletesSupport('figure', ["c-card-list-8__img", "hover-zoom-img"], ccardlist8__itemlink, "", "", "", "", "", "", "");
let thumbnailimageClassArr = [];
if (json[i].newsthumbnailfit == "1") {
thumbnailimageClassArr.push("object-fit-contain");
}
if (json[i].thumbnailposition == "ä¸å¯ã") {
thumbnailimageClassArr.push("object-position-bottom");
} else if (json[i].thumbnailposition == "ä¸å¯ã") {
thumbnailimageClassArr.push("object-position-top");
}
let thumbnailimage = window.location.origin + "/assets/img/common/img_default_h.png";
if (json[i].thumb) {
thumbnailimage = json[i].thumb;
}
makeElmForAthletesSupport('img', thumbnailimageClassArr, ccardlist8__img, "", "", thumbnailimage, "", json[i].title, "async", "");
const ccardlist8__txtwrap = makeElmForAthletesSupport('div', ["c-card-list-8__txt-wrap"], ccardlist8__itemlink, "", "", "", "", "", "", "");
makeElmForAthletesSupport('p', ["c-card-list-8__ttl", "hover-underline-2"], ccardlist8__txtwrap, "", "", "", json[i].title, "", "", "");
const ccardlist8__sup = makeElmForAthletesSupport('div', ["c-card-list-8__sup"], ccardlist8__txtwrap, "", "", "", "", "", "", "");
makeElmForAthletesSupport('span', ["c-card-list-8__date"], ccardlist8__sup, "", "", "", json[i].publishedon, "", "", "");
makeElmForAthletesSupport('span', ["c-card-list-8__category"], ccardlist8__sup, "", "", "", json[i].category.join(','), "", "", "");
}
}
}
};
xhr.send();
}
/**
* ã¢ã¹ãªã¼ããµãã¼ããã¥ã¼ã¹ç¨htmlã®çæ
*/
function makeElmForAthletesSupport(tag, classAttributeArr, parent, style, href, src, text, alt, decoding, target) {
const elm = document.createElement(tag);
if (classAttributeArr.length > 0) {
for (let i = 0; i < classAttributeArr.length; i++) {
elm.classList.add(classAttributeArr[i]);
}
}
if (style != "") {
elm.style = style;
}
if (href != "") {
elm.href = href;
}
if (src != "") {
elm.src = src;
}
if (text != "") {
elm.textContent = text;
}
if (alt != "") {
elm.alt = alt;
}
if (decoding != "") {
elm.decoding = decoding;
}
if (target != "") {
elm.target = target;
}
parent.appendChild(elm);
return elm;
}
/**
* å¦ã¶ã»ä½é¨ããã¤ãã³ãç¨
*/
const insertEvent = document.getElementById('js-insert-event');
if (insertEvent) {
const timestamp = Math.floor(Date.now() / 1000);
const category = insertEvent.dataset.category;
const jsonPath = '/assets/event-json/' + category + '.json?' + timestamp;
const xhr = new XMLHttpRequest();
xhr.open('GET', jsonPath);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
const json = JSON.parse(xhr.responseText);
if (json.length != 0) {
let l = json.length;
if (l > 4) {
l = 4;
}
for (i = 0; i < l; i++) {
let url;
if (json[i].external_url) {
url = json[i].external_url;
} else {
url = json[i].url;
}
let targetblank;
if (json[i].istargetblank == '1') {
targetblank = target="_blank"
} else {
targetblank = "";
}
const ccardlist5__item = makeElmForOlympismExperience("a", ["c-card-list-5__item"], insertEvent, "", url, "", "", "", "", targetblank, "", "", "");
const ccardlist5__img = makeElmForOlympismExperience("figure", ["c-card-list-5__img", "hover-zoom-img", "aspect-ratio-16-9"], ccardlist5__item, "", "", "", "", "", "", "");
makeElmForOlympismExperience("img", "", ccardlist5__img, "", "", json[i].image, "", json[i].name, "async", "", "lazy", "16", "9");
makeElmForOlympismExperience("p", ["c-card-list-5__ttl", "hover-underline-2"], ccardlist5__item, "", "", "", json[i].name, "", "", "", "", "", "");
const ccardlist5__txtsup = makeElmForOlympismExperience("div", ["c-card-list-5__txt-sup"], ccardlist5__item, "", "", "", "", "", "", "", "", "", "");
ccardlist5__txtsup.innerHTML = json[i].shortdescription;
makeElmForOlympismExperience("p", ["c-card-list-5__txt-status", "is-end"], ccardlist5__item, "", "", "", json[i].phase, "", "", "", "", "", "");
}
}
}
};
xhr.send();
}
/**
* å¦ã¶ã»ä½é¨ããç¨
*/
function makeElmForOlympismExperience(tag, classAttributeArr, parent, style, href, src, text, alt, decoding, target, loading, width, height) {
const elm = document.createElement(tag);
if (classAttributeArr.length > 0) {
for (let i = 0; i < classAttributeArr.length; i++) {
elm.classList.add(classAttributeArr[i]);
}
}
if (style != "") {
elm.style = style;
}
if (href != "") {
elm.href = href;
}
if (src != "") {
elm.src = src;
}
if (text != "") {
elm.textContent = text;
}
if (alt != "") {
elm.alt = alt;
}
if (decoding != "") {
elm.decoding = decoding;
}
if (target != "") {
elm.target = target;
}
if (target != "") {
elm.target = target;
}
if (loading != "") {
elm.loading = loading;
}
if (width != "") {
elm.width = width;
}
if (height != "") {
elm.height = height;
}
parent.appendChild(elm);
return elm;
}