Start pagina

JavaScript


Blog lezen

The source-code for the javascript used on this site.

You can also download the file (you might need to choose "Save link as...", depending on your browser).


/*
    Copyright (c) 2005 Joost Diepenmaat, Zeekat Softwareontwikkeling, 
    all rights reserved.

    Permission is hereby granted, free of charge, to any person obtaining 
    a copy of this software and associated documentation files (the 
    "Software"), to deal in the Software without restriction, including 
    without limitation the rights to use, copy, modify, merge, publish, 
    distribute, sublicense, and/or sell copies of the Software, and to 
    permit persons to whom the Software is furnished to do so, subject to 
    the following conditions:

    The above copyright notice and this permission notice shall be included
    in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
    OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
    OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


/*
    this function is called when the html document is loaded
*/

function documentLoaded() {
    animateMarkers();
}



/*
    this function searches for all <span> elements with class "activemarker"
    and animates them. moving the from the right, 6 pixels to the left and back,
    as determined by the positions array. the animation stops when all positions
    have been played.

    activemarker spans should have "position: relative" specified in their style
*/

function animateMarkers() {
    if (document.getElementsByTagName && setTimeout) {
        var markers = new Array();
        var spans = document.getElementsByTagName("span"); 
        for(var i=0;i<spans.length;i++) {
            if(spans[i].className == 'activemarker')  {
                var marker = spans[i].style || spans[i];
                if (marker) {
                    markers.push(marker);
                }
            }
        }
        if (markers.length > 0) {
            var frameCount = 0;
            var positions = new Array( 6,3,1,0,1,3,6,4,3,4,6,5,6 ); /* boing */
            var markerFrame = function() {
                for (var i = 0; i < markers.length; i++) {
                    markers[i].left = positions[frameCount] + "px";
                }
                if (++frameCount < positions.length ) {
                    setTimeout(markerFrame,60);
                }
            }
            setTimeout(markerFrame,200);
        }
    }
}