Published
Edited
Nov 4, 2020
1 fork
Importers
7 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// to compute the result one could use:
/*
result = f && f.text ? await f.text() : f
*/
// or pipe it directly to an editable viewof:
Insert cell
Insert cell
Insert cell
async function fileuploader(options = {}) {
const form = Object.assign(file(options), {
value: options.remoteFile ? undefined : options.default
});

if (options.remoteFile)
fetch(options.remoteFile)
.then(f => {
form.value = f;
form.dispatchEvent(new CustomEvent("input", { bubbles: true }));
})
.catch(e => {
form.value = e;
form.dispatchEvent(new CustomEvent("input", { bubbles: true }));
});

form.className = "fileuploader";
form.appendChild(style());

return form;
}
Insert cell
remoteFiles = [
"https://gist.githubusercontent.com/Fil/ec3acdf4ba5149daa14eae9d047f09d6/raw/ac75b7298f9dc4115f2e459126d90461473266bf/test1.txt",
"https://gist.githubusercontent.com/Fil/ec3acdf4ba5149daa14eae9d047f09d6/raw/ac75b7298f9dc4115f2e459126d90461473266bf/test2.json",
"not-an-url:error"
]
Insert cell
import { file, select, text, textarea } from "@jashkenas/inputs"
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more