
    (function () {
  window["viewerLoader"] = window["viewerLoader"] || (function () {
    let executeOnReady = [];
    let notLoadedCount = 0;
    let scriptToLoad = [];

    let loader = {
      loadedStyles: function () {
        let existingCss = [];
    for (let i = 0; i < document.styleSheets.length; i++) {
          let css = document.styleSheets[i];
          let src = css.href;
          if (src != null) {
            existingCss.push(src);
          }
        }
        return existingCss;
      },
      addConstructorExecution: function (fn) {
        executeOnReady.push(fn);
      },
      getLoadedScripts: function () {
        let existingScripts = [];

    for (let i = 0; i < document.scripts.length; i++) {
          let script = document.scripts[i];
          let href = script.src;
          if (href != null) {
            existingScripts.push(href);
          }
        }
        return existingScripts;
      },
      addRequiredScripts: function (scripts, mobile) {
        if(!mobile && !loader.isBootstrapPresent()){
            notLoadedCount++;
            interval = window.setInterval(function(){
                if(loader.isBootstrapPresent()){
                    notLoadedCount--;
                    window.clearInterval(interval);
                    loader.excecuteOnReadyFn();
                }
            }, 50);
        }
        scripts.filter(function (script) {
          return loader.getLoadedScripts().indexOf(script) === -1;
        }).forEach(function (scriptSrc) {
          let script = document.createElement('script');
          script.async = false;
          notLoadedCount++;

        script.onload = function() {
            notLoadedCount--;
            loader.excecuteOnReadyFn();
          };
          script.async = false;
          script.src = scriptSrc;
          document.head.appendChild(script);
        });


      },
      excecuteOnReadyFn: function(){
        if(notLoadedCount==0){
          let current;
          while((current=executeOnReady.pop()) != null){
            current();
          }
        }
      },
      isBootstrapPresent: function(){
        return  typeof $ !='undefined' &&
                typeof $.fn !='undefined' &&
                typeof $.fn.tooltip !='undefined' &&
                typeof $.fn.tooltip.Constructor!='undefined' &&
                typeof $.fn.tooltip.Constructor.VERSION!='undefined';
      },
      addRequiredCss: function (styles) {
        styles.filter(function (s) {
          return loader.loadedStyles().indexOf(s) === -1;
        }).forEach(function (style) {
          let link = document.createElement('link');
          link.rel = 'stylesheet';
          link.type = 'text/css';
          link.href = style;
          link.media = 'all';
          document.head.appendChild(link);
        });
      }
    };

    return loader;
  })();

// viewer dependency loader
  let configuration ={"resources":{"script":["https://leopard.tu-braunschweig.de/modules/iview2/js/iview-client-base.min.js","https://leopard.tu-braunschweig.de/modules/iview2/js/iview-client-frame.min.js","https://leopard.tu-braunschweig.de/modules/iview2/js/iview-client-mets.min.js","https://leopard.tu-braunschweig.de/modules/iview2/js/iview-client-metadata.min.js","https://leopard.tu-braunschweig.de/js/digibib.js"],"css":["https://leopard.tu-braunschweig.de/modules/iview2/css/default.css","https://leopard.tu-braunschweig.de/rsc/sass/mir-layout/scss/flatmir-flatly.min.css"]},"properties":{"derivate":"dbbs_derivate_00019673","webApplicationBaseURL":"https://leopard.tu-braunschweig.de/","pdfCreatorFormatString":"{webApplicationBaseURL}/rsc/pdf/{derivate}?pages\u003d{pages}","lang":"de","permalink.updateHistory":false,"embedded":"true","chapter.showOnStart":false,"derivateURL":"https://leopard.tu-braunschweig.de/servlets/MCRFileNodeServlet/dbbs_derivate_00019673/","metsURL":"https://leopard.tu-braunschweig.de/servlets/MCRMETSServlet/dbbs_derivate_00019673","canvas.overview.enabled":true,"maximalPageScale":"4","i18nURL":"https://leopard.tu-braunschweig.de/rsc/locale/translate/{lang}/component.mets.*,component.viewer.*","filePath":"/max/00000001.jpg","mobile":false,"adminMail":"Publikationsserver der TU Braunschweig \u003cdigibib@tu-braunschweig.de\u003e","tileProviderPath":"https://leopard.tu-braunschweig.de/servlets/MCRTileServlet/","imageXmlPath":"https://leopard.tu-braunschweig.de/servlets/MCRTileServlet/","pdfCreatorURI":"https://www.tu-braunschweig.de/ub/","text.enabled":"true","doctype":"mets","metadataURL":"https://leopard.tu-braunschweig.de/receive/dbbs_mods_00040125?XSL.Transformer\u003dmycoreobject-viewer","canvas.startup.fitWidth":true,"objId":"dbbs_mods_00040125","pdfCreatorRestrictionFormatString":"{webApplicationBaseURL}/rsc/pdf/"}};

  viewerLoader.addRequiredCss(configuration.resources.css);
  viewerLoader.addRequiredScripts(configuration.resources.script, configuration.properties.mobile);
  viewerLoader.addConstructorExecution(function(){
          let container = jQuery("[data-viewer='"+configuration.properties.derivate+":"+CSS.escape(configuration.properties.filePath)+"']");
          new mycore.viewer.MyCoReViewer(container, configuration.properties);
  });

})
();
  