Loading Algorithm - UniversalViewer/universalviewer GitHub Wiki

(proposal)

Load IIIF resource

    It's a manifest

        Parse manifest

    It's a collection

        A collection index has been passed

            There is a sub collection matching that index
    
                Load collections recursively until one containing manifests is found
                
                    A manifest index has been passed (defaults to 0)

                        There is a manifest matching that index

                            Parse manifest

                        There isn't a manifest matching that index

                            Throw error

                Finished recursion and no manifests were found

                    Throw error

            There isn't a sub collection matching that index

                Throw error

        A collection index hasn't been passed (undefined)

            The collection contains manifests

                A manifest index has been passed (defaults to 0)

                    There is a manifest matching that index
    
                        Parse manifest

                    There isn't a manifest matching that index

                        Throw error

            The collection doesn't contain manifests

                Load collections recursively until one containing manifests is found
                
                    A manifest index has been passed (defaults to 0)

                        There is a manifest matching that index

                            Parse manifest

                        There isn't a manifest matching that index

                            Throw error

                Finished recursion and no manifests were found

                    Throw error