EMOJIIIIIIIIIIIIIIIII XD

This commit is contained in:
zapashcanon 2023-04-05 22:27:13 +02:00
parent 2e63f44d33
commit 54f310be88
Signed by untrusted user who does not match committer: zapashcanon
GPG Key ID: 8981C3C62D1D28F1
6 changed files with 26 additions and 24 deletions

View File

@ -5,4 +5,4 @@
(action
(with-stdout-to
%{target}
(cat ../../../js/client.bc.js))))
(run cat ../../../js/client.bc.js))))

View File

@ -9,7 +9,6 @@
caqti-driver-sqlite3
directories
dream
emoji
fpath
lambdasoup
lwt

View File

@ -20,10 +20,11 @@ let ws =
(* listen for close event *)
let () =
let on_close _e = log "Websocket closed!@\n" in
Ev.listen Websocket.Ev.close on_close (Websocket.as_target ws)
let _listener : Ev.listener = Ev.listen Websocket.Ev.close on_close (Websocket.as_target ws) in
()
let jv_to_pos : Geolocation.Pos.t -> Msg.pos =
fun o ->
fun o ->
let open Geolocation.Pos in
{ latitude = latitude o
; longitude = longitude o
@ -46,35 +47,36 @@ let () =
let _watch_id = Geo.watch_geolocation send in
()
in
Ev.listen Ev.open' on_open (Websocket.as_target ws)
let _listener : Ev.listener = Ev.listen Ev.open' on_open (Websocket.as_target ws) in
()
module Camel = struct
open Leaflet
let friends = Hashtbl.create 5
let latlng
pos =
Latlng.create pos.Msg.latitude pos.longitude
let latlng
pos =
Latlng.create pos.Msg.latitude pos.longitude
let create
pos =
let create
pos =
log "Camel.create@\n";
(* TODO size/ better icon / make it rotate on direction *)
let html =
Format.sprintf {|<div class="marker">%s</div>|} Emoji.camel |> Option.some
Format.sprintf {|<div class="marker">%s</div>|} "WOOF" |> Option.some
in
let icon = Icon.create_div ~html ~bg_pos:None [] in
let layer = Layer.create_marker (latlng pos) [ Icon icon ] in
Layer.add_to Geo.map layer;
layer
let move_to
let move_to
geo dromedary = Layer.set_latlng (latlng geo) dromedary
geo dromedary = Layer.set_latlng (latlng geo) dromedary
let kill_friend
dromedary = Layer.remove dromedary
dromedary = Layer.remove dromedary
let find_opt = Hashtbl.find_opt friends
@ -96,4 +98,5 @@ let () =
| None -> Camel.add id pos
| Some friend -> Camel.move_to pos friend
in
Ev.listen Message.Ev.message on_message (Websocket.as_target ws)
let _ev : Ev.listener = Ev.listen Message.Ev.message on_message (Websocket.as_target ws) in
()

View File

@ -1,7 +1,7 @@
(executable
(name client)
(modules client)
(libraries brr emoji leaflet geo msg utils)
(libraries brr leaflet geo msg utils)
(modes js))
(library

View File

@ -19,12 +19,12 @@ let save_view () =
match Brr_io.Storage.set_item storage (Jstr.v "lat") lat with
| (exception Jv.Error _) | Error _ -> failwith "can't set latlng storage"
| Ok () -> (
match Brr_io.Storage.set_item storage (Jstr.v "lng") lng with
| (exception Jv.Error _) | Error _ -> failwith "can't set latlng storage"
| Ok () -> (
match Brr_io.Storage.set_item storage (Jstr.v "zoom") zoom with
| (exception Jv.Error _) | Error _ -> failwith "can't set zoom storage"
| Ok () -> () ) )
match Brr_io.Storage.set_item storage (Jstr.v "lng") lng with
| (exception Jv.Error _) | Error _ -> failwith "can't set latlng storage"
| Ok () -> (
match Brr_io.Storage.set_item storage (Jstr.v "zoom") zoom with
| (exception Jv.Error _) | Error _ -> failwith "can't set zoom storage"
| Ok () -> () ) )
(* wrap Leaflet.Map.set_view to save last position to storage *)
let set_view latlng ~zoom =
@ -88,7 +88,7 @@ let watch_geolocation f =
let lng = Pos.longitude geo in
let latlng = Latlng.create lat lng in
set_view latlng ~zoom:None
(* TODO update/make camel marker on the map *)
(* TODO update/make camel marker on the map *)
in
(* watch l ~opts f monitors the position of l determined with opts by periodically calling f. Stop watching by calling unwatch with the returned identifier. *)

View File

@ -11,4 +11,4 @@ let find_by_id id =
let add_event_to_class event name handler =
let el_list = El.find_by_class (Jstr.of_string name) in
List.iter (fun el -> Ev.listen event (handler el) (El.as_target el)) el_list
List.iter (fun el -> let _listener : Ev.listener = Ev.listen event (handler el) (El.as_target el) in ()) el_list