Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,33 @@ async function handleFiles(files) {

return rawData;
}

(function jsonFromUrl() {
// json via jsonUrl query param

// Extract the 'jsonUrl' parameter from the URL
const urlParams = new URLSearchParams(window.location.search);
const jsonUrl = urlParams.get('jsonUrl');

console.log({ jsonUrl });

// Updated logic: run this on page load
if (jsonUrl) {
fetch(jsonUrl)
.then((res) => {
if (!res.ok) throw new Error('Failed to fetch');
return res.text(); // or .json() if you want parsed object
})
.then((text) => {
// Create a File object (only if your handleFiles requires it)
const blob = new Blob([text], { type: 'application/json' });
const file = new File([blob], 'remote.json', { type: 'application/json' });

// Call handleFiles directly, bypassing the input altogether
handleFiles([file]).finally(destroyProgressBars).then(init);
})
.catch((error) => {
console.error(`Could not load JSON from URL ${jsonUrl}`, error);
});
}
})();
Loading