1var ns4 = (navigator.appName.indexOf("Netscape") != -1 && !document.getElementById); 2 3if(!window.JSFX) 4 JSFX=new Object(); 5 6JSFX.layerNo=0; 7/**********************************************************************************/ 8JSFX.createLayer = function(htmlStr, parent) 9{ 10 var elem = null; 11 12 if(document.layers) 13 { 14 var xName="xLayer" + JSFX.layerNo++; 15 if(parent == null) 16 elem=new Layer(2000); 17 else 18 elem=new Layer(2000, parent.elem); 19 20 elem.document.open(); 21 elem.document.write(htmlStr); 22 elem.document.close(); 23 elem.moveTo(0,0); 24 elem.innerHTML = htmlStr; 25 } 26 else 27 if(document.all) 28 { 29 if(parent == null) 30 parent=document.body; 31 else 32 parent=parent.elem; 33 34 var xName = "xLayer" + JSFX.layerNo++; 35 var txt = '<DIV ID="' + xName + '"' 36 + ' STYLE="position:absolute;left:0;top:0;visibility:hidden">' 37 + htmlStr 38 + '</DIV>'; 39 40 parent.insertAdjacentHTML("BeforeEnd",txt); 41 42 elem = document.all[xName]; 43 } 44 else 45 if (document.getElementById) 46 { 47 if(parent == null) 48 parent=document.body; 49 else 50 parent=parent.elem; 51 52 var xName="xLayer" + JSFX.layerNo++; 53 var txt = "" 54 + "position:absolute;left:0px;top:0px;visibility:hidden"; 55 56 var newRange = document.createRange(); 57 58 elem = document.createElement("DIV"); 59 elem.setAttribute("style",txt); 60 elem.setAttribute("id", xName); 61 62 parent.appendChild(elem); 63 64 newRange.setStartBefore(elem); 65 strFrag = newRange.createContextualFragment(htmlStr); 66 elem.appendChild(strFrag); 67 } 68 69 return elem; 70} 71/**********************************************************************************/ 72JSFX.Layer = function(newLayer, parent) 73{ 74 if(!newLayer) 75 return; 76 77 if(typeof newLayer == "string") 78 this.elem = JSFX.createLayer(newLayer, parent); 79 else 80 this.elem=newLayer; 81 82 if(document.layers) 83 { 84 this.images = this.elem.document.images; 85 this.parent = parent; 86 this.style = this.elem; 87 if(parent != null) 88 this.style.visibility = "inherit"; 89 } 90 else 91 { 92 this.images = document.images; 93 this.parent = parent; 94 this.style = this.elem.style; 95 } 96 window[this.elem.id]=this; //save a reference to this 97} 98/**********************************************************************************/ 99JSFX.findLayer = function(theDiv, d) 100{ 101 if(document.layers) 102 { 103 var i; 104 if(d==null) d = document; 105 var theLayer = d.layers[theDiv]; 106 if(theLayer != null) 107 return(theLayer); 108 else 109 for(i=0 ; i<d.layers.length ; i++) 110 { 111 theLayer = JSFX.findLayer(theDiv, d.layers[i].document); 112 if(theLayer != null) 113 return(theLayer); 114 } 115 return("Undefined...."); 116 } 117 else 118 if(document.all) 119 return(document.all[theDiv]); 120 else 121 if(document.getElementById) 122 return(document.getElementById(theDiv)); 123 else 124 return("Undefined....."); 125} 126 127/**********************************************************************************/ 128/*** moveTo (x,y) ***/ 129JSFX.Layer.prototype.moveTo = function(x,y) 130{ 131 this.style.left = x+"px"; 132 this.style.top = y+"px"; 133} 134if(ns4) 135 JSFX.Layer.prototype.moveTo = function(x,y) { this.elem.moveTo(x,y); } 136/**********************************************************************************/ 137/*** show()/hide() Visibility ***/ 138JSFX.Layer.prototype.show = function() { this.style.visibility = "visible"; } 139JSFX.Layer.prototype.hide = function() { this.style.visibility = "hidden"; } 140JSFX.Layer.prototype.isVisible = function() { return this.style.visibility == "visible"; } 141if(ns4) 142{ 143 JSFX.Layer.prototype.show = function() { this.style.visibility = "show"; } 144 JSFX.Layer.prototype.hide = function() { this.style.visibility = "hide"; } 145 JSFX.Layer.prototype.isVisible = function() { return this.style.visibility == "show"; } 146} 147/**********************************************************************************/ 148/*** zIndex ***/ 149JSFX.Layer.prototype.setzIndex = function(z) { this.style.zIndex = z; } 150JSFX.Layer.prototype.getzIndex = function() { return this.style.zIndex; } 151/**********************************************************************************/ 152/*** ForeGround (text) Color ***/ 153JSFX.Layer.prototype.setColor = function(c){this.style.color=c;} 154if(ns4) 155 JSFX.Layer.prototype.setColor = function(c) 156 { 157 this.elem.document.write("<FONT COLOR='"+c+"'>"+this.elem.innerHTML+"</FONT>"); 158 this.elem.document.close(); 159 } 160/**********************************************************************************/ 161/*** BackGround Color ***/ 162JSFX.Layer.prototype.setBgColor = function(color) { this.style.backgroundColor = color==null?'transparent':color; } 163if(ns4) 164 JSFX.Layer.prototype.setBgColor = function(color) { this.elem.bgColor = color; } 165/**********************************************************************************/ 166/*** BackGround Image ***/ 167JSFX.Layer.prototype.setBgImage = function(image) { this.style.backgroundImage = "url("+image+")"; } 168if(ns4) 169 JSFX.Layer.prototype.setBgImage = function(image) { this.style.background.src = image; } 170/**********************************************************************************/ 171/*** set Content***/ 172JSFX.Layer.prototype.setContent = function(xHtml) { this.elem.innerHTML=xHtml; } 173if(ns4) 174 JSFX.Layer.prototype.setContent = function(xHtml) 175 { 176 this.elem.document.write(xHtml); 177 this.elem.document.close(); 178 this.elem.innerHTML = xHtml; 179 } 180 181/**********************************************************************************/ 182/*** Clipping ***/ 183JSFX.Layer.prototype.clip = function(x1,y1, x2,y2){ this.style.clip="rect("+y1+" "+x2+" "+y2+" "+x1+")"; } 184if(ns4) 185 JSFX.Layer.prototype.clip = function(x1,y1, x2,y2) 186 { 187 this.style.clip.top =y1; 188 this.style.clip.left =x1; 189 this.style.clip.bottom =y2; 190 this.style.clip.right =x2; 191 } 192/**********************************************************************************/ 193/*** Resize ***/ 194JSFX.Layer.prototype.resizeTo = function(w,h) 195{ 196 this.style.width =w + "px"; 197 this.style.height =h + "px"; 198} 199if(ns4) 200 JSFX.Layer.prototype.resizeTo = function(w,h) 201 { 202 this.style.clip.width =w; 203 this.style.clip.height =h; 204 } 205/**********************************************************************************/ 206/*** getX/Y ***/ 207JSFX.Layer.prototype.getX = function() { return parseInt(this.style.left); } 208JSFX.Layer.prototype.getY = function() { return parseInt(this.style.top); } 209if(ns4) 210{ 211 JSFX.Layer.prototype.getX = function() { return this.style.left; } 212 JSFX.Layer.prototype.getY = function() { return this.style.top; } 213} 214/**********************************************************************************/ 215/*** getWidth/Height ***/ 216JSFX.Layer.prototype.getWidth = function() { return this.elem.offsetWidth; } 217JSFX.Layer.prototype.getHeight = function() { return this.elem.offsetHeight; } 218if(!document.getElementById) 219 JSFX.Layer.prototype.getWidth = function() 220 { 221 //Extra processing here for clip 222 return this.elem.scrollWidth; 223 } 224 225if(ns4) 226{ 227 JSFX.Layer.prototype.getWidth = function() { return this.style.clip.right; } 228 JSFX.Layer.prototype.getHeight = function() { return this.style.clip.bottom; } 229} 230/**********************************************************************************/ 231/*** Opacity ***/ 232if(ns4) 233{ 234 JSFX.Layer.prototype.setOpacity = function(pc) {return 0;} 235} 236else if(document.all) 237{ 238 JSFX.Layer.prototype.setOpacity = function(pc) 239 { 240 if(this.style.filter=="") 241 this.style.filter="alpha(opacity=100);"; 242 this.elem.filters.alpha.opacity=pc; 243 } 244} 245else 246{ 247/*** Assume NS6 ***/ 248 JSFX.Layer.prototype.setOpacity = function(pc){ this.style.MozOpacity=pc+'%' } 249} 250/**************************************************************************/ 251/*** Event Handling - Start ***/ 252/*** NS4 ***/ 253if(ns4) 254{ 255 JSFX.eventmasks = { 256 onabort:Event.ABORT, onblur:Event.BLUR, onchange:Event.CHANGE, 257 onclick:Event.CLICK, ondblclick:Event.DBLCLICK, 258 ondragdrop:Event.DRAGDROP, onerror:Event.ERROR, 259 onfocus:Event.FOCUS, onkeydown:Event.KEYDOWN, 260 onkeypress:Event.KEYPRESS, onkeyup:Event.KEYUP, onload:Event.LOAD, 261 onmousedown:Event.MOUSEDOWN, onmousemove:Event.MOUSEMOVE, 262 onmouseout:Event.MOUSEOUT, onmouseover:Event.MOUSEOVER,
263 onmouseup:Event.MOUSEUP, onmove:Event.MOVE, onreset:Event.RESET, 264 onresize:Event.RESIZE, onselect:Event.SELECT, onsubmit:Event.SUBMIT, 265 onunload:Event.UNLOAD 266 }; 267 JSFX.Layer.prototype.addEventHandler = function(eventname, handler) 268 { 269 this.elem.captureEvents(JSFX.eventmasks[eventname]); 270 var xl = this; 271 this.elem[eventname] = function(event) { 272 event.clientX = event.pageX; 273 event.clientY = event.pageY; 274 event.button = event.which; 275 event.keyCode = event.which; 276 event.altKey =((event.modifiers & Event.ALT_MASK) != 0); 277 event.ctrlKey =((event.modifiers & Event.CONTROL_MASK) != 0); 278 event.shiftKey =((event.modifiers & Event.SHIFT_MASK) != 0); 279 return handler(xl, event); 280 } 281 } 282 JSFX.Layer.prototype.removeEventHandler = function(eventName) 283 { 284 this.elem.releaseEvents(JSFX.eventmasks[eventName]); 285 delete this.elem[eventName]; 286 } 287} 288/**************************************************************************/ 289/** IE 4/5+***/ 290else 291if(document.all) 292{ 293 JSFX.Layer.prototype.addEventHandler = function(eventName, handler) 294 { 295 var xl = this; 296 this.elem[eventName] = function() 297 { 298 var e = window.event; 299 e.cancelBubble = true; 300 if(document.getElementById) 301 { 302 e.layerX = e.offsetX; 303 e.layerY = e.offsetY; 304 } 305 else 306 { 307 /*** Work around for IE 4 : clone window.event ***/ 308 ev = new Object(); 309 for(i in e) 310 ev[i] = e[i]; 311 ev.layerX = e.offsetX; 312 ev.layerY = e.offsetY; 313 e = ev; 314 } 315 316 return handler(xl, e); 317 } 318 } 319 JSFX.Layer.prototype.removeEventHandler = function(eventName) 320 { 321 this.elem[eventName] = null; 322 } 323} 324/**************************************************************************/ 325/*** Assume NS6 ***/ 326else 327{ 328 JSFX.Layer.prototype.addEventHandler = function(eventName, handler) 329 { 330 var xl = this; 331 this.elem[eventName] = function(e) 332 { 333 e.cancelBubble = true; 334 return handler(xl, e); 335 } 336 } 337 JSFX.Layer.prototype.removeEventHandler = function(eventName) 338 { 339 this.elem[eventName] = null; 340 } 341} 342/*** Event Handling - End ***/ 343/**************************************************************************/ 344JSFX.Layer.prototype.setTimeout = function(f, t) 345{ 346 setTimeout("window."+this.elem.id+"."+f, t); 347} 348if(!window.JSFX) 349 JSFX=new Object(); 350 351if(!JSFX.Browser) 352 JSFX.Browser = new Object(); 353 354if(navigator.appName.indexOf("Netscape") != -1) 355{ 356 JSFX.Browser.getCanvasWidth = function() {return innerWidth;} 357 JSFX.Browser.getCanvasHeight = function() {return innerHeight;} 358 JSFX.Browser.getWindowWidth = function() {return outerWidth;} 359 JSFX.Browser.getWindowHeight = function() {return outerHeight;} 360 JSFX.Browser.getScreenWidth = function() {return screen.width;} 361 JSFX.Browser.getScreenHeight = function() {return screen.height;} 362 JSFX.Browser.getMinX = function() {return(pageXOffset);} 363 JSFX.Browser.getMinY = function() {return(pageYOffset);} 364 JSFX.Browser.getMaxX = function() {return(pageXOffset+innerWidth);} 365 JSFX.Browser.getMaxY = function() {return(pageYOffset+innerHeight);} 366 367} 368else if(document.all) { 369 JSFX.Browser.getCanvasWidth = function() {return document.body.clientWidth;} 370 JSFX.Browser.getCanvasHeight = function() {return document.body.clientHeight;} 371 JSFX.Browser.getWindowWidth = function() {return document.body.clientWidth;} 372 JSFX.Browser.getWindowHeight = function() {return document.body.clientHeight;} 373 JSFX.Browser.getScreenWidth = function() {return screen.width;} 374 JSFX.Browser.getScreenHeight = function() {return screen.height;} 375 JSFX.Browser.getMinX = function() {return(document.body.scrollLeft);} 376 JSFX.Browser.getMinY = function() {return(document.body.scrollTop);} 377 JSFX.Browser.getMaxX = function() { 378 return(document.body.scrollLeft 379 +document.body.clientWidth); 380 } 381 JSFX.Browser.getMaxY = function() { 382 return(document.body.scrollTop 383 +document.body.clientHeight); 384 } 385} 386JSFX.FallingSprite = function(theHtml) 387{ 388 //Call the superclass constructor 389 this.superC = JSFX.Layer; 390 this.superC(theHtml); 391 392 this.x = Math.random() * (JSFX.Browser.getMaxX()-40); 393 this.y = -40; 394 this.dx = Math.random() * 4 - 2;
395 this.dy = Math.random() * 6 + 2; 396 this.ang = 0; 397 this.angStep = .2; 398 this.amp = 10; 399 this.state = "FALL"; 400 401 this.moveTo(this.x,this.y); 402 this.show(); 403} 404JSFX.FallingSprite.prototype = new JSFX.Layer; 405 406JSFX.FallingSprite.prototype.animate = function() 407{ 408 if(this.state == "OFF") 409 return; 410 411 this.x += this.dx; 412 this.y += this.dy; 413 this.ang += this.angStep; 414 415 this.moveTo(this.x + this.amp*Math.sin(this.ang), this.y); 416 417 if( (this.x > JSFX.Browser.getMaxX()-20) 418 || (this.x < JSFX.Browser.getMinX()-0) 419 || (this.y > JSFX.Browser.getMaxY()-40) ) 420 { 421 if(this.state == "STOPPING") 422 { 423 this.moveTo(-100,-100); 424 this.hide(); 425 this.state = "OFF"; 426 } 427 else 428 { 429 this.x = Math.random() * (JSFX.Browser.getMaxX()-40); 430 this.y = JSFX.Browser.getMinY()-40; 431 this.dx = Math.random() * 4 - 2; 432 this.dy = Math.random() * 6 + 2; 433 this.ang = 0; 434 } 435 } 436} 437/*** Class FallingObj extends Object ***/ 438JSFX.FallingObj = function(numSprites, theImage, stopTime) 439{ 440 this.id = "JSFX_FallingObj_"+JSFX.FallingObj.count++; 441 this.sprites = new Array(); 442 for(i=0 ; i<numSprites; i++) 443 { 444 this.sprites[i]=new JSFX.FallingSprite(theImage); 445 } 446 window[this.id]=this; 447 this.animate(); 448 449 if(stopTime) 450 setTimeout("window."+this.id+".stop()", stopTime*1000); 451 452} 453JSFX.FallingObj.count = 0; 454 455JSFX.FallingObj.prototype.stop = function() 456{ 457 for(i=0 ; i<this.sprites.length ; i++) 458 this.sprites[i].state = "STOPPING"; 459} 460 461JSFX.FallingObj.prototype.animate = function() 462{ 463 setTimeout("window."+this.id+".animate()", 40); 464 465 for(i=0 ; i<this.sprites.length ; i++) 466 this.sprites[i].animate(); 467 468} 469/*** END Class FallingObj ***/ 470 471/* 472 * Class Falling extends Object (Static method for creating "Falling" objects 473 */ 474Falling = function(n, theImage, stopTime) 475{ 476 myFalling = new JSFX.FallingObj(n, theImage, stopTime); 477 478 return myFalling; 479}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.