commit | author | age
|
19351a
|
1 |
/* $Id : lefttime.js 4865 2007-01-31 14:04:10Z paulgao $ */ |
B |
2 |
/* * |
|
3 |
* 给定一个剩余时间(s)动态显示一个剩余时间. |
|
4 |
* 当大于一天时。只显示还剩几天。小于一天时显示剩余多少小时,多少分钟,多少秒。秒数每秒减1 * |
|
5 |
*/ |
|
6 |
// 初始化变量 |
|
7 |
var auctionDate = 0; |
|
8 |
var _GMTEndTime = 0; |
|
9 |
var showTime = "leftTime"; |
|
10 |
var _day = 'day'; |
|
11 |
var _hour = 'hour'; |
|
12 |
var _minute = 'minute'; |
|
13 |
var _second = 'second'; |
|
14 |
var _end = 'end'; |
|
15 |
|
|
16 |
var cur_date = new Date(); |
|
17 |
var startTime = cur_date.getTime(); |
|
18 |
var Temp; |
|
19 |
var timerID = null; |
|
20 |
var timerRunning = false; |
|
21 |
|
|
22 |
function showtime() |
|
23 |
{ |
|
24 |
now = new Date(); |
|
25 |
var ts = parseInt((startTime - now.getTime()) / 1000) + auctionDate; |
|
26 |
var dateLeft = 0; |
|
27 |
var hourLeft = 0; |
|
28 |
var minuteLeft = 0; |
|
29 |
var secondLeft = 0; |
|
30 |
var hourZero = ''; |
|
31 |
var minuteZero = ''; |
|
32 |
var secondZero = ''; |
|
33 |
if (ts < 0) |
|
34 |
{ |
|
35 |
ts = 0; |
|
36 |
CurHour = 0; |
|
37 |
CurMinute = 0; |
|
38 |
CurSecond = 0; |
|
39 |
} |
|
40 |
else |
|
41 |
{ |
|
42 |
dateLeft = parseInt(ts / 86400); |
|
43 |
ts = ts - dateLeft * 86400; |
|
44 |
hourLeft = parseInt(ts / 3600); |
|
45 |
ts = ts - hourLeft * 3600; |
|
46 |
minuteLeft = parseInt(ts / 60); |
|
47 |
secondLeft = ts - minuteLeft * 60; |
|
48 |
} |
|
49 |
|
|
50 |
if (hourLeft < 10) |
|
51 |
{ |
|
52 |
hourZero = '0'; |
|
53 |
} |
|
54 |
if (minuteLeft < 10) |
|
55 |
{ |
|
56 |
minuteZero = '0'; |
|
57 |
} |
|
58 |
if (secondLeft < 10) |
|
59 |
{ |
|
60 |
secondZero = '0'; |
|
61 |
} |
|
62 |
|
|
63 |
if (dateLeft > 0) |
|
64 |
{ |
|
65 |
Temp = dateLeft + _day + hourZero + hourLeft + _hour + minuteZero + minuteLeft + _minute + secondZero + secondLeft + _second; |
|
66 |
} |
|
67 |
else |
|
68 |
{ |
|
69 |
if (hourLeft > 0) |
|
70 |
{ |
|
71 |
Temp = hourLeft + _hour + minuteZero + minuteLeft + _minute + secondZero + secondLeft + _second; |
|
72 |
} |
|
73 |
else |
|
74 |
{ |
|
75 |
if (minuteLeft > 0) |
|
76 |
{ |
|
77 |
Temp = minuteLeft + _minute + secondZero + secondLeft + _second; |
|
78 |
} |
|
79 |
else |
|
80 |
{ |
|
81 |
if (secondLeft > 0) |
|
82 |
{ |
|
83 |
Temp = secondLeft + _second; |
|
84 |
} |
|
85 |
else |
|
86 |
{ |
|
87 |
Temp = ''; |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
if (auctionDate <= 0 || Temp == '') |
|
94 |
{ |
|
95 |
Temp = "<strong>" + _end + "</strong>"; |
|
96 |
stopclock(); |
|
97 |
} |
|
98 |
|
|
99 |
if (document.getElementById(showTime)) |
|
100 |
{ |
|
101 |
document.getElementById(showTime).innerHTML = Temp; |
|
102 |
} |
|
103 |
|
|
104 |
timerID = setTimeout("showtime()", 1000); |
|
105 |
timerRunning = true; |
|
106 |
} |
|
107 |
|
|
108 |
var timerID = null; |
|
109 |
var timerRunning = false; |
|
110 |
function stopclock() |
|
111 |
{ |
|
112 |
if (timerRunning) |
|
113 |
{ |
|
114 |
clearTimeout(timerID); |
|
115 |
} |
|
116 |
timerRunning = false; |
|
117 |
} |
|
118 |
|
|
119 |
function macauclock() |
|
120 |
{ |
|
121 |
stopclock(); |
|
122 |
showtime(); |
|
123 |
} |
|
124 |
|
|
125 |
function onload_leftTime(now_time) |
|
126 |
{ |
|
127 |
|
|
128 |
/* 第一次运行时初始化语言项目 */ |
|
129 |
try |
|
130 |
{ |
|
131 |
|
|
132 |
_GMTEndTime = gmt_end_time; |
|
133 |
// 剩余时间 |
|
134 |
_day = day; |
|
135 |
_hour = hour; |
|
136 |
_minute = minute; |
|
137 |
_second = second; |
|
138 |
_end = end; |
|
139 |
} |
|
140 |
catch (e) |
|
141 |
{ |
|
142 |
} |
|
143 |
if (_GMTEndTime > 0) |
|
144 |
{ |
|
145 |
if (now_time == undefined) |
|
146 |
{ |
|
147 |
var tmp_val = parseInt(_GMTEndTime) - parseInt(cur_date.getTime() / 1000 + cur_date.getTimezoneOffset() * 60); |
|
148 |
} |
|
149 |
else |
|
150 |
{ |
|
151 |
//var tmp_val = parseInt(_GMTEndTime) - parseInt((new Date()).valueOf()/1000); |
|
152 |
var tmp_val = parseInt(_GMTEndTime) - now_time; |
|
153 |
} |
|
154 |
if (tmp_val > 0) |
|
155 |
{ |
|
156 |
auctionDate = tmp_val; |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
macauclock(); |
|
161 |
try |
|
162 |
{ |
|
163 |
initprovcity(); |
|
164 |
} |
|
165 |
catch (e) |
|
166 |
{ |
|
167 |
} |
|
168 |
} |