change @. -> @\n
This commit is contained in:
parent
8cd88d9880
commit
1377500bc9
4 changed files with 25 additions and 25 deletions
|
|
@ -12,14 +12,14 @@ module Leaflet = struct
|
||||||
|
|
||||||
(* create a map *)
|
(* create a map *)
|
||||||
let map =
|
let map =
|
||||||
log "creating map@.";
|
log "creating map@\n";
|
||||||
let open Brr in
|
let open Brr in
|
||||||
let _container = El.div ~at:At.[ id (Jstr.v "map") ] [] in
|
let _container = El.div ~at:At.[ id (Jstr.v "map") ] [] in
|
||||||
Jv.call leaflet "map" [| Jv.of_string "map" |]
|
Jv.call leaflet "map" [| Jv.of_string "map" |]
|
||||||
|
|
||||||
(* create map tile layer *)
|
(* create map tile layer *)
|
||||||
let tile_layer =
|
let tile_layer =
|
||||||
log "creating tile layer@.";
|
log "creating tile layer@\n";
|
||||||
Jv.call leaflet "tileLayer"
|
Jv.call leaflet "tileLayer"
|
||||||
[| Jv.of_string "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
[| Jv.of_string "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||||
; Jv.obj
|
; Jv.obj
|
||||||
|
|
@ -32,7 +32,7 @@ module Leaflet = struct
|
||||||
|
|
||||||
(* add tile layer *)
|
(* add tile layer *)
|
||||||
let () =
|
let () =
|
||||||
log "adding tile layer@.";
|
log "adding tile layer@\n";
|
||||||
let _map : Jv.t = Jv.call tile_layer "addTo" [| map |] in
|
let _map : Jv.t = Jv.call tile_layer "addTo" [| map |] in
|
||||||
()
|
()
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ module Leaflet = struct
|
||||||
(* set map's view *)
|
(* set map's view *)
|
||||||
(* try to set map's view to last position viewed by using web storage *)
|
(* try to set map's view to last position viewed by using web storage *)
|
||||||
let () =
|
let () =
|
||||||
log "setting view@.";
|
log "setting view@\n";
|
||||||
let lat = Brr_io.Storage.get_item storage (Jstr.of_string "lat") in
|
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 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
|
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 |]
|
ignore @@ Jv.call map "setView" [| latlng; Jv.of_int 13 |]
|
||||||
|
|
||||||
let on_moveend _event =
|
let on_moveend _event =
|
||||||
log "on moveend event@.";
|
log "on moveend event@\n";
|
||||||
let latlng = Jv.call map "getCenter" [||] in
|
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 :^) *)
|
(*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
|
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 |]
|
not @@ Jv.to_bool @@ Jv.call latlng "equals" [| wrapped_latlng |]
|
||||||
in
|
in
|
||||||
if is_wrapped then (
|
if is_wrapped then (
|
||||||
log "setView to wrapped coordinate@.";
|
log "setView to wrapped coordinate@\n";
|
||||||
(* warning: calling setView in on_moveend can cause recursion *)
|
(* warning: calling setView in on_moveend can cause recursion *)
|
||||||
ignore @@ Jv.call map "setView" [| wrapped_latlng |] ) )
|
ignore @@ Jv.call map "setView" [| wrapped_latlng |] ) )
|
||||||
|
|
||||||
let on_zoomend _event =
|
let on_zoomend _event =
|
||||||
log "on zoomend event@.";
|
log "on zoomend event@\n";
|
||||||
let zoom = Jv.call map "getZoom" [||] in
|
let zoom = Jv.call map "getZoom" [||] in
|
||||||
match
|
match
|
||||||
Brr_io.Storage.set_item storage (Jstr.of_string "zoom") (Jv.to_jstr zoom)
|
Brr_io.Storage.set_item storage (Jstr.of_string "zoom") (Jv.to_jstr zoom)
|
||||||
|
|
@ -92,14 +92,14 @@ module Leaflet = struct
|
||||||
| Ok () -> ()
|
| Ok () -> ()
|
||||||
|
|
||||||
let () =
|
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 "moveend"; Jv.repr on_moveend |];
|
||||||
ignore @@ Jv.call map "on" [| Jv.of_string "zoomend"; Jv.repr on_zoomend |]
|
ignore @@ Jv.call map "on" [| Jv.of_string "zoomend"; Jv.repr on_zoomend |]
|
||||||
end
|
end
|
||||||
|
|
||||||
module Geolocalize = struct
|
module Geolocalize = struct
|
||||||
let update_location geo =
|
let update_location geo =
|
||||||
log "update_location@.";
|
log "update_location@\n";
|
||||||
match geo with
|
match geo with
|
||||||
| Error _ -> failwith "error in geolocation"
|
| Error _ -> failwith "error in geolocation"
|
||||||
| Ok geo ->
|
| Ok geo ->
|
||||||
|
|
@ -111,7 +111,7 @@ module Geolocalize = struct
|
||||||
ignore @@ Jv.call Leaflet.map "setView" [| latlng; Jv.of_int 13 |]
|
ignore @@ Jv.call Leaflet.map "setView" [| latlng; Jv.of_int 13 |]
|
||||||
|
|
||||||
let geolocalize _ =
|
let geolocalize _ =
|
||||||
log "geolocalize@.";
|
log "geolocalize@\n";
|
||||||
let l = Brr_io.Geolocation.of_navigator Brr.G.navigator in
|
let l = Brr_io.Geolocation.of_navigator Brr.G.navigator in
|
||||||
ignore @@ Fut.await (Brr_io.Geolocation.get l) update_location
|
ignore @@ Fut.await (Brr_io.Geolocation.get l) update_location
|
||||||
|
|
||||||
|
|
@ -125,7 +125,7 @@ end
|
||||||
module Marker = struct
|
module Marker = struct
|
||||||
(*todo do this in js_babillard*)
|
(*todo do this in js_babillard*)
|
||||||
let marker_on_click thread_preview thread_id _e =
|
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_id = Jv.to_string thread_id in
|
||||||
let thread_preview_div = Jv.get Jv.global "thread_preview_div" in
|
let thread_preview_div = Jv.get Jv.global "thread_preview_div" in
|
||||||
ignore @@ Jv.set thread_preview_div "innerHTML" thread_preview;
|
ignore @@ Jv.set thread_preview_div "innerHTML" thread_preview;
|
||||||
|
|
@ -137,7 +137,7 @@ module Marker = struct
|
||||||
()
|
()
|
||||||
|
|
||||||
let on_each_feature feature layer =
|
let on_each_feature feature layer =
|
||||||
log "on_each_feature@.";
|
log "on_each_feature@\n";
|
||||||
let feature_properties = Jv.get feature "properties" in
|
let feature_properties = Jv.get feature "properties" in
|
||||||
let thread_preview = Jv.get feature_properties "content" in
|
let thread_preview = Jv.get feature_properties "content" in
|
||||||
let thread_id = Jv.get feature_properties "thread_id" in
|
let thread_id = Jv.get feature_properties "thread_id" in
|
||||||
|
|
@ -148,8 +148,8 @@ module Marker = struct
|
||||||
|]
|
|]
|
||||||
|
|
||||||
let handle_geojson geojson =
|
let handle_geojson geojson =
|
||||||
log "handle_geojson@.";
|
log "handle_geojson@\n";
|
||||||
log "feed geojson to leaflet@.";
|
log "feed geojson to leaflet@\n";
|
||||||
(* make markers unresponsive on newthread page*)
|
(* make markers unresponsive on newthread page*)
|
||||||
match Jv.find Jv.global "newthread" with
|
match Jv.find Jv.global "newthread" with
|
||||||
| None ->
|
| None ->
|
||||||
|
|
@ -163,12 +163,12 @@ module Marker = struct
|
||||||
()
|
()
|
||||||
|
|
||||||
let markers_handle_response response =
|
let markers_handle_response response =
|
||||||
log "markers_handle_response@.";
|
log "markers_handle_response@\n";
|
||||||
let geo_json_list_futur = Jv.call response "json" [||] in
|
let geo_json_list_futur = Jv.call response "json" [||] in
|
||||||
ignore @@ Jv.call geo_json_list_futur "then" [| Jv.repr handle_geojson |]
|
ignore @@ Jv.call geo_json_list_futur "then" [| Jv.repr handle_geojson |]
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
log "fetch thread geojson@.";
|
log "fetch thread geojson@\n";
|
||||||
let window = Jv.get Jv.global "window" in
|
let window = Jv.get Jv.global "window" in
|
||||||
let link = Jv.of_string "/markers" in
|
let link = Jv.of_string "/markers" in
|
||||||
let fetchfutur = Jv.call window "fetch" [| link |] in
|
let fetchfutur = Jv.call window "fetch" [| link |] in
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ let log = Format.printf
|
||||||
|
|
||||||
(* set input lat/lng when clicked and make new thread form visible *)
|
(* set input lat/lng when clicked and make new thread form visible *)
|
||||||
let on_click e =
|
let on_click e =
|
||||||
log "on_click@.";
|
log "on_click@\n";
|
||||||
|
|
||||||
let lat_lng = Jv.get e "latlng" in
|
let lat_lng = Jv.get e "latlng" in
|
||||||
ignore @@ Jv.call Leaflet.popup "setLatLng" [| lat_lng |];
|
ignore @@ Jv.call Leaflet.popup "setLatLng" [| lat_lng |];
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ let log = Format.printf
|
||||||
(* called by clicking post_id *)
|
(* called by clicking post_id *)
|
||||||
(* insert id into reply form *)
|
(* insert id into reply form *)
|
||||||
let insert_quote post_id _event =
|
let insert_quote post_id _event =
|
||||||
log "quote@.";
|
log "quote@\n";
|
||||||
Option.iter
|
Option.iter
|
||||||
(fun comment_textarea ->
|
(fun comment_textarea ->
|
||||||
let content = Jv.get comment_textarea "value" in
|
let content = Jv.get comment_textarea "value" in
|
||||||
|
|
@ -16,13 +16,13 @@ let insert_quote post_id _event =
|
||||||
Jv.undefined
|
Jv.undefined
|
||||||
|
|
||||||
let () =
|
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 document = Jv.get Jv.global "document" in
|
||||||
let quote_links =
|
let quote_links =
|
||||||
Jv.to_jv_list
|
Jv.to_jv_list
|
||||||
@@ Jv.call document "getElementsByClassName" [| Jv.of_string "quote-link" |]
|
@@ Jv.call document "getElementsByClassName" [| Jv.of_string "quote-link" |]
|
||||||
in
|
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 add_click quote_link =
|
||||||
let post_id =
|
let post_id =
|
||||||
Jv.call quote_link "getAttribute" [| Jv.of_string "data-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")
|
ignore @@ Jv.set el_style "display" (Jv.of_string "block")
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
log "change image description visibility@.";
|
log "change image description visibility@\n";
|
||||||
Option.iter
|
Option.iter
|
||||||
(fun file_input ->
|
(fun file_input ->
|
||||||
let alt_input = Jv.get Jv.global "alt" in
|
let alt_input = Jv.get Jv.global "alt" in
|
||||||
|
|
|
||||||
|
|
@ -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*)
|
(*change postImage class to make it bigger/smaller on click*)
|
||||||
let image_click post_image event =
|
let image_click post_image event =
|
||||||
log "image_click@.";
|
log "image_click@\n";
|
||||||
let current_class =
|
let current_class =
|
||||||
Jv.to_string @@ Jv.call post_image "getAttribute" [| Jv.of_string "class" |]
|
Jv.to_string @@ Jv.call post_image "getAttribute" [| Jv.of_string "class" |]
|
||||||
in
|
in
|
||||||
|
|
@ -30,7 +30,7 @@ let image_click post_image event =
|
||||||
ignore @@ Jv.call event "preventDefault" [||]
|
ignore @@ Jv.call event "preventDefault" [||]
|
||||||
|
|
||||||
let render_time date_span =
|
let render_time date_span =
|
||||||
log "render time@.";
|
log "render time@\n";
|
||||||
let t =
|
let t =
|
||||||
float_of_int
|
float_of_int
|
||||||
(Jv.to_int
|
(Jv.to_int
|
||||||
|
|
@ -44,7 +44,7 @@ let render_time date_span =
|
||||||
ignore @@ Jv.set date_span "innerHTML" (Jv.of_string date)
|
ignore @@ Jv.set date_span "innerHTML" (Jv.of_string date)
|
||||||
|
|
||||||
let make_pretty _event =
|
let make_pretty _event =
|
||||||
log "make pretty@.";
|
log "make pretty@\n";
|
||||||
let document = Jv.get Jv.global "document" in
|
let document = Jv.get Jv.global "document" in
|
||||||
|
|
||||||
let times =
|
let times =
|
||||||
|
|
@ -68,7 +68,7 @@ let make_pretty _event =
|
||||||
|
|
||||||
(*make pretty after page load*)
|
(*make pretty after page load*)
|
||||||
let () =
|
let () =
|
||||||
log "add load eventlistener to make pretty@.";
|
log "add load eventlistener to make pretty@\n";
|
||||||
let window = Jv.get Jv.global "window" in
|
let window = Jv.get Jv.global "window" in
|
||||||
ignore
|
ignore
|
||||||
@@ Jv.call window "addEventListener"
|
@@ Jv.call window "addEventListener"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue