change @. -> @\n

This commit is contained in:
Swrup 2022-02-19 00:59:01 +01:00
parent 8cd88d9880
commit 1377500bc9
4 changed files with 25 additions and 25 deletions

View file

@ -12,14 +12,14 @@ module Leaflet = struct
(* create a map *)
let map =
log "creating map@.";
log "creating map@\n";
let open Brr in
let _container = El.div ~at:At.[ id (Jstr.v "map") ] [] in
Jv.call leaflet "map" [| Jv.of_string "map" |]
(* create map tile layer *)
let tile_layer =
log "creating tile layer@.";
log "creating tile layer@\n";
Jv.call leaflet "tileLayer"
[| Jv.of_string "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
; Jv.obj
@ -32,7 +32,7 @@ module Leaflet = struct
(* add tile layer *)
let () =
log "adding tile layer@.";
log "adding tile layer@\n";
let _map : Jv.t = Jv.call tile_layer "addTo" [| map |] in
()
@ -41,7 +41,7 @@ module Leaflet = struct
(* set map's view *)
(* try to set map's view to last position viewed by using web storage *)
let () =
log "setting view@.";
log "setting view@\n";
let lat = Brr_io.Storage.get_item storage (Jstr.of_string "lat") in
let lng = Brr_io.Storage.get_item storage (Jstr.of_string "lng") in
let zoom = Brr_io.Storage.get_item storage (Jstr.of_string "zoom") in
@ -58,7 +58,7 @@ module Leaflet = struct
ignore @@ Jv.call map "setView" [| latlng; Jv.of_int 13 |]
let on_moveend _event =
log "on moveend event@.";
log "on moveend event@\n";
let latlng = Jv.call map "getCenter" [||] in
(*we need to wrap coordinates so we don't drift into a parralel universe and lose track of markers :^) *)
let wrapped_latlng = Jv.call map "wrapLatLng" [| latlng |] in
@ -78,12 +78,12 @@ module Leaflet = struct
not @@ Jv.to_bool @@ Jv.call latlng "equals" [| wrapped_latlng |]
in
if is_wrapped then (
log "setView to wrapped coordinate@.";
log "setView to wrapped coordinate@\n";
(* warning: calling setView in on_moveend can cause recursion *)
ignore @@ Jv.call map "setView" [| wrapped_latlng |] ) )
let on_zoomend _event =
log "on zoomend event@.";
log "on zoomend event@\n";
let zoom = Jv.call map "getZoom" [||] in
match
Brr_io.Storage.set_item storage (Jstr.of_string "zoom") (Jv.to_jstr zoom)
@ -92,14 +92,14 @@ module Leaflet = struct
| Ok () -> ()
let () =
log "add on (move/zoom)end event@.";
log "add on (move/zoom)end event@\n";
ignore @@ Jv.call map "on" [| Jv.of_string "moveend"; Jv.repr on_moveend |];
ignore @@ Jv.call map "on" [| Jv.of_string "zoomend"; Jv.repr on_zoomend |]
end
module Geolocalize = struct
let update_location geo =
log "update_location@.";
log "update_location@\n";
match geo with
| Error _ -> failwith "error in geolocation"
| Ok geo ->
@ -111,7 +111,7 @@ module Geolocalize = struct
ignore @@ Jv.call Leaflet.map "setView" [| latlng; Jv.of_int 13 |]
let geolocalize _ =
log "geolocalize@.";
log "geolocalize@\n";
let l = Brr_io.Geolocation.of_navigator Brr.G.navigator in
ignore @@ Fut.await (Brr_io.Geolocation.get l) update_location
@ -125,7 +125,7 @@ end
module Marker = struct
(*todo do this in js_babillard*)
let marker_on_click thread_preview thread_id _e =
log "marker_on_click@.";
log "marker_on_click@\n";
let thread_id = Jv.to_string thread_id in
let thread_preview_div = Jv.get Jv.global "thread_preview_div" in
ignore @@ Jv.set thread_preview_div "innerHTML" thread_preview;
@ -137,7 +137,7 @@ module Marker = struct
()
let on_each_feature feature layer =
log "on_each_feature@.";
log "on_each_feature@\n";
let feature_properties = Jv.get feature "properties" in
let thread_preview = Jv.get feature_properties "content" in
let thread_id = Jv.get feature_properties "thread_id" in
@ -148,8 +148,8 @@ module Marker = struct
|]
let handle_geojson geojson =
log "handle_geojson@.";
log "feed geojson to leaflet@.";
log "handle_geojson@\n";
log "feed geojson to leaflet@\n";
(* make markers unresponsive on newthread page*)
match Jv.find Jv.global "newthread" with
| None ->
@ -163,12 +163,12 @@ module Marker = struct
()
let markers_handle_response response =
log "markers_handle_response@.";
log "markers_handle_response@\n";
let geo_json_list_futur = Jv.call response "json" [||] in
ignore @@ Jv.call geo_json_list_futur "then" [| Jv.repr handle_geojson |]
let () =
log "fetch thread geojson@.";
log "fetch thread geojson@\n";
let window = Jv.get Jv.global "window" in
let link = Jv.of_string "/markers" in
let fetchfutur = Jv.call window "fetch" [| link |] in

View file

@ -5,7 +5,7 @@ let log = Format.printf
(* set input lat/lng when clicked and make new thread form visible *)
let on_click e =
log "on_click@.";
log "on_click@\n";
let lat_lng = Jv.get e "latlng" in
ignore @@ Jv.call Leaflet.popup "setLatLng" [| lat_lng |];

View file

@ -3,7 +3,7 @@ let log = Format.printf
(* called by clicking post_id *)
(* insert id into reply form *)
let insert_quote post_id _event =
log "quote@.";
log "quote@\n";
Option.iter
(fun comment_textarea ->
let content = Jv.get comment_textarea "value" in
@ -16,13 +16,13 @@ let insert_quote post_id _event =
Jv.undefined
let () =
log "add inser_quote event on post links@.";
log "add inser_quote event on post links@\n";
let document = Jv.get Jv.global "document" in
let quote_links =
Jv.to_jv_list
@@ Jv.call document "getElementsByClassName" [| Jv.of_string "quote-link" |]
in
log "quote_links leng %d@." (List.length quote_links);
log "quote_links leng %d@\n" (List.length quote_links);
let add_click quote_link =
let post_id =
Jv.call quote_link "getAttribute" [| Jv.of_string "data-id" |]
@ -39,7 +39,7 @@ let make_visible el _event =
ignore @@ Jv.set el_style "display" (Jv.of_string "block")
let () =
log "change image description visibility@.";
log "change image description visibility@\n";
Option.iter
(fun file_input ->
let alt_input = Jv.get Jv.global "alt" in

View file

@ -13,7 +13,7 @@ let to_string = function Small -> "post-image" | Big -> "post-image-big"
(*change postImage class to make it bigger/smaller on click*)
let image_click post_image event =
log "image_click@.";
log "image_click@\n";
let current_class =
Jv.to_string @@ Jv.call post_image "getAttribute" [| Jv.of_string "class" |]
in
@ -30,7 +30,7 @@ let image_click post_image event =
ignore @@ Jv.call event "preventDefault" [||]
let render_time date_span =
log "render time@.";
log "render time@\n";
let t =
float_of_int
(Jv.to_int
@ -44,7 +44,7 @@ let render_time date_span =
ignore @@ Jv.set date_span "innerHTML" (Jv.of_string date)
let make_pretty _event =
log "make pretty@.";
log "make pretty@\n";
let document = Jv.get Jv.global "document" in
let times =
@ -68,7 +68,7 @@ let make_pretty _event =
(*make pretty after page load*)
let () =
log "add load eventlistener to make pretty@.";
log "add load eventlistener to make pretty@\n";
let window = Jv.get Jv.global "window" in
ignore
@@ Jv.call window "addEventListener"