//////////////////// // // // Extensions // // // //////////////////// Array.prototype.shuffle = function () { var i = this.length; if( i == 0 ) return false; while( --i ) { var j = Math.floor( Math.random() * ( i + 1 ) ); var tempi = this[i]; var tempj = this[j]; this[i] = tempj; this[j] = tempi; }; }; Math.rand = function ( a, b ) { if( a && !b ) return Math.floor( Math.random() * a ); if( a > b ) return Math.floor( Math.random() * ( a - b )) + b; if( b > a ) return Math.floor( Math.random() * ( b - a )) + a; return a; }; ///////////////// // // // Objects // // // ///////////////// function Path( xcen, ycen, xrad, yrad, bits ) { this.x = new Array(); this.y = new Array(); this.t = 197; var a = (2 * Math.PI) / bits; for( var i = 0; i < bits; i ++ ) { this.x[i] = Math.round( xcen + (xrad * Math.cos( a * i )) ); this.y[i] = Math.round( ycen + (yrad * Math.sin( a * i )) ); }; }; function Wind( node ) { if( !node.style.position ) node.style.position = "relative"; if( node.style.position != "fixed" ) { if( !node.style.left ) node.style.left = "0px"; if( !node.style.top ) node.style.top = "0px"; }; var xcen = parseInt( node.style.left ); var ycen = parseInt( node.style.top ); var xrad = Math.rand( xRadiusMin, xRadiusMax ); var yrad = Math.rand( yRadiusMin, yRadiusMax ); var bits = Math.rand( cyclesMin , cyclesMax ); this.node = node; this.node.style.left = xcen +"px"; this.node.style.top = ycen +"px"; this.path = new Path( xcen, ycen, xrad, yrad, bits ); this.draw = function () { this.node.style.left = this.path.x[this.path.t] +"px"; this.node.style.top = this.path.y[this.path.t] +"px"; this.path.t = (this.path.t + 1) % this.path.x.length; }; this.loop = window.setInterval( "winds["+ i +"].draw()", (30 + i) ); }; function Ticker( titleAdd ) { this.ln = document.title.length; this.tx = document.title + titleAdd + document.title + titleAdd; this.mx = this.tx.length / 2; this.ps = 0; this.tk = function () { document.title = this.tx.substr( this.ps, this.ln ); this.ps ++; if( this.ps > this.mx ) { this.ps = 0; window.clearInterval( this.tm ); this.tm = window.setInterval( "tickerTitle.tk()", 2000 ); } if( this.ps == 1 ) { window.clearInterval( this.tm ); this.tm = window.setInterval( "tickerTitle.tk()", 100 ); }; }; this.tm = window.setInterval( "tickerTitle.tk()", 100 ); }; ////////////////// // // // Routines // // // ////////////////// function domParse( el, lm, dp ) { var tags = new Array(); var i = 0; while( i < el.childNodes.length ) { var ch = el.childNodes[i]; if( ch.tagName ) { tags.push( ch ); if( dp < lm ) { var seep = domParse( ch, lm, dp + 1 ); if( seep.length > 0 ) tags = tags.concat( seep ); }; }; i++; }; return tags; }; ///////////////// // // // Globals // // // ///////////////// var zipCode = '11238'; var windSpeed = 10; var xRadiusMin = windSpeed / 3; var xRadiusMax = windSpeed / 1; var yRadiusMin = windSpeed / 4; var yRadiusMax = windSpeed / 3; var cyclesMin = (360 / (windSpeed / 2)) + 0; var cyclesMax = (360 / (windSpeed / 2)) + 20; //////////////////// // // // Fuck It Up // // // //////////////////// if( parent.frames.length ) { var body = parent.document.getElementsByTagName( "body" )[0]; } else { var body = document.getElementsByTagName( "body" )[0]; }; var tags = domParse( body, 8, 0 ); var stop = tags.length; if( stop > 60 ) { tags.shuffle(); stop = 60; }; var winds = new Array(); for( var i = 0; i < stop; i++ ) { winds[i] = new Wind( tags[i] ); }; var windMakerURL = "http://stewdio.org/windmaker/windmaker.html"; var anchors = document.getElementsByTagName( "a" ); for( var i = 0; i < anchors.length; i ++ ) { anchors[ i ].href = windMakerURL + "?zip=" + zipCode + "&url=" + escape( anchors[ i ].href ); }; var titleAdd = " ... Current wind conditions for "+ zipCode +" ... "; var tickerTitle = new Ticker( titleAdd );