geochan/src/js/js_post_form.ml

38 lines
1.2 KiB
OCaml
Raw Normal View History

let log = Format.printf
(* called by clicking post_id *)
(* insert id into reply form *)
let insert_quote post_id =
log "quote@.";
2022-02-18 01:37:25 +01:00
Option.iter
(fun comment_textarea ->
let content = Jv.get comment_textarea "value" in
let new_content =
Jv.call content "concat"
[| Jv.of_string "\n>>"; post_id; Jv.of_string " " |]
in
ignore @@ Jv.set comment_textarea "value" new_content )
Jv.(find global "replyComment");
Jv.undefined
let () = Jv.set Jv.global "insert_quote" (Jv.repr insert_quote)
(* make image description field visible when a file is selected*)
let make_visible el _event =
let el_style = Jv.get el "style" in
2022-02-18 01:37:25 +01:00
ignore @@ Jv.set el_style "display" (Jv.of_string "block")
let () =
log "change image description visibility@.";
2022-02-18 01:37:25 +01:00
Option.iter
(fun 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) |];
ignore
@@ Jv.call file_input "addEventListener"
[| Jv.of_string "change"; Jv.repr (make_visible alt_label) |] )
Jv.(find global "file")