Sunday, August 31, 2008

Much to update... but for now just a code snippet...

A lot's happened since my last post - but for now I'd just like to share this line of JavaScript I came across a moment ago. It even comes with a helpful comment!
// Please, don't change below this line

// ----------------------------------------------------------------------------------

var menus=[],TMg,TM09=['click','mouseout','mouseover','mousedown','hide'];function TM0A(TM0B){for(var i in menus){if(TM0B&&menus[i].TM0C&&!menus[i].TMc)menus[i].TM0C.TM0D.menus[i].TM0E();menus[i].TM0E();menus[i].TM0F=true}this.TM0G=true}function TM0H(TM0I){var TM0J;if(this.width!=(TM0J=this.TM0K(window))){this.width=TM0J;TM0B=TM0I=true}if(this.height!=(TM0J=this.TM0L(window))){this.height=TM0J;TM0B=TM0I=true}if(this.TM0M!=(TM0J=this.TM0N(window))){this.TM0M=TM0J;TM0I=true}if(this.TM0O!=(TM0J=this.TM0P(window))){this.TM0O=TM0J;TM0I=true}if(TM0I){this.TM0G=false;this.TM0E(TM0B)}}function menu(TM0Q,TM0R,TM0S){this.TM0Q=TM0Q;this.TM0R=TM0R;this.TMh=[];this.TM0T=[];this.TMT=[];this.exec=TM0U;this.hide=TM0V;this.onhide=TM0W;this.onclick=TM0X;this.onmouseout=TM0Y;this.onmouseover=TM0Z;this.onmousedown=TM0a;this.TM0E=TM0b;this.TM0c=TMM;this.TM0d=this.TMd=this.TMQ=0;this.TM08=function(){};if(TM0S){this.TMQ=TM0S.zIndex||0;this.TM05=TM0S.onexpand&&typeof(TM0S.onexpand)=='function'?TM0S.onexpand:null;this.TM0e=TM0S.oncollapse&&typeof(TM0S.oncollapse)=='function'?TM0S.oncollapse:null;if(TM0S.wrapper&&typeof(TM0S.wrapper)=='function')this.TMp=TM0S.wrapper;this.TMc=Boolean(TM0S.frames);this.TMd=TM0S.popup?-1:0;this.TM0f=Boolean(TM0S.showroot);var TM0g=TM0S.frames;if(this.TMd){this.TM03=TMy;this.expand=TM04;if(document.images[TM0S.popup]){this.elements=[document.images[TM0S.popup]];this.TM07=TM0h}else this.TM07=function(){}}if(TM0S.forms){this.TMJ=TM0S.forms;this.TM08=TMF}}if(!this.TMp)this.TMp=TM0i;this.TM0j={'width':100,'height':20,'block_top':null,'block_left':null,'vertical':false,'expd_delay':0,'hide_delay':100,'table':[0,0,0],'css':{'table':'','inner':'','outer':''}};this.TMR=-1;this.TMP=this;this.TMV=function(TM0k){return this.TM0j[TM0k]};if(!TMg){TMg=new TM0();TMg.TM0l={'x':0,'y':0};TMg.TM0m=navigator.userAgent.indexOf('Gecko')>-1;TMg.TMm=TMenu_path_to_files+'pixel.gif';if(TMg.TM0n){document.write('<div id="TMAnchor" style="position:absolute">.</div>');TMg.TM0o=TMg.TM3('TMAnchor')}if(!TMg.TM0p)TMg.TM0p='onload';TMg.TM0K=window.innerWidth!=null?function(w){return w.innerWidth}:function(w){return w.document.body.offsetWidth};TMg.TM0L=window.innerHeight!=null?function(w){return w.innerHeight}:function(w){return w.document.body.offsetHeight};TMg.TM0N=window.pageXOffset!=null?function(w){return w.pageXOffset}:function(w){return w.document.body.scrollLeft};TMg.TM0P=window.pageYOffset!=null?function(w){return w.pageYOffset}:function(w){return w.document.body.scrollTop};TMg.TM0E=TM0A;TMg.TM0q=TM0H}this.id=TM0S&&TM0S.key?TM0S.key:menus.length;menus[this.id]=this;this.TMY=[];this.TMt=this.TM0Q.length;this.TM0r=Boolean(this.TM0R[0].block_top==null&&this.TM0R[0].block_left==null);for(var i=0;i<this.TMt;i++)new TM0s(i,this,this,i);this.TM0c(1);this.TMe=this.TMf;for(i=0;i<this.TMT.length;i++)this.TMT[i].TM0t();if(top!=window&&(TM0g&&(TM0g+'').indexOf(',')>-1||!TM0g)){TMg.TM0u=TMg.TM1||(window.opera&&document.appendChild)||TMg.TM0v?top.document.body:top;if(window.frameElement!=null)TMg.TM0L=function(w){return w.frameElement.offsetHeight};if(!top.TM0w){top.TM0w={'TM0y':[]};var TM0x,TMb=TMg.TM0u[TMg.TM0p]?new String(TMg.TM0u[TMg.TM0p]):'';if((TM0x=TMb.indexOf('{'))>-1)TMb=TMb.substring(TM0x+1,TMb.lastIndexOf('}')-1)+';';TMg.TM0u[TMg.TM0p]=Function(TMb+'top.TM0w.TM0z()')}if(!top.TM0w.TM0y[this.id])top.TM0w.TM0y[this.id]={'TM11':0,'TM0g':[],'TM19':[],'TM12':[]};if(this.TMc&&!top.TM0w.TM0z){top.TM0w.TM0z=function(){for(var TM10 in this.TM0y){if(this.TM0y[TM10].TM11<2){this.TM0y[TM10].TM12[0].TM0C=null;return this.TM0y[TM10].TM0g[0].setInterval('TMg.TM0q()',500)}for(var TM13 in this.TM0y[TM10].TM0g)if(this.TM0y[TM10].TM0g[TM13]&&this.TM0y[TM10].TM0g[TM13].TMg)this.TM0y[TM10].TM0g[TM13].TMg.TM0q()}setTimeout('top.TM0w.TM0z()',200)};top.TM0w.TM14=function(TM15,TM16,TM17){var TM12=this.TM0y[TM15].TM12;for(var TM10 in TM12)if(TM12[TM10]&&!TM12[TM10].TM0T[TM16])return setTimeout('top.TM0w.TM14("'+TM15+'","'+TM16+'",'+TM17+')',100);for(TM10 in TM12)if(TM12[TM10])TM12[TM10]['on'+TM09[TM17]](TM16)}}var TM18=this.TM0C=top.TM0w.TM0y[this.id];if(TM18.TM19[name]==null){TM18.TM19[name]=TM18.TM11;TM18.TM11++}TM18.TM0g[TM18.TM19[name]]=window;TM18.TM12[TM18.TM19[name]]=this;if(this.TMc){TM18.TM0D=window;this.TM0g=[];for(i in TM0g){this.TM0g[i]=[];for(var j in TM0g[i])this.TM0g[i][j]=eval('top.'+TM0g[i][j])}}window.onunload=function(){for(var TM10 in menus){if(menus[TM10].TM0C){menus[TM10].TM0C.TM0g[menus[TM10].TM0C.TM19[name]]=menus[TM10].TM0C.TM12[menus[TM10].TM0C.TM19[name]]=null}}}}else if(!TMg.TM1A)TMg.TM1A=setInterval('TMg.TM0q()',200)}function TM0b(){if(this.TM0C){this.TM0g=this.TM0C.TM0D.menus[this.id].TM0g;if(this.TMc){var TM1B=0,TM1C;this.TM0C.TM1D=[];for(i in this.TM0g){TM1C=0;for(j in this.TM0g[i]){if(!this.TM0C.TM1D[this.TM0g[i][j].name])this.TM0C.TM1D[this.TM0g[i][j].name]={'x':TM1C,'y':TM1B};TM1C+=TMg.TM0K(this.TM0g[i][j])}TM1B+=TMg.TM0L(this.TM0g[i][j])}this.TM0C.TMe=TMg.TM4(this.TMe,this.TM0C.TM1D[window.name].x-TMg.TM0N(window),this.TM0C.TM1D[window.name].y-TMg.TM0P(window),TMg.TM0v)}else{TMg.TMB(this.TMe,{'x':this.TM0C.TMe.x-this.TM0C.TM1D[window.name].x+TMg.TM0N(window),'y':this.TM0C.TMe.y-this.TM0C.TM1D[window.name].y+TMg.TM0P(window)});if(this.TM0f)TMg.TM8(this.TMe,1)}}if(document.layers)for(var TM10=0;TM10<this.TMt;TM10++)this.TMT[TM10].TM00(0);else if(TM1E&&!TMg.TM0n)for(var TM10=0;TM10<this.TMt;TM10++)this.TMT[TM10].TM07()}function TM0U(id,TM17){if(!TMg.TM0G)return;if(this.TM0C&&TM17){top.TM0w.TM14(this.id,id,TM17)}else return menus[this.id]['on'+TM09[TM17]](id)}function TM0V(){if(this.TM0d>0||!this.TM1F)return;if(this.TMI)this.TMI.TM03(this.TMd);this.TMI=null;if(this.TM0e)this.TM0e();if(!TMg.TM2&&!TMg.TM0m)this.TM08(true)}function TM0W(){if(this.TMI)this.TMI.TM03(this.TMd);this.TMI=null;this.TM0d=0}function TM0X(id){var TM1G=Boolean(this.TM0T[id].TMq[1]);if(TM1G&&this.TM0C)top.TM0w.TM14(this.id,id,4);return TM1G}function TM0Y(id){this.TM0d--;this.TM0T[id].TM00(0);if(this.TM1H)clearTimeout(this.TM1H);this.TM1F=setTimeout('menus["'+this.id+'"].hide()',this.TM0T[id].TMV('hide_delay'));if(this.TM0T[id].TMh.sb!=null)top.status='';if(this.TM0T[id].TMh.oo!=null)this.TM0T[id].TMh.oo(id)}function TM0Z(id){if((TMg.TM0m||window.opera)&&this.TM0T[id].TMx==1)return;this.TM0d++;for(var TM1I=this.TM0T[id];TM1I!=this;TM1I=TM1I.TMs)TM1I.TM00(1);var TM1I=this.TM0T[id];clearTimeout(this.TM1F);this.TM1F=null;if(TM1I.TMh.sb!=null)setTimeout('menus["'+this.id+'"].TM0T["'+id+'"].TM1N()',10);this.TM02=TM1I;if(TM1I.TMh.oh!=null)TM1I.TMh.oh(id);if(TM1I.TMs.TMT[0].TM1J<0)return;if(TM1I.TMs.TMT[0].TM1J)this.TM1H=setTimeout('menus["'+this.id+'"].TM0T["'+id+'"].expand()',TM1I.TMs.TMT[0].TM1J);else TM1I.expand()}function TM0a(id){this.TM0T[id].TM00(2);if(this.TM0T[id].TMs.TMT[0].TM1J<0)this.TM0T[id].expand()}function TM0s(TM1K,TMs,TMP,TM1L){this.id=this.TM1K=new String(TM1K);this.TMs=TMs;this.TMP=TMP;this.TMr=this.TM1K.split('_');this.TMR=this.TMr.length-1;var TM1M='';for(var i=0;i<=this.TMR;i++)TM1M+='['+(Number(this.TMr[i])+(i?3:0))+']';eval('this.TMq = this.TMP.TM0Q'+TM1M);if(!this.TMq)return;this.TMh=this.TMq[2]?this.TMq[2]:[];this.TMP.TM0T[this.id]=this;TMs.TMT[TMs.TMT.length]=this;this.TM00=TMw;this.TM1N=TM1O;this.TM07=TM0h;this.TMp=this.TMP.TMp;this.TM0c=TMo;this.TMV=TM1P;this.TMX=TM1Q;this.TM0t=TMv;this.TM03=TMy;this.expand=TM04;if(!TM1L){this.TM1R=this.TMs.TMh.bt||this.TMV('block_top');this.TM1S=this.TMs.TMh.bl||this.TMV('block_left');this.TM1T=this.TMV('top')<0;this.TM1U=this.TMV('left')<0;this.TM1V=this.TMV('width');this.TM1W=this.TMV('height');this.TMu=this.TMV('vertical');this.TM1X=this.TMV('wise_pos');this.TM1J=this.TMV('expd_delay')}var TM1Y=this.TMs.TMT[0].TM1V,TM1Z=this.TMs.TMT[0].TM1W;if(this.TMs.TMT[0].TMu){if(this.TMs.TMh.bw!=null)TM1Y=this.TMs.TMh.bw;if(this.TMh.sh!=null)TM1Z=this.TMh.sh}else{if(this.TMs.TMh.bh!=null)TM1Z=this.TMs.TMh.bh;if(this.TMh.sw!=null)TM1Y=this.TMh.sw}this.TMs.TMY[TM1L]=this.TM0c(TM1Y,TM1Z);this.TMt=this.TMq.length-3;if(this.TMt>0&&this.TMq[3]){this.TMT=[];this.TM1a=TMM;this.TM06=TM1b;if(TM1E&&!document.layers){this.TM06();this.TM1c=this.TMR==0&&this.TMP.TM0r}}}function TM0i(TM1d){return TM1d}function TM1b(){this.TMY=[];for(var i=0;i<this.TMt;i++)if(this.TMq[3+i])new TM0s(this.TM1K+'_'+i,this,this.TMP,i);else this.TMt--;this.TM1a();for(i in this.TMT)this.TMT[i].TM0t()}function TM1O(){top.status=this.TMh.sb}function TM1P(TM0k){var TM1e=null,TM1f=this.TMP.TM0R[this.TMR];if(TM1f)TM1e=TM1f[TM0k];return(TM1e==null?this.TMs.TMV(TM0k):TM1e)}function TM1Q(TM1g,TM1h){var TM1i=this.TMV('css'),TM1j=TM1i[TM1g];if(typeof(TM1j)=='string')return TM1j;for(var TM1k=TM1h;TM1k>=0;TM1k--)if(TM1j[TM1k])return TM1j[TM1k]}function TM0h(TMC,value){if(this.TMt>0){if(TMg.TM0n){TMg.TMB(TMg.TM0o,{'x':0,'y':0});TMg.TM0l=TMg.TM4(TMg.TM0o,0,0);TMg.TM0n=0}var TM1l=this.TMT[0],TM1m=TMg.TM4(this.elements[0],(this.TMh.bl?this.TMh.bl:TM1l.TM1S)-TMg.TM0l.x,(this.TMh.bt?this.TMh.bt:TM1l.TM1R)-TMg.TM0l.y,this.TM1c);if(TM1l.TM1U)TM1m.x-=TMg.TMD(this.TMf);if(TM1l.TM1T)TM1m.y-=TMg.TMD(this.TMf,1);if(TM1l.TM1X&&!this.TMP.TM0C){var wise=TM1l.TM1X,TM1n=TMg.TMD(this.TMf,0),TM1o=TMg.TMD(this.TMf,1),TM1p=TMg.TM0K(window),TM1q=TMg.TM0L(window),TM1r=TMg.TM0N(window),TM1s=TMg.TM0P(window);if(TM1m.x+TM1n>TM1p+TM1r)TM1m.x=(wise==1?TM1p+TM1r:TM1m.x)-TM1n;if(TM1m.y+TM1o>TM1q+TM1s)TM1m.y=(wise==1?TM1q+TM1s:TM1m.y)-TM1o;if(TM1m.x<TM1r)TM1m.x=TM1r;if(TM1m.y<TM1s)TM1m.y=TM1s}TMg.TMB(this.TMf,TM1m);if(this.TMn)TMg.TMB(this.TMn,TM1m);if(TM1E&&!document.layers)for(var TM10=0;TM10<this.TMt;TM10++)this.TMT[TM10].TM07()}}var TM1t=navigator.appVersion.split('MSIE '),TM1E=window.opera||TM1t.length<2||parseFloat(TM1t[1])<5||(navigator.appVersion.indexOf('Mac')>-1&&navigator.appVersion.indexOf('MSIE')>-1)||navigator.userAgent.indexOf('Konqueror')>-1;document.write('<scr','ipt language="JavaScript" src="',TMenu_path_to_files,'menu.',(document.layers?'lay':TM1E?'opr':'dom'),'.js"></scr','ipt>');

In order to preserve the layout of this page, I've added line breaks; that was, literally, a single line of code. A single, 9,911-character, line of code.

And that just about sums up the state of the codebase for this particular website...

3 comments:

Anonymous said...

Are you sure that wasn't compiled from some much easier to read source that you no longer have? Either a simple JS code compactor, or something like GWT?

James Muscat said...

That's entirely probable... but the comment did made me laugh!

As another clue as to where it's from: embedding the js code that creates your drop-down menus on every page of your dynamic-content site - not such a good plan. Particularly when you've coded several of them wrongly... ;-)

Anonymous said...

So. Presumably you submitted that to The Daily WTF?