add emojid

This commit is contained in:
Swrup 2022-03-23 04:34:54 +01:00
parent ccba00b2e7
commit 4dd63360a2
7 changed files with 5082 additions and 9 deletions

View file

@ -1,16 +1,17 @@
let log = Format.printf
(* called by clicking post_id *)
(* insert id into reply form *)
let insert_quote post_id _event =
(* insert emojid into reply form *)
let insert_quote emojid _event =
log "quote@\n";
Option.iter
(fun textarea ->
let content = Jv.to_string @@ Jv.get textarea "value" in
let new_content =
if String.ends_with ~suffix:"\n" content || String.length content = 0
then Format.sprintf "%s>>%s " content post_id
else Format.sprintf "%s@\n>>%s " content post_id
then (* don't skip a line *)
Format.sprintf "%s[%s] " content emojid
else Format.sprintf "%s@\n[%s] " content emojid
in
ignore @@ Jv.set textarea "value" (Jv.of_string new_content) )
Jv.(find global "reply-comment")
@ -24,13 +25,13 @@ let () =
in
log "quote_links leng %d@\n" (List.length quote_links);
let add_click quote_link =
let post_id =
let emojid =
Jv.to_string
@@ Jv.call quote_link "getAttribute" [| Jv.of_string "data-id" |]
@@ Jv.call quote_link "getAttribute" [| Jv.of_string "data-emojid" |]
in
ignore
@@ Jv.call quote_link "addEventListener"
[| Jv.of_string "click"; Jv.repr (insert_quote post_id) |]
[| Jv.of_string "click"; Jv.repr (insert_quote emojid) |]
in
List.iter add_click quote_links