Adding Fireworks to Your Blog

As a special project at Institutional Web Support Services, I had the opportunity to alter the iCampus login page for the 4th of July weekend. The iCampus page now features a fireworks display.

As an added “Easter egg”, the logo at the top-left corner of the screen is now a roll-over link (see images below). The link itself has different images for up, over and down states. The new logo is of a firework/rocket in place of the “i” of the original white iCampus logo. At its up state, the rocket has its wick wrapped around itself and the spark has been placed where the dot of the “i” used to be. On hover/over, the wick is shorter and the spark is nearing the rocket. A message also pop’s up reading, “Click for the Grand Finale!”. Upon clicking an additional sequence of randomly timed fireworks go off at the top of the screen. Below I have some imges and finally a tutorial on how to make fireworks for your site!

icampus logo 4thJuly2011 Adding Fireworks to Your Blog

Image copyright IWSS at Illinois State University.

If you wanna check out the page, just go to the Illinois State University iCampus login page (this will only be up for the 2011 4th of July weekend).

Screen shot 2011 06 30 at 12.54.16 PM 400x77 Adding Fireworks to Your Blog

The Tutorial

The Code

  1. Resources for Header

    After unzipping the download above and placing all the necessary files in their proper locations, you can load these scripts with this code in the HEADER tag.
    <head>
    <link rel="stylesheet" type="text/css" href="style/fireworks.css" media="screen" />
    <!--script type="text/javascript" src="script/debug.js"></script-->
    <!--script type="text/javascript" src="script/soundmanager.js"></script-->
    <script type="text/javascript" src="script/fireworks.js"></script>
    </head>

  2. Comment for Help

    This commented out code is useful in knowing how the createFirework function can be called. Knowing what each variable does is helpful in creating that perfect show.
    <!--
    <code>
    createFirework(<span id="function-example">nRadius,nParticles,nCircles,burstType,startX,startY,burstX,burstY)</span>);
    </code>
    -->

  3. Creating a Fireworks Show on Page Load

    Luckily, the BODY tag of a document has an event object called “onload” that allows you to run a script when the BODY of an HTML document finished loading. We can then add a firework script to launch a random sequence of explosions…
    <body onload="var r=4+parseInt((Math.random()*1)+100);for(var i=r; i--;){setTimeout('createFirework(8,(Math.random()*15)+15,(Math.random()*3)+1,1,null,95,(Math.random()*85)+10,(Math.random()*10)+1,Math.random()>0.5,false, false)',(i+1)*(1+parseInt(Math.random()*1000)+2000));}return false">
    In this code a value with “null” returns a random number, however if you want to create a more controlled number you have to use a math operator. “(Math.random()*5)+100)” means… you will return a random number between 0-4 and then add 100 to it. The possible outcomes are then 100, 101, 102, 103 and 104. Most of the x-y variables in this code accept only a 0-100 value because they are based on percentages of the screen. Keep that in mind when manipulating the math.

  4. Make a Click-able Link Launch a Firework Show

    Just like the BODY tag, an A tag has a lot of “events” that can launch scripts. It only makes sense to then use “onclick” to launch a Fireworks Script.
    <ul><li><a href="#" onclick="var r=4+parseInt(Math.random()*10);for(var i=r; i--;){setTimeout('createFirework(10,(Math.random()*15)+15,(Math.random()*3)+1,1,null,95,(Math.random()*85)+10,(Math.random()*10)+1,Math.random()>0.5,true)',(i+1)*(1+parseInt(Math.random()*800)));}return false" title="The Grand Finale!">Grand Finale!</a></li></ul>

  5. Important Div’s

    The Fireworks JavaScript also looks for certain divs that are required in order for the fireworks to launch. Just place this code inside the body. It can go pretty much anywhere, but in this example I have chosen to place this code at the end of the HTML document.
    <div id="sound">
    </div>
    <div id="fireworks-template">
    <div id="fw"></div>
    <div id="fp"><img src="image/particles.gif" alt="" /></div>
    </div>
    <div id="fireContainer"></div>
    </body>
    </html>

Testing

From here on out just use the Fireworks.js Hompage for testing firework variables and don’t forget the code below. It is a helpful guide…
createFirework(nRadius,nParticles,nCircles,burstType,startX,startY,burstX,burstY)

Posted in Blog, IWSS, Professional, Tutorial | Tagged , , , , , , , , | 7 Comments

7 Responses to Adding Fireworks to Your Blog

  1. ray says:

    Chris
    Nice implementation and nice tut. You should consider setting up a dummy page on your site to preserve it. You know, the internet is forever.

    • Geeb says:

      Thanks for the comment Ray.

      I was planning on putting some eater eggs on this page and the homepage for the actual 4th of July :) So come back and check it out! Glad you liked it.

  2. Way2learn says:

    Really well designed website -)

  3. Mahabub says:

    thanks for share this coding

  4. Roxanne says:

    I was recommended this web site by my cousin. I am not sure whether this
    post is written by him as nobody else know
    such detailed about my difficulty. You are amazing! Thanks!

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Like this post?

Subscribe to the RSS Feed or to Email Updates, right now!