Dojo goes Disco !

Hello everybody,

Though this code snippet might not be the most usefull, it could still help in some cases. Here i will show you a funny example to make your app go disco !

Warning: The following demos in this post contains flashing lights and patterns.

The interesting thing here is the random hex colour generator (i’m not the author, but this is a compilation of several generators i’ve found on the web), of course :

1
2
3
4
5
6
dojo.style(
    zone,
    "border",
    "2px solid #" + ("00000"+(Math.random()*16777216<<0).toString(16)).substr(-6)
);
</div>

Of course the following use case is totally absurd and not optimized at all, but you can try it on your app and feel the disco spirit flow into you again :D

1
2
3
4
5
6
7
8
9
10
11
12
13
14
postCreate : function(){
    // whatever code you have here, just add this line at the bottom
    var interval = setInterval(dojo.hitch(this, function(){this.disco();}), 125);
},

disco : function(){
    dojo.query("div").forEach(function(theDiv){
        dojo.style(
            theDiv,
            "border",
            "2px solid #" + ("00000"+(Math.random()*16777216<<0).toString(16)).substr(-6)
        );
    }, this);
}

In any case, the good thing is that the colour generator can be used to create random colour panes or for debugging when you have many nested stuffs, or just for fun :)

See the snippet in action here :
http://dojo-sandbox.net/public/10e1c/0

Share and Enjoy

This entry was posted in Dojo, Random and tagged , , , , , . Bookmark the permalink.

10 Responses to Dojo goes Disco !

  1. Wuhi says:

    this snipped changed my life!
    Here is MY contribution http://dojo-sandbox.net/public/b1707/0

  2. PEM says:

    And don’t forget to click on the “Run” tab to see it in action ! ;)
    Awesome contribution by the way !

  3. Zladivliba says:

    I’m just feeling the vibe !

  4. Zladivliba says:

    Ok I couldn’t let your guys do this all on your own, so here’s my part :
    http://dojo-sandbox.net/public/a14ba/3
    or
    http://dojo-sandbox.net/public/a14ba/6

  5. nice post bro. waiting for the next part to show up

  6. Evie says:

    loool. that is a great idea! :(

  7. Prooridub says:

    Nice Post. This record helped me in my college assignment. Thnaks Alot

  8. Brielle says:

    J’aime vraiment votre article. J’ai essaye de trouver de nombreux en ligne et trouver le votre pour ĂȘtre la meilleure de toutes.

    Mon francais n’est pas tres bon, je suis de l’Allemagne.

    [Edited by PEM : no Advertisement for 3rd party websites allowed in comments]

Leave a Reply

Your email address will not be published. Required fields are marked *