Ojs_jsJS utilities
Replace a referenced map by the same map with an additional binding.
val mk_msg_of_wsdata :
(Yojson.Safe.t -> ('a, string) result) ->
string ->
'a optionHelper function to read a messsage from a websocket frame data, using the given (json to msg) function.
val setup_ws :
string ->
(string -> 'a option) ->
onopen:(Js_of_ocaml.WebSockets.webSocket Js_of_ocaml.Js.t -> 'c) ->
onmessage:(Js_of_ocaml.WebSockets.webSocket Js_of_ocaml.Js.t -> 'a -> 'd) ->
Js_of_ocaml.WebSockets.webSocket Js_of_ocaml.Js.t optionsetup_ws url msg_of_data ~onopen ~onmessage opens a websocket connection to the given url, using msg_of_data to read messages and pass them to the onmessage handler. onopen is called when the websocket is open.
val send_msg :
Js_of_ocaml.WebSockets.webSocket Js_of_ocaml.Js.t ->
string ->
unitSend data on the given websocket.
val clear_children : Js_of_ocaml.Dom.node Js_of_ocaml.Js.t -> unitRemove all children of a DOM node.
val node_by_id : string -> Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.tGet a DOM node by its id.
val gen_id : unit -> idgen_id() returns a new id prefixed by "ojsid". This is useful to create unique node ids when creating nodes in the DOM.
val set_onclick :
Js_of_ocaml.Dom_html.eventTarget Js_of_ocaml.Js.t ->
(Js_of_ocaml.Dom_html.mouseEvent Js_of_ocaml.Js.t -> 'a) ->
unitset_onclick node f sets f as callback to "onclick" event on node.
Separate the given string according to the given list of characters.
val get_classes : Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t -> string listget_classes node returns the list of classes associated to this element (by splitting on spaces in the class attribute).
val node_unset_class :
Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t ->
string ->
unitnode_unset_class node cl removes the given class cl from the given DOM element.
val node_set_class :
Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t ->
string ->
unitnode_set_class node cl adds the given class cl from the given DOM element, if it is not present yet.
unset_class ~id cl is the same as node_unset_class but use the given id to retrieve the element.
set_class ~id cl is the same as node_set_class but use the given id to retrieve the element.
val display_message :
?timeout:float ->
?cl:id ->
id ->
Js_of_ocaml.Dom.node Js_of_ocaml.Js.t list ->
unitval display_error : id -> Js_of_ocaml.Dom.node Js_of_ocaml.Js.t list -> unit