Skip to content

Commit

Permalink
Locators to loaders rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Tevemadar committed Mar 19, 2024
1 parent 92cabcb commit efb13f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ async function transformSeries(series) {
document.getElementById("nlcolor").value="#00FFFF";
}

const locators = {
const loaders = {
/**
* Provide the link of an actual QuickNII/VisuAlign JSON.
* <br>
* This demo simply passes the complete URL, no transformation is done
* @param {string} series_id <code>series</code> URL parameter
* @returns {string}
*/
SeriesLocator: async series_id => fetch(series_id).then(response => response.json()),
SeriesLoader: async series_id => fetch(series_id).then(response => response.json()),
/**
* Provide the link of an actual DZI descriptor.
* <br>
Expand All @@ -45,7 +45,7 @@ const locators = {
* @param {string} section_id <code>filename</code> field of a section
* @returns {string}
*/
DZILocator: async section_id => fetch(`${args.pyramids}/${section_id}.tif/${section_id}.dzi`).then(response => response.text()),
DZILoader: async section_id => fetch(`${args.pyramids}/${section_id}.tif/${section_id}.dzi`).then(response => response.text()),
/**
* Provide the link of an actual image tile.
* <br>
Expand All @@ -59,7 +59,7 @@ const locators = {
* @param {type} format <code>Format</code> field (from the DZI descriptor, usually "png" or "jpg")
* @returns {string}
*/
TileLocator: async (section_id, level, x, y, format) => {
TileLoader: async (section_id, level, x, y, format) => {
const img = document.createElement("img");
await new Promise(resolve => {
img.onload = resolve;
Expand All @@ -73,12 +73,12 @@ const locators = {
* @param {type} atlas_id <code>atlas</code> URL parameter
* @returns {string}
*/
AtlasLocator: async atlas_id => fetch(atlas_id + ".json").then(response => response.json()),
AtlasLoader: async atlas_id => fetch(atlas_id + ".json").then(response => response.json()),
/**
* Provide the link of the atlas descriptor, atlas data is often just next to LocaliZoom,
* and appending a .pack extension is enough
* @param {type} atlas_id <code>atlas</code> URL parameter
* @returns {string}
*/
AtlasVolumeLocator: async atlas_id => fetch(atlas_id + ".pack").then(response => response.arrayBuffer())
AtlasVolumeLoader: async atlas_id => fetch(atlas_id + ".pack").then(response => response.arrayBuffer())
};
8 changes: 4 additions & 4 deletions filmstrip.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var filmstrip={};

var volumeready=false;
this.start=async function(){
initvol(await locators.AtlasVolumeLocator(args.atlas),volumeReady);
initvol(await loaders.AtlasVolumeLoader(args.atlas),volumeReady);
};
// async function volumeReady(event){
// cover();
Expand All @@ -31,7 +31,7 @@ var filmstrip={};
cover();
volumeready=true;
//metahack=event.target.response;//.slices;
metahack=await locators.SeriesLocator(args.series);
metahack=await loaders.SeriesLoader(args.series);
await transformSeries(metahack);
var slices=metahack.slices;
propagation.propagate(slices);
Expand Down Expand Up @@ -130,7 +130,7 @@ var filmstrip={};
ctx.fillRect(x*160-pos+20-10,20,128+10+10,128);
}
if(item.icon===null){
item.icon=locators.DZILocator(item.id).then(async dzi=>{
item.icon=loaders.DZILoader(item.id).then(async dzi=>{
// item.icon=new XMLHttpRequest();
// item.icon.open("GET",locators.DZILocator(item.id));
// item.icon.onload=function(event){
Expand All @@ -153,7 +153,7 @@ var filmstrip={};
width=(width+1)>>1;
height=(height+1)>>1;
}
item.icon=await locators.TileLocator(item.id,maxlevel-level,0,0,doc.getAttribute("Format"));
item.icon=await loaders.TileLoader(item.id,maxlevel-level,0,0,doc.getAttribute("Format"));
redraw();
// var img=document.createElement("img");
// img.onload=function(event){
Expand Down
6 changes: 3 additions & 3 deletions filmstripzoom.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
// var atlas;
// function descriptorReady(event){
// atlas=event.target.response;
atlas = await locators.AtlasLocator(args.atlas);
atlas = await loaders.AtlasLoader(args.atlas);
for(var label of atlas.labels)
if(label.rgb){
label.r=parseInt(label.rgb.substr(0,2),16);
Expand Down Expand Up @@ -372,7 +372,7 @@
// xhr.open("GET",locators.DZILocator(section_id));
// xhr.onload=xmlReady;
// xhr.send();
locators.DZILocator(section_id).then(dzi=>xmlReady(dzi));
loaders.DZILoader(section_id).then(dzi=>xmlReady(dzi));
}

var overlay=document.createElement("canvas");
Expand Down Expand Up @@ -444,7 +444,7 @@
// return locators.TileLocator(section_id,this.MaxLevel-level,x,y,cfg.Format);
// };
cfg.Load = async function (level, x, y) {
const img = await locators.TileLocator(section_id, cfg.MaxLevel-level, x, y, cfg.Format);
const img = await loaders.TileLoader(section_id, cfg.MaxLevel-level, x, y, cfg.Format);
const canvas = document.createElement("canvas");
canvas.width = cfg.TileSize;
canvas.height = cfg.TileSize;
Expand Down

0 comments on commit efb13f4

Please sign in to comment.