Created
March 29, 2016 15:40
-
-
Save ccapndave/721d42912f9a6497d790 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ]); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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