Random Button



  • I created this solely because I read the articles on this site every once in a while, and because of such I want a random button.  I would love on my break from work to just hit random and get some awesome WTF to read before I have to go back to life.  If this has already been suggested a million times before, I am so very sorry.



  • @Razmeth said:

    I created this solely because I read the articles on this site every once in a while, and because of such I want a random button.  I would love on my break from work to just hit random and get some awesome WTF to read before I have to go back to life.  If this has already been suggested a million times before, I am so very sorry.

    I agree... I'm sure there's some great articles that I haven't read hiding on the site, and a "random" button would be great :D.



  • ALA has a "selected article sidebar" thingy.

    FYI. 



  • 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!

     



  • @Mr. Lurker said:

    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()})() 



  • 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. 



  • @dhromed said:

    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? 



  • @PSWorx said:

    @dhromed said:

    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. :)



  • @dhromed said:

    @PSWorx said:
    @dhromed said:

    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.



  • @PSWorx said:

    The construct fails on firefox/spidermonkey, as it should - which is enough for me.

    new Date().getFullYear() does not fail in FFX.

    @PSWorx said:

    "elsefor" causes a syntax error for some weird reason :)
     

    That's so odd! You're using that hacker tool Opera, aren't you? 


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.