package ojs_base
Install
Dune Dependency
Authors
Maintainers
Sources
md5=e706f1f9ec2f935d29c6b6e4832c8bdf
sha512=2596f6c59bea9c6b89923099c604a0e095a96880e7e91b06357e1de50867ae7e0261c87c35f608b7e426bddd6dd025a9868c07499287116ed458de4a0b9e9f30
doc/ojs_base.js/Ojs_js/index.html
Module Ojs_js
Source
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.
Log to JS console.
Helper function to read a messsage from a websocket frame data, using the given (json to msg) function.
Used to create ojs specific classes. class_ str
returns "ojs-"^str
.
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.
Get a DOM node by its 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_message :
?timeout:float ->
?cl:id ->
id ->
Js_of_ocaml.Dom.node Js_of_ocaml.Js.t list ->
unit