128 lines
3.0 KiB
JavaScript
128 lines
3.0 KiB
JavaScript
// JavaScript Document
|
|
|
|
function jfCountDown(d, h, m, s) //constructor
|
|
{
|
|
this.days = d;
|
|
this.days_1 = Math.floor(this.days/10);
|
|
this.days_2 = this.days%10;
|
|
|
|
this.hours = h;
|
|
this.hours_1 = Math.floor(this.hours/10);
|
|
this.hours_2 = this.hours%10;
|
|
|
|
this.minutes = m;
|
|
this.minutes_1 = Math.floor(this.minutes/10);
|
|
this.minutes_2 = this.minutes%10;
|
|
|
|
this.seconds = s;
|
|
this.seconds_1 = Math.floor(this.seconds/10);
|
|
this.seconds_2 = this.seconds%10;
|
|
|
|
this.id_days_1 = $('#d-1 span');
|
|
this.id_days_2 = $('#d-2 span');
|
|
|
|
this.id_hours_1 = $('#h-1 span');
|
|
this.id_hours_2 = $('#h-2 span');
|
|
|
|
this.id_minutes_1 = $('#m-1 span');
|
|
this.id_minutes_2 = $('#m-2 span');
|
|
|
|
this.id_seconds_1 = $('#s-1 span');
|
|
this.id_seconds_2 = $('#s-2 span');
|
|
|
|
this.update();
|
|
|
|
var self = this;
|
|
|
|
this.id_interval = setInterval(function() {self.run();}, 1000);
|
|
}
|
|
|
|
jfCountDown.prototype.update = function()
|
|
{
|
|
this.id_days_1.removeClass().addClass('n-' + this.days_1);
|
|
this.id_days_2.removeClass().addClass('n-' + this.days_2);
|
|
|
|
this.id_hours_1.removeClass().addClass('n-' + this.hours_1);
|
|
this.id_hours_2.removeClass().addClass('n-' + this.hours_2);
|
|
|
|
this.id_minutes_1.removeClass().addClass('n-' + this.minutes_1);
|
|
this.id_minutes_2.removeClass().addClass('n-' + this.minutes_2);
|
|
|
|
this.id_seconds_1.removeClass().addClass('n-' + this.seconds_1);
|
|
this.id_seconds_2.removeClass().addClass('n-' + this.seconds_2);
|
|
}
|
|
|
|
jfCountDown.prototype.run = function()
|
|
{
|
|
if(this.seconds == 0)
|
|
{
|
|
if(this.minutes == 0)
|
|
{
|
|
if(this.hours == 0)
|
|
{
|
|
if(this.days == 0)
|
|
{
|
|
clearInterval(this.id_interval);
|
|
window.alert('Open!!!');
|
|
}
|
|
else
|
|
{
|
|
this.days -= 1;
|
|
this.hours = 23;
|
|
this.minutes = 59;
|
|
this.seconds = 59;
|
|
|
|
this.days_1 = Math.floor(this.days/10);
|
|
this.days_2 = this.days%10;
|
|
|
|
this.hours_1 = Math.floor(this.hours/10);
|
|
this.hours_2 = this.hours%10;
|
|
|
|
this.minutes_1 = Math.floor(this.minutes/10);
|
|
this.minutes_2 = this.minutes%10;
|
|
|
|
this.seconds_1 = Math.floor(this.seconds/10);
|
|
this.seconds_2 = this.seconds%10;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.hours -= 1;
|
|
this.minutes = 59;
|
|
this.seconds = 59;
|
|
|
|
this.days_1 = Math.floor(this.days/10);
|
|
this.days_2 = this.days%10;
|
|
|
|
this.hours_1 = Math.floor(this.hours/10);
|
|
this.hours_2 = this.hours%10;
|
|
|
|
this.minutes_1 = Math.floor(this.minutes/10);
|
|
this.minutes_2 = this.minutes%10;
|
|
|
|
this.seconds_1 = Math.floor(this.seconds/10);
|
|
this.seconds_2 = this.seconds%10;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.minutes -= 1;
|
|
this.seconds = 59;
|
|
|
|
this.minutes_1 = Math.floor(this.minutes/10);
|
|
this.minutes_2 = this.minutes%10;
|
|
|
|
this.seconds_1 = Math.floor(this.seconds/10);
|
|
this.seconds_2 = this.seconds%10;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.seconds -= 1;
|
|
|
|
this.seconds_1 = Math.floor(this.seconds/10);
|
|
this.seconds_2 = this.seconds%10;
|
|
}
|
|
|
|
this.update();
|
|
} |