add all event from ocaml

This commit is contained in:
Swrup 2022-02-18 18:31:55 +01:00
parent 01e62889e2
commit ad460ee549
8 changed files with 52 additions and 15 deletions

View file

@ -101,12 +101,16 @@ module Geolocalize = struct
in
ignore @@ Jv.call Leaflet.map "setView" [| latlng; Jv.of_int 13 |]
let geolocalize () =
let geolocalize _ =
log "geolocalize@.";
let l = Brr_io.Geolocation.of_navigator Brr.G.navigator in
ignore @@ Fut.await (Brr_io.Geolocation.get l) update_location
let () = Jv.set Jv.global "geolocalize" (Jv.repr geolocalize)
let () =
let button = Jv.get Jv.global "geolocalize" in
ignore
@@ Jv.call button "addEventListener"
[| Jv.of_string "click"; Jv.repr geolocalize |]
end
module Marker = struct

View file

@ -2,7 +2,7 @@ let log = Format.printf
(* called by clicking post_id *)
(* insert id into reply form *)
let insert_quote post_id =
let insert_quote post_id _event =
log "quote@.";
Option.iter
(fun comment_textarea ->
@ -15,7 +15,23 @@ let insert_quote post_id =
Jv.(find global "replyComment");
Jv.undefined
let () = Jv.set Jv.global "insert_quote" (Jv.repr insert_quote)
let () =
log "add inser_quote event on post links@.";
let document = Jv.get Jv.global "document" in
let quote_links =
Jv.to_jv_list
@@ Jv.call document "getElementsByClassName" [| Jv.of_string "quoteLink" |]
in
log "quote_links leng %d@." (List.length quote_links);
let add_click quote_link =
let post_id =
Jv.call quote_link "getAttribute" [| Jv.of_string "data-id" |]
in
ignore
@@ Jv.call quote_link "addEventListener"
[| Jv.of_string "click"; Jv.repr (insert_quote post_id) |]
in
List.iter add_click quote_links
(* make image description field visible when a file is selected*)
let make_visible el _event =

View file

@ -43,7 +43,7 @@ let render_time date_span =
in
ignore @@ Jv.set date_span "innerHTML" (Jv.of_string date)
let make_pretty _ =
let make_pretty _event =
log "make pretty@.";
let document = Jv.get Jv.global "document" in