let demoFiles = []; let counter = 0; const getDemoFileNames = function () { let demoFileList = []; for (let i = 1; i < 25; i++) { let filename = "anon" + i; demoFileList.push(filename); } return demoFileList; }; // init all larvitar.initializeImageLoader(); larvitar.registerResliceLoader(); larvitar.initializeCSTools(); larvitar.store.initialize(); larvitar.store.addViewport("viewer-base"); larvitar.store.addViewport("viewer-reslice"); async function createFile(fileName, cb) { let response = await fetch("./demo/" + fileName); let data = await response.blob(); let file = new File([data], fileName); demoFiles.push(file); counter++; if (counter == 24) { cb(); } } function renderSerie() { larvitar .readFiles(demoFiles) .then(seriesStack => { // render the first series of the study let seriesId = _.keys(seriesStack)[0]; let serie = seriesStack[seriesId]; larvitar.populateLarvitarManager(seriesId, serie); larvitar.renderImage(serie, "viewer-base").then(() => { console.log("Image axial has been rendered"); }); larvitar.cacheImages(serie, function (resp) { if (resp.loading == 100) { larvitar.resliceSeries(serie, "coronal").then(data => { larvitar.renderImage(data, "viewer-reslice").then(() => { console.log("Image resliced has been rendered"); }); larvitar.addDefaultTools(); larvitar.setToolActive("Wwwc"); }); } }); }) .catch(err => console.log(err)); } let demoFileList = getDemoFileNames(); _.each(demoFileList, function (demoFile) { createFile(demoFile, renderSerie); });