행위

낙서장

라이언의 꿀팁백과

Ryanyang (토론 | 기여)님의 2022년 6월 28일 (화) 09:47 판 (새 문서: const NeoKIIS_ePoster = (function() { const DEFAULT_EPOSTER = 0; const ePosters = [ {filename: "eposter_fallback.mp4", from: "", to: ""}, {filename: "20220627_20220710.mp4", from: "20220627", to: "20220710"}, {filename: "20220711_20220724.mp4", from: "20220711", to: "20220724"}, ]; getServerDate = async function() { try { const response = await fetch(location.href); const headerDate = await response.headers.get('Date'); return formatServerDate(headerDate); } catch {...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

const NeoKIIS_ePoster = (function() {

const DEFAULT_EPOSTER = 0;

const ePosters = [

{filename: "eposter_fallback.mp4", from: "", to: ""},

{filename: "20220627_20220710.mp4", from: "20220627", to: "20220710"},

{filename: "20220711_20220724.mp4", from: "20220711", to: "20220724"},

];

getServerDate = async function() {

try {

const response = await fetch(location.href);

const headerDate = await response.headers.get('Date');

return formatServerDate(headerDate);

} catch {

return formatServerDate(new Date());

}

};

formatServerDate = function(serverDate) {

d = new Date(serverDate);

year = d.getFullYear();

month = ("0" + (d.getMonth() + 1)).slice(-2);

date = d.getDate();

return year + month + date;

};

getTodayPoster = function(today) {

return ePosters.filter(it => it.from <= today && it.to >= today).shift() || ePosters[DEFAULT_EPOSTER];

};

return {

init: getServerDate,

getTodayPoster: getTodayPoster,

}

}());

const today = await NeoKIIS_ePoster.init();

const ePoster = NeoKIIS_ePoster.getTodayPoster(today);