Irev-Dev / MRI-Volume-Slice

Tools for view MRI Volumes in the browser
6 stars 7 forks source link

fetch data from search param in URL #37

Closed Irev-Dev closed 6 years ago

Irev-Dev commented 6 years ago

Add functionality so that if a URL to a data set on openneuro.org is put in the URL as a search parameter than the app fetches that data to display.

I.e. mrislice.netlify.com/?https://openneuro.org/crn/datasets/ds001545/snapshots/1.0.0/files/sub-01:anat:sub-01_T1w.json will display data from https://openneuro.org/crn/datasets/ds001545/snapshots/1.0.0/files/sub-01:anat:sub-01_T1w.json

Instead of the hard coded dataset on line: 55 of 'script.js`

async function loadDefaultData() {
  const lastFile = await idb.get('LastNiftiFile');
  if (lastFile) return setupNifti(lastFile);
  const url = 'https://openneuro.org/crn/datasets/ds001417/files/sub-study002:ses-after:anat:sub-study002_ses-after_T1w.nii.gz';
  // load from the cache API or fetch if not found
let response;
 . . . 

hint: window.location.search will give you string following the ? in the url.

asifsha commented 6 years ago

Hello, I can do this.