about summary refs log tree commit diff stats
path: root/src/server
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-12 22:41:36 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-12 22:42:55 +0100
commit1960de266d72eb9f3b5c025f1325c116d8d09319 (patch)
treeff65ba7a1b696bdcfa3105d754a97199528e564f /src/server
parentc2bc54b88fdd0297255d21192f4936e3a9de0075 (diff)
downloadchawan-1960de266d72eb9f3b5c025f1325c116d8d09319.tar.gz
buffer: form fixes
* show submission URL on hover for all form-associated elements
* skip non-checked checkbox/radio inputs
Diffstat (limited to 'src/server')
-rw-r--r--src/server/buffer.nim26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim
index 7dcca52f..a5858e44 100644
--- a/src/server/buffer.nim
+++ b/src/server/buffer.nim
@@ -332,25 +332,19 @@ func canSubmitOnClick(fae: FormAssociatedElement): bool =
 proc getClickHover(styledNode: StyledNode): string =
   let clickable = styledNode.getClickable()
   if clickable != nil:
-    case clickable.tagType
-    of TAG_A:
+    if clickable of HTMLAnchorElement:
       return HTMLAnchorElement(clickable).href
-    of TAG_INPUT:
+    elif clickable of FormAssociatedElement:
       #TODO this is inefficient and also quite stupid
-      if clickable of FormAssociatedElement:
-        let fae = FormAssociatedElement(clickable)
-        if fae.canSubmitOnClick():
-          let req = fae.form.submitForm(fae)
-          if req.isSome:
-            return $req.get.url
-      return "<input>"
-    of TAG_OPTION:
+      let fae = FormAssociatedElement(clickable)
+      if fae.canSubmitOnClick():
+        let req = fae.form.submitForm(fae)
+        if req.isSome:
+          return $req.get.url
+      return "<" & $clickable.tagType & ">"
+    elif clickable of HTMLOptionElement:
       return "<option>"
-    of TAG_BUTTON:
-      return "<button>"
-    of TAG_TEXTAREA:
-      return "<textarea>"
-    else: discard
+  return ""
 
 func getCursorStyledNode(buffer: Buffer, cursorx, cursory: int): StyledNode =
   let i = buffer.lines[cursory].findFormatN(cursorx) - 1