dist/crocodoc.viewer.js
function pageLoadLoop() {
        var index;
        clearTimeout(pageLoadTID);
        if (pageLoadQueue.length > 0) {
            // found a page to load
            index = pageLoadQueue.shift();
            // page exists and not reached max errors?
            if (pages[index]) {
                api.loadPage(index, function loadPageCallback(pageIsLoading) {
                    if (pageIsLoading === false) {
                        // don't wait if the page is not loading
                        pageLoadLoop();
                    } else {
                        pageLoadTID = setTimeout(pageLoadLoop, PAGE_LOAD_INTERVAL);
                    }
                });
            } else {
                pageLoadLoop();
            }
        } else {
            stopPageLoadLoop();
        }
    }
function pageLoadLoop() {
        var index;
        clearTimeout(pageLoadTID);
        if (pageLoadQueue.length > 0) {
            // found a page to load
            index = pageLoadQueue.shift();
            // page exists and not reached max errors?
            if (pages[index]) {
                api.loadPage(index, function loadPageCallback(pageIsLoading) {
                    if (pageIsLoading === false) {
                        // don't wait if the page is not loading
                        pageLoadLoop();
                    } else {
                        pageLoadTID = setTimeout(pageLoadLoop, PAGE_LOAD_INTERVAL);
                    }
                });
            } else {
                pageLoadLoop();
            }
        } else {
            stopPageLoadLoop();
        }
    }
function pageLoadLoop ( ) { var index ; clearTimeout ( pageLoadTID ) ; if ( pageLoadQueue . length > 0 ) { // found a page to load index = pageLoadQueue . shift ( ) ; // page exists and not reached max errors? if ( pages [ index ] ) { api . loadPage ( index , function loadPageCallback ( pageIsLoading ) { if ( pageIsLoading === false ) { // don't wait if the page is not loading pageLoadLoop ( ) ; } else { pageLoadTID = setTimeout ( pageLoadLoop , PAGE_LOAD_INTERVAL ) ; } } ) ; } else { pageLoadLoop ( ) ; } } else { stopPageLoadLoop ( ) ; } }
Loop through the pageLoadQueue and load pages sequentially,
setting a timeout to run again after PAGE_LOAD_INTERVAL ms
until the queue is empty
@returns {void}
@private
Loop through the pageLoadQueue and load pages sequentially setting a timeout to run again after PAGE_LOAD_INTERVAL ms until the queue is empty