Pure JavaScript clock

Source: Internet
Author: User

Script description:
Step 1: Add the following code to the <Script language = JavaScript>
<! --
Px = 400; py = 200
Obs = new array (13)
Function OB (){
For (I = 0; I <13; I ++ ){
If (document. All) obs [I] = new array (eval ('ob' + I). style,-100,-100)
Else obs [I] = new array (eval ('document. ob' + I),-100,-100)
}
}
Function Cl (a, B, c ){
If (document. All ){
If (! = 0) B + =-1
Eval ('C' + A + '. style. pixeltop =' + (PY + (c )))
Eval ('C' + A + '. style. pixelleft =' + (PX + (B )))
}
Else {
If (! = 0) B + = 10
Eval ('document. c' + A + '. Top =' + (PY + (c )))
Eval ('document. c' + A + '. Left =' + (PX + (B )))
}
If (document. All) c0.style. pixelleft = 26
}

Function runclock (){
For (I = 0; I <13; I ++ ){
Obs [I] [0]. Left = obs [I] [1] + px
Obs [I] [0]. Top = obs [I] [2] + py
}
}

VaR lastsec
Function timer (){
Time = new date ()
SEC = time. getseconds ()
If (sec! = Lastsec ){

Lastsec = Sec
SEC = math. Pi * SEC/30
Min = math. Pi * time. getminutes ()/30
HR = math. Pi * (time. gethours () * 60) + time. getminutes ()/360
For (I = 1; I <6; I ++ ){
Obs [I] [1] = math. Sin (SEC) * (44-(I-1) * 11)-16;
If (document. layers) obs [I] [1] + = 10;
Obs [I] [2] =-math. Cos (SEC) * (44-(I-1) * 11)-27;
}
For (I = 6; I <10; I ++ ){
Obs [I] [1] = math. Sin (min) * (40-(i-6) * 10)-16;
If (document. layers) obs [I] [1] + = 10;
Obs [I] [2] =-math. Cos (min) * (40-(i-6) * 10)-27;
}
For (I = 10; I <13; I ++ ){
Obs [I] [1] = math. Sin (HR) * (37-(I-10) * 11)-16;
If (document. layers) obs [I] [1] + = 10;
Obs [I] [2] =-math. Cos (HR) * (37-(I-10) * 11)-27;
}
}

}
Function setnum (){

CL (0,-67,-65 );
CL (1, 10,-51 );
CL (2,28,-33 );
CL (3,35,-8 );
CL (4,28, 17 );
CL (5, 10, 35 );
CL (6,-15, 42 );
CL (7,-40, 35 );
CL (8,-58,17 );
CL (9,-65,-8 );
CL (10,-58,-33 );
CL (11,-40,-51 );
CL (12,-16,-56 );

}

File: // -->

</SCRIPT>

Step 2: Add the following code to <body>:
<Div id = "C0" style = "position: absolute; Right: 6; top: 6; Z-index: 2;">
</Div>
<Div id = "C1" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 1 </B> </div>
<Div id = "C2" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 2 </B> </div>
<Div id = "C3" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 3 </B> </div>
<Div id = "C4" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 4 </B> </div>
<Div id = "C5" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 5 </B> </div>
<Div id = "C6" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 6 </B> </div>
<Div id = "C7" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 7 </B> </div>
<Div id = "C8" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 8 </B> </div>
<Div id = "C9" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 9 </B> </div>
<Div id = "C10" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 10 </B> </div>
<Div id = "C11" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 11 </B> </div>
<Div id = "C12" style = "position: absolute; left: 20; top:-20; Z-index: 5; font-size: 11px; "> <B> 12 </B> </div>
<Div id = "ob0" style = "position: absolute; left:-20; top:-20; Z-index: 1"> </div>
<Div id = "ob1" style = "position: absolute; left:-20; top:-20; Z-index: 8 "> <font size =" + 3 "color =" # 0000ff "> <B>. </B> </font> </div>
<Div id = "ob2" style = "position: absolute; left:-20; top:-20; Z-index: 8 "> <font size =" + 3 "color =" # 0000ff "> <B>. </B> </font> </div>
<Div id = "ob3" style = "position: absolute; left:-20; top:-20; Z-index: 8 "> <font size =" + 3 "color =" # 0000ff "> <B>. </B> </font> </div>
<Div id = "ob4" style = "position: absolute; left:-20; top:-20; Z-index: 8 "> <font size =" + 3 "color =" # 0000ff "> <B>. </B> </font> </div>
<Div id = "ob5" style = "position: absolute; left:-20; top:-20; Z-index: 8 "> <font size =" + 3 "color =" # 0000ff "> <B>. </B> </font> </div>
<Div id = "ob6" style = "position: absolute; left:-20; top:-20; Z-index: 7 "> <font size =" + 3 "color =" #00 FFFF "> <B>. </B> </font> </div>
<Div id = "ob7" style = "position: absolute; left:-20; top:-20; Z-index: 7 "> <font size =" + 3 "color =" #00 FFFF "> <B>. </B> </font> </div>
<Div id = "ob8" style = "position: absolute; left:-20; top:-20; Z-index: 7 "> <font size =" + 3 "color =" #00 FFFF "> <B>. </B> </font> </div>
<Div id = "ob9" style = "position: absolute; left:-20; top:-20; Z-index: 7 "> <font size =" + 3 "color =" #00 FFFF "> <B>. </B> </font> </div>
<Div id = "ob10" style = "position: absolute; left:-20; top:-20; Z-index: 6 "> <font size =" + 3 "color =" # f30000 "> <B>. </B> </font> </div>
<Div id = "ob11" style = "position: absolute; left:-20; top:-20; Z-index: 6 "> <font size =" + 3 "color =" # f30000 "> <B>. </B> </font> </div>
<Div id = "ob12" style = "position: absolute; left:-20; top:-20; Z-index: 6 "> <font size =" + 3 "color =" # f30000 "> <B>. </B> </font> </div>

Step 3: change the content in <body>:
<Body bgcolor = "# fef4d9" onLoad = "OB (), setnum (), setinterval ('timer () ', 100); setinterval ('runclock ()', 100) ">

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.