Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit 676fd06

Browse files
authored
Merge pull request #78 from justinwoo/add-blob-actions
Add Blob URL actions `(create|revoke)ObjectURL`
2 parents 1212818 + e1d0682 commit 676fd06

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

src/DOM/HTML/Types.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module DOM.HTML.Types
33
( Navigator
44
, Location
55
, History
6+
, URL
67
, Window
78
, ALERT
89
, CONFIRM
@@ -231,6 +232,8 @@ foreign import data Window :: *
231232

232233
foreign import data History :: *
233234

235+
foreign import data URL :: *
236+
234237
foreign import data ALERT :: !
235238

236239
foreign import data HISTORY :: !

src/DOM/HTML/URL.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
3+
exports.createObjectURL = function (fileOrBlob) {
4+
return function (URL) {
5+
return function () {
6+
return URL.createObjectURL(fileOrBlob);
7+
};
8+
};
9+
};
10+
11+
exports.revokeObjectURL = function (objectURL) {
12+
return function (URL) {
13+
return function () {
14+
return URL.revokeObjectURL(objectURL);
15+
};
16+
};
17+
};

src/DOM/HTML/URL.purs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module DOM.HTML.URL
2+
( createObjectURL
3+
, revokeObjectURL
4+
) where
5+
6+
import Control.Monad.Eff (Eff)
7+
import DOM (DOM)
8+
import DOM.File.Types (File)
9+
import DOM.HTML.Types (URL)
10+
import Data.Unit (Unit)
11+
12+
foreign import createObjectURL :: forall eff. File -> URL -> Eff (dom :: DOM | eff) String
13+
14+
foreign import revokeObjectURL :: forall eff. String -> URL -> Eff (dom :: DOM | eff) Unit

src/DOM/HTML/Window.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,9 @@ exports.scrollY = function (window) {
181181
return window.scrollY;
182182
};
183183
};
184+
185+
exports.url = function (window) {
186+
return function () {
187+
return window.URL;
188+
};
189+
};

src/DOM/HTML/Window.purs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ module DOM.HTML.Window
2222
, scrollBy
2323
, scrollX
2424
, scrollY
25+
, url
2526
) where
2627

2728
import Control.Monad.Eff (Eff)
2829
import DOM (DOM)
29-
import DOM.HTML.Types (ALERT, CONFIRM, HISTORY, HTMLDocument, History, Location, Navigator, PROMPT, WINDOW, Window)
30+
import DOM.HTML.Types (ALERT, CONFIRM, HISTORY, HTMLDocument, History, Location, Navigator, PROMPT, WINDOW, Window, URL)
3031
import Data.Maybe (Maybe)
3132
import Data.Nullable (Nullable, toMaybe)
3233
import Prelude (Unit, (<$>))
@@ -39,6 +40,8 @@ foreign import location :: forall eff. Window -> Eff (dom :: DOM | eff) Location
3940

4041
foreign import history :: forall e. Window -> Eff (history :: HISTORY | e) History
4142

43+
foreign import url :: forall eff. Window -> Eff (dom :: DOM | eff) URL
44+
4245
foreign import innerWidth :: forall eff. Window -> Eff (dom :: DOM | eff) Int
4346

4447
foreign import innerHeight :: forall eff. Window -> Eff (dom :: DOM | eff) Int
@@ -52,7 +55,7 @@ foreign import moveBy :: forall eff. Int -> Int -> Window -> Eff (window :: WIND
5255
foreign import moveTo :: forall eff. Int -> Int -> Window -> Eff (window :: WINDOW | eff) Unit
5356

5457
open :: forall eff. String -> String -> String -> Window -> Eff (window :: WINDOW | eff) (Maybe Window)
55-
open window url name features = toMaybe <$> _open window url name features
58+
open window url' name features = toMaybe <$> _open window url' name features
5659

5760
foreign import _open
5861
:: forall eff

0 commit comments

Comments
 (0)