add alt text field

This commit is contained in:
Swrup 2022-01-25 14:07:28 +01:00
parent 7272ede2ca
commit 44bacabfbd
7 changed files with 198 additions and 129 deletions

View file

@ -105,3 +105,24 @@ let on_click e =
let () =
ignore
@@ Jv.call Leaflet.map "on" [| Jv.of_string "click"; Jv.repr on_click |]
(*!Duplicate*)
(* make image description field visible when a file is selected*)
let make_visible alt_input alt_label _event =
let alt_style = Jv.get alt_input "style" in
let alt_label_style = Jv.get alt_label "style" in
ignore @@ Jv.set alt_style "display" (Jv.of_string "block");
ignore @@ Jv.set alt_label_style "display" (Jv.of_string "block");
()
let () =
let file_input = Jv.find Jv.global "file" in
match file_input with
| None -> () (*not post form on the page, not logged in*)
| Some file_input ->
let alt_input = Jv.get Jv.global "alt" in
let alt_label = Jv.get Jv.global "altLabel" in
ignore
@@ Jv.call file_input "addEventListener"
[| Jv.of_string "change"; Jv.repr (make_visible alt_input alt_label) |];
()