<ptml> <pead> <title>christree</title> </pead> <body > <script type= ' text/jav Ascript ' > var $ = function () {var dom = {}; return {get:function ($) {if (!dom[$]) dom[$] = document.getElementById ($); return dom[$]; }, Apply:function (s,t,d) {if (t && typeof t = = ' object ') $.apply (s,d) if (s && t && typeof s = = ' object ' && typeof t = = ' object ' {for (var i in t) {s[i] = T[i]}/return S; }, Createel:function (Attribute,tag) {if (!tag) tag = "DIV"; var el = document.createelement (tag); $.apply (El,attribute); Return el; }} () var christree = function (params) {$.apply (This.param,params | | {}) this.__construct (); } christree.prototype = {param: {}, __construct:function () {var x = This.param.x,y = this.param.y,xy=[]; for (Var i=0;i<7;i++) {xy = This.createtree (X,Y,I/4) x = xy[0]; y = xy[1]; } this.createroot (x,y,xy[2]); }, Createtree:function (X,y,level) {var lel = level || 0.1 for (i=0;i<110*lel;i+=10) {for (j=i-10;j<2*i;j+=10) {var el = $.createel ({id: "div_" +x+ "_" +i+ "_" +y+ "_" +j} , "span"); El.style.cssText = "Width:5px;height:5px;position:absolute;left:" + (X-I*3/2 + j) + "; Top:" + (Y+i) + "; font-size:0px; Background: #00ff00 "; Document.body.appendChild (EL); if (j = = i-10) this.lightup (EL.ID,X-I*3/2 + j,y+i); } this.lightup (EL.ID,X-I*3/2 + j,y+i); [This.param.x,this.param.y+110*lel,y+i]}, Createroot:function (x,y,l) {for (var i = 0;i<50;i++) {var el = $.createel ({id: "div_" +x+ "_" +i+ "_" +y+ "_" +j}, "span"); El.style.cssText = "Width:5px;height:5px;position:absolute;left: +x+"; Top: "+ (L+i) +"; font-size:0px;background:# FFF "; Document.body.appendChild (EL); }, Createtext:function (text) {var el = $.createel ({id: "text", Innerhtml:text, align: ' center '}) el.style. Csstext = "color: #fff; background: #fff: Margin:4px;padding:3px;top:500px;left:500;font-size:20px;position:absolute "; Document.body.appendChiLD (EL); }, Lightup:function (id,x,y) {var self = this,i=0; settimeout (function () {i++; $.get (id). Style.background = Self.lightcolor[i%self.lightcolor.length]; SetTimeout (arguments.callee,200); },this.param.howtoshine (X,y))}, Lightcolor: [' #ff0000 ', ' #00ff00 ', ' #ffff00 ', ' #ff6600 ', ' #66ff00 ']} new Christree ({ x:400, Y:50, Howtoshine:function (x,y) {return 100+x-y}}) New Christree ({x:600, y:50, Howtoshine:func tion (x,y) {return math.sqrt (x*x-2*x*y+y*y) *10}}) var ct = new Christree ({x:800, y:50, Howtoshine:function (x,y) {return x+y}}); Ct.createtext (' Merry chrismas!:)))) "); </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]