open Brr let str = Jstr.v let str_of_error e = Jv.of_error e |> Jv.to_string (* redefine At module? *) let class' j = At.class' (str j) let id j = At.id (str j) let href j = At.href (str j) let src j = At.src (str j) let alt j = At.v (str "alt") (str j) let title j = At.title (str j) let type' j = At.type' (str j) let name j = At.name (str j) let value j = At.value (str j) let mk_at k v = At.v (str k) (str v) let el_txt s = El.txt (str s) let h1 s = El.h1 [ el_txt s ] let h2 s = El.h2 [ el_txt s ] let window = G.window let window_as_target = Window.as_target window let window_jv = Jv.get Jv.global "window" let window_width () = Jv.get window_jv "innerWidth" |> Jv.to_float let window_height () = Jv.get window_jv "innerHeight" |> Jv.to_float let document = G.document let document_as_target = Document.as_target document let body = Document.body document let find_html_el_by_id id = Document.find_el_by_id G.document (Jstr.of_string id) let get_bounds el = let x = El.bound_x el in let y = El.bound_y el in let w = El.bound_w el in let h = El.bound_h el in (x, y, w, h) let clamp ~min ~max x = Float.max (Float.min max x) min (* -- Note util -- *) open Note open Note_brr let def_visibility (visibility : [ `On | `Off ]) b_s el = match visibility with | `On -> Elr.def_class (str "off") (S.map not b_s) el | `Off -> Elr.def_class (str "off") b_s el let def_disabled b_s el = Elr.def_at At.Name.disabled (S.map (function true -> Some (Jstr.v "") | false -> None) b_s) el let hold_on el ev_type f = let event = Evr.on_el ev_type Fun.id el in Elr.may_hold_logr el (E.log event f); () let hold_event_on el event f = Elr.may_hold_logr el (E.log event f); () let hold_endless f e = Logr.may_hold (E.log e f) let hold_endless_on_window ev_type f = let event = Evr.on_target ev_type Fun.id window_as_target in hold_endless f event; ()