examples/lib/timeline/timeline.js
function loadAll (urls, callback, sendCallbackWhenAlreadyLoaded) {
        // list all urls which are not yet loaded
        var urlsLeft = [];
        urls.forEach(function (url) {
            if (!isLoaded(url)) {
                urlsLeft.push(url);
            }
        });

        if (urlsLeft.length) {
            // there are unloaded images
            var countLeft = urlsLeft.length;
            urlsLeft.forEach(function (url) {
                load(url, function () {
                    countLeft--;
                    if (countLeft == 0) {
                        // done!
                        callback();
                    }
                }, sendCallbackWhenAlreadyLoaded);
            });
        }
        else {
            // we are already done!
            if (sendCallbackWhenAlreadyLoaded) {
                callback();
            }
        }
    }
function loadAll (urls, callback, sendCallbackWhenAlreadyLoaded) {
        // list all urls which are not yet loaded
        var urlsLeft = [];
        urls.forEach(function (url) {
            if (!isLoaded(url)) {
                urlsLeft.push(url);
            }
        });

        if (urlsLeft.length) {
            // there are unloaded images
            var countLeft = urlsLeft.length;
            urlsLeft.forEach(function (url) {
                load(url, function () {
                    countLeft--;
                    if (countLeft == 0) {
                        // done!
                        callback();
                    }
                }, sendCallbackWhenAlreadyLoaded);
            });
        }
        else {
            // we are already done!
            if (sendCallbackWhenAlreadyLoaded) {
                callback();
            }
        }
    }
function loadAll ( urls , callback , sendCallbackWhenAlreadyLoaded ) { // list all urls which are not yet loaded var urlsLeft = [ ] ; urls . forEach ( function ( url ) { if ( ! isLoaded ( url ) ) { urlsLeft . push ( url ) ; } } ) ; if ( urlsLeft . length ) { // there are unloaded images var countLeft = urlsLeft . length ; urlsLeft . forEach ( function ( url ) { load ( url , function ( ) { countLeft -- ; if ( countLeft == 0 ) { // done! callback ( ) ; } } , sendCallbackWhenAlreadyLoaded ) ; } ) ; } else { // we are already done! if ( sendCallbackWhenAlreadyLoaded ) { callback ( ) ; } } }
Load a set of images, and send a callback as soon as all images are
loaded
@param {String[]} urls
@param {function } callback
@param {boolean} sendCallbackWhenAlreadyLoaded
Load a set of images and send a callback as soon as all images are loaded