PDA

View Full Version : Làm đồng hồ chạy theo chuột nè


anhyeuemnhieudl
31-10-2003, 19:43
Bạn chỉ cần copy code sau vào sau thể <body> trên web của bạn là được ngay
<script LANGUAGE="JavaScript1.2">

colors = new Array('330099','00ff00','ff00ff'); //Clock face colors.
sCol = 'ff00ff'; //seconds colour.
mCol = '00ff00'; //minutes colour.
hCol = 'red'; //hours colour.
//Alter nothing below!
H = '***';
H = H.split('');
H = H.reverse();
M = '****';
M = M.split('');
M = M.reverse();
S = '*****';
S = S.split('');
S = S.reverse();
dots = 12;
var Ypos = 0,Xpos = 0,Ybase = 0,Xbase = 0;
var ay = 0, ax = 0, Ay = 0, Ax = 0, by = 0, bx = 0, By = 0, Bx = 0, cy
= 0, cx = 0, Cy = 0, Cx = 0, dy = 0, dx = 0, Dy = 0, Dx = 0;
count = 0;
count_a = 0;
move = 1;
ie4=document.all
ns = (document.layers)?1:0;

viz = (document.layers)?'hide':'hidden';
if (ns) {
for (i = 0; i < dots; i++)
document.write('<layer name=nface'+i+' top=0 left=0 bgcolor=#000099 clip="0,0,3,3"></layer>');
for (i = 0; i < S.length; i++)
document.write('<layer name=nx'+i+' top=0 left=0 width=36 height=36><font face=Verdana size=2 color='+sCol+'><p align="center">'+S[i]+'</p></font></layer>');
for (i = 0; i < M.length; i++)
document.write('<layer name=ny'+i+' top=0 left=0 width=36 height=36><font face=Verdana size=2 color='+mCol+'><p align="center">'+M[i]+'</p></font></layer>');
for (i = 0; i < H.length; i++)
document.write('<layer name=nz'+i+' top=0 left=0 width=36 height=36><font face=Verdana size=2 color='+hCol+'><p align="center">'+H[i]+'</p></font></layer>');
}
else if (ie4){
document.write('<div id="W" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < dots; i++) {
document.write('<div id="face" style="position:absolute;top:0px;left:0px;width:3px;heigh t:3px;font-size:3px;background:#000099"></div>');
}
document.write('</div></div>');
document.write('<div id="X" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < S.length; i++) {
document.write('<div id="x" style="position:absolute;width:36px;height:36px;font-family:Verdana;font-size:12px;color:'+sCol+';text-align:center;padding-top:10px">'+S[i]+'</div>');
}
document.write('</div></div>')
document.write('<div id="Y" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < M.length; i++) {
document.write('<div id="y" style="position:absolute;width:36px;height:36px;font-family:Verdana;font-size:12px;color:'+mCol+';text-align:center;padding-top:10px">'+M[i]+'</div>');
}
document.write('</div></div>')
document.write('<div id="Z" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < H.length; i++) {
document.write('<div id="z" style="position:absolute;width:36px;height:36px;font-family:Verdana;font-size:12px;color:'+hCol+';text-align:center;padding-top:10px">'+H[i]+'</div>');
}
document.write('</div></div>');
}
if (ns) {
window.captureEvents(Event.MOUSEMOVE);
function nsMouse(evnt) {
Ypos = evnt.pageY + 100;
Xpos = evnt.pageX + 100;
}
window.onMouseMove = nsMouse;
}
else if (ie4){
function ieMouse() {
Ypos = event.y + 100;
Xpos = event.x + 100;
}
document.onmousemove = ieMouse;
}
function clock() {
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs / 30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins / 30;
hr = time.getHours();
hrs = -1.575 + Math.PI * hr / 6 + Math.PI * parseInt(time.getMinutes())
/ 360;
Ybase = 15;
Xbase = 15;

if (ns) {
document.layers["nx"+0].visibility = viz;
document.layers["ny"+0].visibility = viz;
document.layers["nz"+0].visibility = viz;
for (i = 0; i < S.length; i++) {
document.layers["nx"+i].top = ay - 12 + (i * Ybase) * Math.sin(sec);
document.layers["nx"+i].left = ax - 12 + (i * Xbase) * Math.cos(sec);
}
for (i = 0; i < M.length; i++) {
document.layers["ny"+i].top = by - 12 + (i * Ybase) * Math.sin(min);
document.layers["ny"+i].left = bx - 12 + (i * Xbase) * Math.cos(min);
}
for (i = 0; i < H.length; i++) {
document.layers["nz"+i].top = cy - 12 + (i * Ybase) * Math.sin(hrs);
document.layers["nz"+i].left = cx - 12 + (i * Xbase) * Math.cos(hrs);
}
for (i = 0; i < dots; ++i) {
document.layers["nface"+i].top = dy - 2 + (70 *
Math.sin(-0.49+dots+i/1.9));
document.layers["nface"+i].left = dx + 4 + (70 *
Math.cos(-0.49+dots+i/1.9));
}
}
else if (ie4) {
var scrll = document.body.scrollTop;
W.style.pixelTop = scrll;
X.style.pixelTop = scrll;
Y.style.pixelTop = scrll;
Z.style.pixelTop = scrll;
x[0].style.visibility=viz;
y[0].style.visibility = viz;
z[0].style.visibility = viz;
for (i = 0; i < S.length; i++) {
x[i].style.pixelTop = ay - 12 + (i * Ybase) * Math.sin(sec);
x[i].style.pixelLeft = ax - 12 + (i * Xbase) * Math.cos(sec);
}
for (i = 0; i < M.length; i++) {
y[i].style.pixelTop = by - 12 + (i * Ybase) * Math.sin(min);
y[i].style.pixelLeft = bx - 12 + (i * Xbase) * Math.cos(min);
}
for (i = 0; i < H.length; i++) {
z[i].style.pixelTop = cy - 12 + (i * Ybase) * Math.sin(hrs);
z[i].style.pixelLeft = cx - 12 + (i * Xbase) * Math.cos(hrs);
}
for (i = 0; i < dots; ++i) {
face[i].style.pixelTop = dy + 6 + (70 * Math.sin(-0.49 + dots + i /
1.9));
face[i].style.pixelLeft = dx + 4 + (70 * Math.cos(-0.49 + dots + i /
1.9));
}
}
}
function MouseFollow() {
ay = Math.round(Ay += ((Ypos) - Ay) * 4 / 15);
ax = Math.round(Ax += ((Xpos) - Ax) * 4 / 15);
by = Math.round(By += (ay - By) * 4 / 15);
bx = Math.round(Bx += (ax - Bx) * 4 / 15);
cy = Math.round(Cy += (by - Cy) * 4 / 15);
cx = Math.round(Cx += (bx - Cx) * 4 / 15);
dy = Math.round(Dy += (cy - Dy) * 4 / 15);
dx = Math.round(Dx += (cx - Dx) * 4 / 15);
clock();
setTimeout('MouseFollow()',10);
}

function StartAll() {
MouseFollow();
}
if (document.layers || document.all) window.onload = StartAll;
// End -->
</script>

yeu_lam
31-10-2003, 20:34
Ông ơi ông viết cài gì mà tôi nhìn chẳng hiểu cái mẹ gì vậy...Lại còn dài nữa chứ,,,..

LSB-KieuPhong
01-11-2003, 14:11
su+ huynh anhyeuemnhieudl có thể giải thic hs rõ ràng hơn cho tại hạ hiểu không vậy
nếu cần liên lạc với tại hạ qua ni ck yahoo trieu doanconganh
thanks

LSB_conan
01-11-2003, 14:47
thể body là cái gì vậy gải thích đi.
thể body là cái gì vậy gải thích đi
thể body là cái gì vậy gải thích đi
thể body là cái gì vậy gải thích đi
thể body là cái gì vậy gải thích đi

anh hung cao nguyen
01-11-2003, 18:24
anhyeuemnhieudl viết cái gì vậy mà mọi người chẳng hiểu gì vậy.Dài quá đó.Tôi đọc cứ ù hết cả đầu lên.Khó hiểu quá......

anhyeuemnhieudl
01-11-2003, 18:50
cái này là javascrip dùng để làm web nếu ai biết thì đọc là hiểu chứ giờ khó giải thích quá

gianghohiepkhach
02-11-2003, 07:05
nếu các huynh co' trang web các nhân thì mới hiểu được chứ nếu ko thì đọc nhũng thứ này cũng như người mù thôi

Kelangquen
02-11-2003, 07:21
Cái này dành cho bác nào viết trang Web. Các bác cứ copy vào doạn Code của trang web, để chỗ nào cũng được. Kế quả là khi các bác di chuyển chuột thì chiếc đồng hồ này cũng uốn éo chạy theo, đẹp lắm,, các bác cứ thử thì biết ngay muh. Lần đầu thấy chiếc đồng hồ này thực sự ngỡ ngàng đấy!

anhyeuemnhieudl
02-11-2003, 17:36
Cảm ơn Kelangquen và gianghohiepkhach nha chắc hai người cũng có web biết về làm web phải không nếu biết thì có kinh nghiệm gì bày với nha

Kelangquen
08-11-2003, 12:33
Uh thì trang web của tớ cũng đang dùng cái này mà, nhưng lúc load thì hơi chậm. Chắc phải ADLS mới nhanh dc.