var timerRunning = [];
var timerID = [];
var auctionDate = [];
var startTime = [];
var showTimeId = [];
function showtime() {
var _day = ‘天’;
var _hour = ‘小时’;
var _minute = ‘分’;
var _second = ‘秒’;
var _end = ‘结束’;
var dateLeft = 0;
var hourLeft = 0;
var minuteLeft = 0;
var secondLeft = 0;
var hourZero = ”;
var minuteZero = ”;
var secondZero = ”;
var c = auctionDate.length;
for ( var i = 0, j = auctionDate.length; i < j; i++) {
if (auctionDate[i] == null) {
c–;
continue;
}
now = new Date();
var ts = parseInt((startTime[i] – now.getTime()) / 1000) + auctionDate[i];
if (ts < 0) {
ts = 0;
CurHour = 0;
CurMinute = 0;
CurSecond = 0;
} else {
dateLeft = parseInt(ts / 86400);
ts = ts – dateLeft * 86400;
hourLeft = parseInt(ts / 3600);
ts = ts – hourLeft * 3600;
minuteLeft = parseInt(ts / 60);
secondLeft = ts – minuteLeft * 60;
}
if (hourLeft < 10) {
hourZero = ’0′;
}
if (minuteLeft < 10) {
minuteZero = ’0′;
}
if (secondLeft < 10) { secondZero = ’0′; } if (dateLeft > 0) {
Temp = dateLeft + _day + hourZero + hourLeft + _hour + minuteZero + minuteLeft + _minute + secondZero + secondLeft + _second;
} else {
if (hourLeft > 0) {
Temp = hourLeft + _hour + minuteZero + minuteLeft + _minute + secondZero + secondLeft + _second;
} else {
if (minuteLeft > 0) {
Temp = minuteLeft + _minute + secondZero + secondLeft + _second;
} else {
if (secondLeft > 0) {
Temp = secondLeft + _second;
} else {
Temp = ”;
}
}
}
}
if (ts Temp = "<strong>" + _end + "</strong>";
auctionDate[i] = null;
}
if (document.getElementById(showTimeId[i])) {
document.getElementById(showTimeId[i]).innerHTML = Temp;
}
timerRunning[i] = true;
}
if (c > 0) {
timerID = setTimeout("showtime()", 1000);
}
}
function stopclock(timerRunning, timerID) {
if (timerRunning) {
clearTimeout(timerID);
}
timerRunning = false;
}
function onload_leftTime(now_time, gmt_end_time, showTime) {
var auctionDate_tmp = 0;
var _GMTEndTime = 0;
var cur_date = new Date();
_GMTEndTime = gmt_end_time;
if (_GMTEndTime > 0) {
if (now_time == undefined) {
var tmp_val = parseInt(_GMTEndTime)
- parseInt(cur_date.getTime() / 1000
+ cur_date.getTimezoneOffset() * 60);
} else {
var tmp_val = parseInt(_GMTEndTime) – now_time;
}
if (tmp_val > 0) {
auctionDate_tmp = tmp_val;
}
}
timerRunning[timerRunning.length] = false;
timerID[timerID.length] = null;
auctionDate[auctionDate.length] = auctionDate_tmp;
startTime[startTime.length] = cur_date.getTime();
showTimeId[showTimeId.length] = showTime;
showtime();
}
|