Ojs_js
JS utilities
Replace a referenced map by the same map with an additional binding.
Replace a referenced map by the same map minus a binding.
Helper 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 option
setup_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.
Send data on the given websocket.
Remove all children of a DOM node.
val gen_id : unit -> id
gen_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) -> unit
set_onclick node f
sets f
as callback to "onclick" event on node
.
Separate the given string according to the given list of characters.
get_classes node
returns the list of classes associated to this element (by splitting on spaces in the class attribute).
node_unset_class node cl
removes the given class cl
from the given DOM element.
node_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_error : id -> Js_of_ocaml.Dom.#node Js_of_ocaml.Js.t list -> unit