Skip to content

Instantly share code, notes, and snippets.

@ccapndave
Created March 29, 2016 15:40
Show Gist options
  • Save ccapndave/721d42912f9a6497d790 to your computer and use it in GitHub Desktop.
Save ccapndave/721d42912f9a6497d790 to your computer and use it in GitHub Desktop.
window.photoFieldOnChange = function(id, fileList, incomingPort) {
if (!app.ports[incomingPort])
return console.error(`Unknown incoming port: ${incomingPort}`);
if (fileList.length !== 1)
return console.error(`Illegal fileList length ${fileList.length}`);
const file = fileList[0];
const objectURL = window.URL.createObjectURL(file);
app.ports[incomingPort].send([ id, objectURL ]);
};
view : { id : String, incomingPort : String } -> Signal.Address Action -> Model -> Html
view context address model =
input
[ type' "file"
, title " "
, accept "image/*"
, attribute "capture" "true"
, attribute "onchange" ("window.photoFieldOnChange(\"" ++ context.id ++ "\", this.files, \"" ++ context.incomingPort ++ "\")")
] []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment