function CountdownTimer(elm, tl, mes){
this.initialize.apply(this, arguments);
}
CountdownTimer.prototype={
initialize: function (elm, tl, mes){
this.elem=document.getElementById(elm);
this.tl=tl;
this.mes=mes;
},
countDown: function (){
var timer='';
var today=new Date();
var day=Math.floor((this.tl - today) / (24 * 60 * 60 * 1000));
var hour=Math.floor(((this.tl - today) % (24 * 60 * 60 * 1000)) /
(60 * 60 * 1000)
);
var min=Math.floor(((this.tl - today) % (24 * 60 * 60 * 1000)) /
(60 * 1000)
) % 60;
var sec=Math.floor(((this.tl - today) % (24 * 60 * 60 * 1000)) /
1000
) % 60 % 60;
var me=this;
if((this.tl - today) > 0){
if(day){
timer +=
'<span class="cdt_num">' +
day +
'</span><small>日</small>';
}
if(hour){
timer +=
'<span class="cdt_num">' +
hour +
'</span><small>時間</small>';
}
timer +=
'<span class="cdt_num">' +
this.addZero(min) +
'</span><small>分</small>' +
'<span class="cdt_num">' +
this.addZero(sec) +
'</span><small>秒</small>';
this.elem.innerHTML=timer;
setTimeout(function (){
me.countDown();
}, 10);
}else{
document.getElementById('cdt_txt').innerHTML =
'2026年7月3日（金）';
this.elem.innerHTML=this.mes;
return;
}},
addZero: function (num){
return ('0' + num).slice(-2);
}};
function CDT(){
var myD=Date.now();
var start=new Date('2024-06-26T17:30+09:00');
var myS=start.getTime();
var end=new Date('2026-06-26T17:30+09:00');
var myE=end.getTime();
var text;
var tl;
if(myS <=myD&&myE >=myD){
text='OPENまで';
tl=end;
}else if(myS > myD){
text='OPENまで';
tl=start;
}else{
text='2026年7月3日（金）';
}
var timer=new CountdownTimer(
'cdt_date',
tl,
'OPENいたしました'
);
timer.countDown();
var target=document.getElementById('cdt_txt');
target.innerHTML=text;
}
window.onload=function (){
CDT();
};