|
Random Button
Last post 11-23-2007 3:10 AM by dhromed. 9 replies.
-
11-19-2007 12:19 AM
|
|
-
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 2,500
|
ALA has a "selected article sidebar" thingy. FYI.
— Flurp.
|
|
-
-
Mr. Lurker


- Joined on 06-22-2007
- Posts 8
|
Being very impatience and bored, I decided to implement this random function myself, in JavaScript no less (as I don't have access to a PHP-server). You can find it at the following location:
http://home.lyse.net/aadnk/Redirect/WTF.html
Enjoy!
|
|
-
-
PSWorx


- Joined on 04-28-2006
- Posts 688
|
Mr. Lurker:Being very impatience and bored, I decided to implement this random function myself, in JavaScript no less (as I don't have access to a PHP-server). You can find it at the following location:
http://home.lyse.net/aadnk/Redirect/WTF.html
Enjoy!
My Nerd-fu has been challenged! javascript:(function(){var a,b,r,i,y,l;a='.XMLHTTP';b='msxml2'+a;a=[b+'.5.0',b+'.4.0',b+'.3.0',b,'Microsoft'+a];r=XMLHttpRequest;if(r)r=new(r)();else for(i=0;i<5;i++)try{if(r=new(ActiveXObject)(a[i]))break}catch(e){};if(!r)return;d=function(m,n){with(Math)return(m+round(random()*(n-m)))};y=d(2004,(new(Date)()).getFullYear());r.open('GET','/Articles/'+y+'/'+d((y==2004)?5:1,12)+'/default.aspx/');r.onreadystatechange=function(){if(r.readyState!=4)return;l=r.responseText.match(/\/Articles\/[^\s\/"]+\.aspx/g);location.href='http://thedailywtf.com/'+l[d(0,l.length)]};r.send()})()
|
|
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 2,500
|
What sort of syntax habit is this, then?
new(r)()
(new(Date)())
new(ActiveXObject)(a[i])
It reminds me of the typeof function and the return function.
But nice job on the micro-XHR-client.
— Flurp.
|
|
-
-
PSWorx


- Joined on 04-28-2006
- Posts 688
|
dhromed:What sort of syntax habit is this, then?
new(r)()
(new(Date)())
new(ActiveXObject)(a[i])
It reminds me of the typeof function and the return function.
But nice job on the micro-XHR-client.
Thanks! The bracket around "new Date" is so I can call functions of the created object. The other ones are just to avoid whitespace. Since whitespace is encoded as %20 - three bytes - you effectively save a byte that way. Besides, it looks better. ... why are you looking at me so funny?
|
|
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 2,500
|
PSWorx: dhromed:What sort of syntax habit is this, then?
new(r)()
(new(Date)())
new(ActiveXObject)(a[i])
It reminds me of the typeof function and the return function.
But nice job on the micro-XHR-client.
Thanks! The bracket around "new Date" is so I can call functions of the created object. The other ones are just to avoid whitespace. Since whitespace is encoded as %20 - three bytes - you effectively save a byte that way. Besides, it looks better.
You can call methods of an instance without parens, too. The JS manual (that is, the JScript one from MS) says that . has higher precedence than new, and that new Date().getFullYear() should fail -- except it doesn't.
Saving space (har! pun!) -- okay. Looking better -- I happily disagree and believe it illustrates that the coder doesn't seem to realise that they're not functions. Also, you say you do it to avoid whitespace, but then put spaces after ifs and elses. :)
— Flurp.
|
|
-
-
PSWorx


- Joined on 04-28-2006
- Posts 688
|
dhromed: PSWorx: dhromed:What sort of syntax habit is this, then?
new(r)()
(new(Date)())
new(ActiveXObject)(a[i])
It reminds me of the typeof function and the return function.
But nice job on the micro-XHR-client.
Thanks! The bracket around "new Date" is so I can call functions of the created object. The other ones are just to avoid whitespace. Since whitespace is encoded as %20 - three bytes - you effectively save a byte that way. Besides, it looks better.
You can call methods of an instance without parens, too. The JS manual (that is, the JScript one from MS) says that . has higher precedence than new, and that new Date().getFullYear() should fail -- except it doesn't.
Saving space (har! pun!) -- okay. Looking better -- I happily disagree and believe it illustrates that the coder doesn't seem to realise that they're not functions. Also, you say you do it to avoid whitespace, but then put spaces after ifs and elses. :)
The construct fails on firefox/spidermonkey, as it should - which is enough for me. Also, look again: I can't remove spaces if they delimit two letters. "elsefor" causes a syntax error for some weird reason :) I agree though, I'm still a lowly novice in the fine art of pointless obfuscation. My next one will be more sane.
|
|
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 2,500
|
PSWorx:The construct fails on firefox/spidermonkey, as it should - which is enough for me.
new Date().getFullYear() does not fail in FFX.
PSWorx:"elsefor" causes a syntax error for some weird reason :) That's so odd! You're using that hacker tool Opera, aren't you?
— Flurp.
|
|
Page 1 of 1 (10 items)
|
|
|