Home Web Front-end JS Tutorial 纯js代码制作的网页时钟

纯js代码制作的网页时钟

Jun 01, 2016 am 09:54 AM
javascript clock

<code class="language-html"> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<meta content="MSHTML 6.00.6000.16414" name="GENERATOR"> 
 
<div style="LEFT: 155px; WIDTH: 400px; ZOOM: 1; POSITION: absolute; TOP: 133px; HEIGHT: 300px"> 
<div id="bg" style="LEFT: -22px; WIDTH: 150px; ZOOM: 1.5; POSITION: absolute; TOP: -57px; HEIGHT: 150px">
<img  src="/static/imghw/default1.png" data-src="http://files.jb51.net/upload/novelty.gif" class="lazy"   style="max-width:90%" alt="纯js代码制作的网页时钟" >  
</div> 
<div id="h" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px">
<img  src="/static/imghw/default1.png" data-src="http://files.jb51.net/upload/novelty_h.gif" class="lazy"   style="max-width:90%" alt="纯js代码制作的网页时钟" >  
</div> 
<div id="m" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px">
<img  src="/static/imghw/default1.png" data-src="http://files.jb51.net/upload/novelty_m.gif" class="lazy"   style="max-width:90%" alt="纯js代码制作的网页时钟" >  
</div> 
<div id="s" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px">
<img  src="/static/imghw/default1.png" data-src="http://files.jb51.net/upload/novelty_s.gif" class="lazy"   style="max-width:90%" alt="纯js代码制作的网页时钟" >  
</div> 
<div id="dot" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px">
<img  src="/static/imghw/default1.png" data-src="http://files.jb51.net/upload/novelty_dot.gif" class="lazy"   style="max-width:90%" alt="纯js代码制作的网页时钟" >  
</div> 
<div> 
<script> 
//oObj input requires that a matrix filter be applied.  
//deg input defines the requested angle of rotation. 
var deg2radians = Math.PI * 2 / 360; 
function MatrixFilter(obj) 
{     
    if(!obj.filters)return; 
    //alert(obj.filters.item(0)); 
    var Matrix; 
    for(p in obj.filters) 
    {        
        if(p=="DXImageTransform.Microsoft.Matrix")Matrix=obj.filters["DXImageTransform.Microsoft.Matrix"];   
    } 
    if(!Matrix) 
    { 
        obj.style.filter+="progid:DXImageTransform.Microsoft.Matrix()"; 
    } 
    Matrix=obj.filters["DXImageTransform.Microsoft.Matrix"]; 
    this.equal=function(Matrix2D_x) 
    { 
        if(Matrix2D_x.M11)Matrix.M11 = Matrix2D_x.M11; 
        if(Matrix2D_x.M12)Matrix.M12 = Matrix2D_x.M12; 
        if(Matrix2D_x.M21)Matrix.M21 = Matrix2D_x.M21; 
        if(Matrix2D_x.M22)Matrix.M22 = Matrix2D_x.M22; 
    } 
     
    if(arguments[1])this.equal(arguments[1]); 
     
    this.Rotate=function(deg) 
    { 
        rad = deg * deg2radians; 
        costheta = Math.cos(rad); 
        sintheta = Math.sin(rad); 
        var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); 
        this.equal(Matrix2D.Mul(Matrix,d)); 
    } 
    this.RotateTo=function(deg) 
    { 
        rad = deg * deg2radians; 
        costheta = Math.cos(rad); 
        sintheta = Math.sin(rad); 
        var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); 
        this.equal(d); 
    } 
    this.RotateAt=function(deg,sx,sy) 
    { 
        rad = deg * deg2radians; 
        costheta = Math.cos(rad); 
        sintheta = Math.sin(rad); 
        var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); 
        var x=sx-Matrix.Dx; 
        var y=sy-Matrix.Dy; 
        this.MoveTo(x*costheta+y*sintheta-x,-x*sintheta+y*costheta-y); 
        this.equal(Matrix2D.Mul(Matrix,d));        
    } 
    this.RotateToAt=function(deg,sx,sy) 
    { 
        rad = deg * deg2radians; 
        costheta = Math.cos(rad); 
        sintheta = Math.sin(rad); 
        var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); 
        var x=sx; 
        var y=sy; 
        this.MoveTo(x-(x*costheta-y*sintheta),-(x*sintheta+y*costheta-x)); 
        this.equal(d); 
    } 

    this.MoveTo=function(sx,sy) 
    { 
        Matrix.Dx=sx; 
        Matrix.Dy=sy; 
    } 
    this.toMatrix2D=function() 
    { 
        return new Matrix2D(Matrix.M11,Matrix.M12,Matrix.M21,Matrix.M22); 
    } 
    this.ZoomBy=function(sx,sy) 
    { 
        var d=new Matrix2D(sx,0,0,sy); 
        this.equal(Matrix2D.Mul(Matrix,d)); 
    } 
    this.toString=function() 
    { 
        return ""+Matrix.M11+" "+Matrix.M12+"\n"+Matrix.M21+" "+Matrix.M22+"\n" 
    } 
    //Matrix.SizingMethod='clip to original'; 
    //this.fnSetRotation(30); 
    //alert(Matrix.M11); 
    //alert(obj.filters["DXImageTransform.Microsoft.Matrix"]); 
} 
function Matrix2D() 
{ 
    this.M11 = arguments[0]||1; 
    this.M12 = arguments[1]||0; 
    this.M21 = arguments[2]||0; 
    this.M22 = arguments[3]||1; 
    this.Mul_Matrix2D=function(Matrix2D_b) 
    { 
        var r=new Matrix2D(); 
        r=Matrix2D.Mul(this,Matrix2D_b);         
        return r;        
    } 
    this.toString=function() 
    { 
        return ""+this.M11+" "+this.M12+"\n"+this.M21+" "+this.M22+"\n" 
    } 
} 
Matrix2D.Mul=function(Matrix2D_a,Matrix2D_b) 
{ 
    var r=new Matrix2D(); 
    r.M11=Matrix2D_a.M11*Matrix2D_b.M11+Matrix2D_a.M12*Matrix2D_b.M21; 
    r.M12=Matrix2D_a.M11*Matrix2D_b.M12+Matrix2D_a.M12*Matrix2D_b.M22; 
    r.M21=Matrix2D_a.M21*Matrix2D_b.M11+Matrix2D_a.M22*Matrix2D_b.M21; 
    r.M22=Matrix2D_a.M21*Matrix2D_b.M12+Matrix2D_a.M22*Matrix2D_b.M22; 
    return r;      
} 


var ms=new MatrixFilter(s); 
var mm=new MatrixFilter(m); 
var mh=new MatrixFilter(h); 
var i=1; 
setInterval("ms.RotateToAt((new Date()).getSeconds()*6+6,69,69)",500); 
setInterval("mm.RotateToAt((new Date()).getMinutes()*6+6,69,69)",500); 
setInterval("mh.RotateToAt(((new Date()).getHours()+(new Date()).getMinutes()/60)*30,69,69)",500); 
//mf.MoveTo(30,70); 
//mf.ZoomBy(1.5,1.5); 
//mf.ZoomBy(1.5,1.5); 
//alert(mf.toMatrix2D()); 

//alert(Matrix2D.Mul(m2d1,m2d2)); 
//fnSetRotation(oDiv.filters.item(0),30); 
</script> 
</div>
</div> 
</code>
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Clock app missing in iPhone: How to fix it Clock app missing in iPhone: How to fix it May 03, 2024 pm 09:19 PM

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

JavaScript and WebSocket: Building an efficient real-time weather forecasting system JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

How to use insertBefore in javascript How to use insertBefore in javascript Nov 24, 2023 am 11:56 AM

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

See all articles