From 25afb0bde9b8a2c064135a534231c232a461b341 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 16 Feb 2020 22:45:07 +0100 Subject: Set up a first version of tabata timer --- src/Dom/Document.ml | 4 ++++ src/Dom/Element.ml | 14 ++++++++++++++ src/Dom/Event.ml | 3 +++ src/Dom/EventTarget.ml | 1 + 4 files changed, 22 insertions(+) create mode 100644 src/Dom/Document.ml create mode 100644 src/Dom/Element.ml create mode 100644 src/Dom/Event.ml create mode 100644 src/Dom/EventTarget.ml (limited to 'src/Dom') diff --git a/src/Dom/Document.ml b/src/Dom/Document.ml new file mode 100644 index 0000000..afd1a84 --- /dev/null +++ b/src/Dom/Document.ml @@ -0,0 +1,4 @@ +external querySelector : string -> Dom.element option = "querySelector" + [@@bs.val] [@@bs.scope "document"] + +let querySelectorUnsafe id = querySelector id |> Js.Option.getExn diff --git a/src/Dom/Element.ml b/src/Dom/Element.ml new file mode 100644 index 0000000..4b38fa9 --- /dev/null +++ b/src/Dom/Element.ml @@ -0,0 +1,14 @@ +external setValue : Dom.element -> string -> unit = "value" [@@bs.set] + +external setInnerText : Dom.element -> string -> unit = "innerText" [@@bs.set] + +external setStyle : Dom.element -> string -> unit = "style" [@@bs.set] + +external setClassName : Dom.element -> string -> unit = "className" [@@bs.set] + +external setAttribute : Dom.element -> string -> string -> unit = "setAttribute" + [@@bs.send] + +external addEventListener : Dom.element -> string -> (Dom.event -> unit) -> unit + = "addEventListener" + [@@bs.send] diff --git a/src/Dom/Event.ml b/src/Dom/Event.ml new file mode 100644 index 0000000..bffd242 --- /dev/null +++ b/src/Dom/Event.ml @@ -0,0 +1,3 @@ +external preventDefault : Dom.event -> unit = "preventDefault" [@@bs.send] + +external target : Dom.event -> Dom.eventTarget = "target" [@@bs.get] diff --git a/src/Dom/EventTarget.ml b/src/Dom/EventTarget.ml new file mode 100644 index 0000000..946a518 --- /dev/null +++ b/src/Dom/EventTarget.ml @@ -0,0 +1 @@ +external value : Dom.eventTarget -> string option = "value" [@@bs.get] -- cgit v1.2.3