summaryrefslogtreecommitdiff
path: root/src
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
parentd03675f9effa443811f054578f7c24e17adbd6dc (diff)
Add throwshade
Diffstat (limited to 'src')
-rw-r--r--src/Main.purs2
-rw-r--r--src/Main/Throwshade.purs18
-rw-r--r--src/UI.js4
-rw-r--r--src/UI.purs4
-rw-r--r--src/Utils.purs6
5 files changed, 34 insertions, 0 deletions
diff --git a/src/Main.purs b/src/Main.purs
index 6fff10b..34ca80b 100644
--- a/src/Main.purs
+++ b/src/Main.purs
@@ -14,6 +14,7 @@ import Main.Menu as Menu
import Main.OBS as OBS
import Main.Pubnix as Pubnix
import Main.Register as Register
+import Main.Throwshade as Throwshade
main :: Effect Unit
main = case Config.mode of
@@ -26,4 +27,5 @@ main = case Config.mode of
"menu" -> Menu.main
"auth" -> Auth.main
"greencircle" -> Greencircle.main
+ "throwshade" -> Throwshade.main
_ -> throw $ "unknown mode: " <> Config.mode
diff --git a/src/Main/Throwshade.purs b/src/Main/Throwshade.purs
new file mode 100644
index 0000000..ad1ad2c
--- /dev/null
+++ b/src/Main/Throwshade.purs
@@ -0,0 +1,18 @@
+module Main.Throwshade where
+
+import Prelude
+
+import Effect (Effect)
+import Effect.Class (liftEffect)
+import Effect.Console (log)
+import UI (setShader)
+import Utils (byId, getTextArea, listen)
+
+main :: Effect Unit
+main = do
+ liftEffect $ log "hello it is throwshade"
+ input <- byId "lcolonq-throwshade-textarea"
+ test <- byId "lcolonq-throwshade-button-test"
+ listen test "click" \_ -> do
+ s <- getTextArea input
+ setShader s
diff --git a/src/UI.js b/src/UI.js
index c5089e6..a6dd0fa 100644
--- a/src/UI.js
+++ b/src/UI.js
@@ -22,3 +22,7 @@ export const _submitRedeem = (url) => (el) => () => {
body: data,
});
};
+
+export const _setShader = (shader) => () => {
+ window.wasmBindings.set_shader(shader);
+};
diff --git a/src/UI.purs b/src/UI.purs
index 3da0814..44117a0 100644
--- a/src/UI.purs
+++ b/src/UI.purs
@@ -29,3 +29,7 @@ redirect url = liftEffect $ _redirect url
foreign import _submitRedeem :: String -> DOM.El.Element -> Effect Unit
submitRedeem :: forall m. MonadEffect m => DOM.El.Element -> m Unit
submitRedeem el = liftEffect $ _submitRedeem (Config.secureApiServer <> "/redeem") el
+
+foreign import _setShader :: String -> Effect Unit
+setShader :: forall m. MonadEffect m => String -> m Unit
+setShader s = liftEffect $ _setShader s
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