diff options
| author | LLLL Colonq <llll@colonq> | 2025-04-15 21:10:01 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-04-15 21:10:01 -0400 |
| commit | b31fd7881f8da11dbdd1cc259907b535d96a47a4 (patch) | |
| tree | 1829fe570e53a0876990c6056da6f71880b65493 /src/Main/Gizmo.purs | |
| parent | bd1256504b6154c7d9b8feb0fefb6755b11586ee (diff) | |
Add gizmo page
Diffstat (limited to 'src/Main/Gizmo.purs')
| -rw-r--r-- | src/Main/Gizmo.purs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Main/Gizmo.purs b/src/Main/Gizmo.purs new file mode 100644 index 0000000..e728e66 --- /dev/null +++ b/src/Main/Gizmo.purs @@ -0,0 +1,34 @@ +module Main.Gizmo where + +import Prelude + +import Config as Config +import Data.Foldable (for_) +import Data.String (Pattern(..), split) +import Data.String as String +import Effect (Effect) +import Effect.Aff (launchAff_) +import Effect.Class (class MonadEffect, liftEffect) +import Effect.Console (log) +import Fetch (fetch) +import UI (addOption, onInput, startBufferRefresh) +import Utils (byId, getSelectValue, setIFrameSrc) + +loadBuffer :: forall m. MonadEffect m => String -> m Unit +loadBuffer nm = do + contents <- byId "lcolonq-gizmo-contents" + setIFrameSrc (Config.apiServer <> "/gizmo?buf=" <> nm) contents + +main :: Effect Unit +main = launchAff_ do + liftEffect $ log "hello from gizmo" + select <- byId "lcolonq-gizmo-select" + onInput select \d -> loadBuffer d + { text: text } <- fetch (Config.apiServer <> "/gizmo/list") {} + glist <- text + for_ (split (Pattern "\n") glist) \buf -> do + when (not $ String.null buf) $ addOption buf select + initial <- getSelectValue =<< byId "lcolonq-gizmo-select" + loadBuffer initial + contents <- byId "lcolonq-gizmo-contents" + startBufferRefresh contents |
