function loadSketchImages()

in toolkit/jb/shared.js [107:139]


function loadSketchImages(p, onComplete) {
    showLoaderAt(0);
    imagesToLoad.forEach(function(imgSpec, index) {
        if (cachedImages[imgSpec.id] || imagesErrors[imgSpec.id]) return;
        var img = new Image();
        //console.log('start loading image', imgSpec.id);
        img.onload = function() {
            //console.log('received', imgSpec.path);
            cachedImages[imgSpec.id] = img;
            readyImgCount++;
            //console.log('images ready:', readyImgCount + '/' + imagesToLoad.length);
            showLoaderAt(readyImgCount / imagesToLoad.length, 'Loading Images');
            if (readyImgCount == imagesToLoad.length) {
                if (onComplete) onComplete();
                hideLoader();
                //console.log('finished loading images');
            }
        };
        img.onerror = function() {
            imagesErrors[imgSpec.id] = true;
            //console.log('image at ' + imgSpec.path + ' failed to load');
            readyImgCount++;
            //console.log('images ready:', readyImgCount + '/' + imagesToLoad.length);
            showLoaderAt(readyImgCount / imagesToLoad.length, 'Loading Images');
            if (readyImgCount == imagesToLoad.length) {
                if (onComplete) onComplete();
                hideLoader();
                //console.log('finished loading images');
            }
        };
        img.src = imgSpec.path;
    });
}