diff options
author | Ben Sima <ben@bsima.me> | 2019-11-23 16:38:47 -0800 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-11-23 16:45:05 -0800 |
commit | 294c8e19b136f06ca7fa1bb4e4d109e90e2bb033 (patch) | |
tree | d8f56bdfc0451f9ad33e4ae396204bd0ba171d4d /Miso/FFI | |
parent | eb7e442d930bda88aac3c6aad0825b5aa4173e5e (diff) |
Add Com.MusicMeetsComics
Diffstat (limited to 'Miso/FFI')
-rw-r--r-- | Miso/FFI/Audio.hs | 20 | ||||
-rw-r--r-- | Miso/FFI/Document.hs | 11 | ||||
-rw-r--r-- | Miso/FFI/Fullscreen.hs | 28 |
3 files changed, 59 insertions, 0 deletions
diff --git a/Miso/FFI/Audio.hs b/Miso/FFI/Audio.hs new file mode 100644 index 0000000..e21ab57 --- /dev/null +++ b/Miso/FFI/Audio.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module Miso.FFI.Audio where + +import GHCJS.Types +import Protolude + +{- +Usage: + +obj <- Miso.FFI.Document.getElementById "myAudioPlayer" +play obj +pause obj + +-} + +foreign import javascript unsafe "$1.play();" + play :: JSVal -> IO () + +foreign import javascript unsafe "$1.pause();" + pause :: JSVal -> IO () diff --git a/Miso/FFI/Document.hs b/Miso/FFI/Document.hs new file mode 100644 index 0000000..f3a7bef --- /dev/null +++ b/Miso/FFI/Document.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module Miso.FFI.Document where + +import GHCJS.Types +import Protolude + +foreign import javascript unsafe "$r = document.getElementById($1);" + getElementById :: JSString -> IO JSVal + +foreign import javascript unsafe "$r = document.querySelector($1);" + querySelector :: JSString -> IO JSVal diff --git a/Miso/FFI/Fullscreen.hs b/Miso/FFI/Fullscreen.hs new file mode 100644 index 0000000..db2e37e --- /dev/null +++ b/Miso/FFI/Fullscreen.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module Miso.FFI.Fullscreen where + +import GHCJS.Types +import Protolude + +-- | Requests that the user agent switch from full-screen mode back to windowed +-- mode. Returns a Promise which is resolved once full-screen mode has been +-- completely shut off. +-- +-- https://developer.mozilla.org/en-US/docs/Web/API/Document/exitFullscreen +foreign import javascript unsafe "$r = document.exitFullscreen();" + exitFullscreen :: IO JSVal + +exit :: IO JSVal +exit = exitFullscreen + +-- | Asks the user agent to place the specified element (and, by extension, its +-- descendants) into full-screen mode, removing all of the browser's UI elements +-- as well as all other applications from the screen. Returns a Promise which is +-- resolved once full-screen mode has been activated. +-- +-- https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen +foreign import javascript unsafe "$r = $1.requestFullscreen();" + requestFullscreen :: JSVal -> IO JSVal + +request :: JSVal -> IO JSVal +request = requestFullscreen |