From 2e92b2e59b543c4c20f52295ef3913f229ed20d3 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Mon, 25 Nov 2024 23:30:16 -0500 Subject: Redeem submit --- flake.nix | 1 + main.css | 9 +++++++++ src/Main.purs | 7 +++++++ src/UI.js | 16 ++++++++++++++++ src/UI.purs | 6 ++++++ templates/api/menu.html | 13 +++++++++++++ 6 files changed, 52 insertions(+) diff --git a/flake.nix b/flake.nix index beedd35..e8249ea 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,7 @@ "web-html" "web-dom" "web-uievents" + "web-xhr" "canvas" "argonaut" "fetch" diff --git a/main.css b/main.css index b173959..f4ab83e 100644 --- a/main.css +++ b/main.css @@ -298,6 +298,9 @@ a.lcolonq-button-link :active { padding-left: 1rem; padding-right: 1rem; padding-bottom: 1rem; + display: flex; + flex-direction: column; + user-select: none; } .lcolonq-menu-box:hover { @@ -314,6 +317,12 @@ a.lcolonq-button-link :active { grid-row-end: span 2; } +.lcolonq-menu-box textarea { + resize: none; + margin-top: 1rem; + flex: 1; +} + /* auth */ .lcolonq-auth { position: absolute; diff --git a/src/Main.purs b/src/Main.purs index 7897b49..983a805 100644 --- a/src/Main.purs +++ b/src/Main.purs @@ -37,6 +37,7 @@ import Web.HTML as HTML import Web.HTML.HTMLDocument as HTML.Doc import Web.HTML.HTMLInputElement as HTML.Input import Web.HTML.Window as HTML.Win +import Web.XHR.FormData as FD maybeToArray :: forall a. Maybe a -> Array a maybeToArray (Just x) = [x] @@ -228,6 +229,12 @@ mainRegister = launchAff_ do mainMenu :: Effect Unit mainMenu = launchAff_ do liftEffect $ log "hello from menu" + textareas <- queryAll "textarea" + for_ textareas \ta -> listen ta "click" Ev.stopPropagation + boxes <- queryAll ".lcolonq-menu-box" + for_ boxes \box -> do + listen box "click" \_ev -> do + UI.submitRedeem box mainAuth :: Effect Unit mainAuth = launchAff_ do diff --git a/src/UI.js b/src/UI.js index b27b10b..5f1aaa0 100644 --- a/src/UI.js +++ b/src/UI.js @@ -1,9 +1,25 @@ export const _cheatLog = (a) => () => console.log(a); export const _setInterval = (delay) => (f) => () => setInterval(f, delay); export const _toJSON = (x) => JSON.stringify(x); + export const _reload = () => { window.location.reload(); }; + export const _redirect = (url) => () => { window.location.href = url; }; + +export const _submitRedeem = (url) => (el) => () => { + const redeem = el.children[0].textContent; + const inp = el.children[1]?.value; + console.log(redeem, inp); + const data = new FormData(); + data.append("ayem", "test"); + data.append("name", redeem); + data.append("input", inp); + fetch(url, { + method: "post", + body: data, + }); +}; diff --git a/src/UI.purs b/src/UI.purs index ac4d694..a01422f 100644 --- a/src/UI.purs +++ b/src/UI.purs @@ -1,8 +1,10 @@ module UI where import Prelude +import Config as Config import Effect (Effect) import Effect.Class (class MonadEffect, liftEffect) +import Web.DOM.Element as DOM.El foreign import _cheatLog :: forall a. a -> Effect Unit cheatLog :: forall m a. MonadEffect m => a -> m Unit @@ -23,3 +25,7 @@ reload = liftEffect _reload foreign import _redirect :: String -> Effect Unit redirect :: forall m. MonadEffect m => String -> m Unit 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.apiServer <> "/redeem") el diff --git a/templates/api/menu.html b/templates/api/menu.html index b8e8673..b5d32b8 100644 --- a/templates/api/menu.html +++ b/templates/api/menu.html @@ -50,6 +50,7 @@ CONFIG_SUBST bread sandwich enriched with extra iron. the latest and greatest. read all about it. +

cycle gizmos

@@ -66,6 +67,7 @@ CONFIG_SUBST long pork. cooked at table. optional floral garnish. +

deslug

@@ -117,33 +119,39 @@ CONFIG_SUBST izakaya fare par excellence. human sacrifices not included. go ask the tengu. +

bells of bezelea

bronze and dreamstuff. mountain thyme garnish. ϕιλία. +

palette swap (eyes)

it is eyes. what did you expect. +

palette swap (hair)

it is hair. what did you expect. +

palette swap (highlight)

it is highlight. what did you expect. +

hex

wiedźmin geralt z rivii. zwany również białym wilkiem. zwalcza zagrażające ludziom potwory. +

antipiracy

@@ -164,6 +172,7 @@ CONFIG_SUBST stuffed inside a freshly-hunted pheasant. stuffed inside a freshly-hunted grouse. boiled. +

gamer

@@ -186,24 +195,28 @@ CONFIG_SUBST or maybe it depends on the moon phase. we play this one by ear. surprise. +

feed friend

hamburber colon three. are these still funny. i love you. +

show friend wikipedia page

copper ore and longing. big red donation prompt. free. +

friend composes song

one hundred and fifty tiny singing birds. they've never heard of salt. before. +
-- cgit v1.2.3