summaryrefslogtreecommitdiff
path: root/src/Utils.purs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-02-18 00:33:43 -0500
committerLLLL Colonq <llll@colonq>2025-02-18 00:33:43 -0500
commit12a8b6bb63ab52cd4828f16d26d94079fa576436 (patch)
treee5bc3783d8e9f17c5653aacb4576bda63a337dcb /src/Utils.purs
parentd03675f9effa443811f054578f7c24e17adbd6dc (diff)
Add throwshade
Diffstat (limited to 'src/Utils.purs')
-rw-r--r--src/Utils.purs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Utils.purs b/src/Utils.purs
index e4fd125..7be7be8 100644
--- a/src/Utils.purs
+++ b/src/Utils.purs
@@ -26,6 +26,7 @@ import Web.Event.EventTarget as Ev.Tar
import Web.HTML as HTML
import Web.HTML.HTMLDocument as HTML.Doc
import Web.HTML.HTMLInputElement as HTML.Input
+import Web.HTML.HTMLTextAreaElement as HTML.TextArea
import Web.HTML.Window as HTML.Win
maybeToArray :: forall a. Maybe a -> Array a
@@ -91,6 +92,11 @@ appendText parent s = do
setText :: forall m. MonadEffect m => DOM.Element -> String -> m Unit
setText e s = liftEffect $ DOM.Node.setTextContent s $ DOM.El.toNode e
+getTextArea :: forall m. MonadEffect m => DOM.Element -> m String
+getTextArea e = case HTML.TextArea.fromElement e of
+ Just inp -> liftEffect $ HTML.TextArea.value inp
+ Nothing -> liftEffect $ throw "element is not a text area"
+
getValue :: forall m. MonadEffect m => DOM.Element -> m String
getValue e = case HTML.Input.fromElement e of
Just inp -> liftEffect $ HTML.Input.value inp