From 77544bdfad2af41514ec1435f706fee87ea2969e Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 7 Feb 2022 15:38:37 +0100 Subject: Added viz.js code --- elements/dune | 9 --------- elements/input.ml | 23 ----------------------- elements/prop.ml | 20 -------------------- elements/timer.ml | 38 -------------------------------------- elements/timer.mli | 11 ----------- elements/transfert.ml | 22 ---------------------- 6 files changed, 123 deletions(-) delete mode 100755 elements/dune delete mode 100755 elements/input.ml delete mode 100755 elements/prop.ml delete mode 100755 elements/timer.ml delete mode 100755 elements/timer.mli delete mode 100755 elements/transfert.ml (limited to 'elements') diff --git a/elements/dune b/elements/dune deleted file mode 100755 index 97d0753..0000000 --- a/elements/dune +++ /dev/null @@ -1,9 +0,0 @@ -(library - (name elements) - (libraries - brr - brr.note - js_of_ocaml - ) - (preprocess (pps ppx_hash js_of_ocaml-ppx)) -) diff --git a/elements/input.ml b/elements/input.ml deleted file mode 100755 index 6ae9aa8..0000000 --- a/elements/input.ml +++ /dev/null @@ -1,23 +0,0 @@ -open Brr -open Brr_note -open Note - -(** Create a slider element, and a signal with the value *) -let slider - : at:Brr.At.t list -> Brr.El.t * float S.t - - = fun ~at -> - let slider = - El.input ~at () in - - let init_value = (Jstr.to_float (El.prop El.Prop.value slider)) in - - let event = - Evr.on_el - Ev.input (fun _ -> - let raw_value = El.prop El.Prop.value slider in - Jstr.to_float raw_value) - slider - |> S.hold init_value - in - slider, event diff --git a/elements/prop.ml b/elements/prop.ml deleted file mode 100755 index 054864c..0000000 --- a/elements/prop.ml +++ /dev/null @@ -1,20 +0,0 @@ -open Brr - -include El.Prop - -let offsetWidth - : int t - = El.Prop.int (Jstr.v "offsetWidth") - -let offsetHeight - : int t - = El.Prop.int (Jstr.v "offsetHeight") - -let outerHTML - : Jstr.t t - = El.Prop.jstr (Jstr.v "outerHTML") - - -let value - : Jstr.t t - = El.Prop.jstr (Jstr.v "value") diff --git a/elements/timer.ml b/elements/timer.ml deleted file mode 100755 index 28516fc..0000000 --- a/elements/timer.ml +++ /dev/null @@ -1,38 +0,0 @@ -open Brr_note_kit - -type t = - { mutable id : Brr.G.timer_id - ; send : float Note.E.send - ; mutable counter : Time.counter - } - -let create - : unit -> (t * Brr_note_kit.Time.span Note.E.t) - = fun () -> - let event, send = Note.E.create () - and counter = (Time.counter ()) in - {id = (-1); send; counter}, event - -let stop - : t -> unit - = fun {id; _} -> - Brr.G.stop_timer id - -let start - : t -> float -> unit - = fun t d -> - let {id; send; _} = t in - t.counter <- Time.counter (); - - Brr.G.stop_timer id; - let timer_id = Brr.G.set_interval - ~ms:(int_of_float @@ d *. 1000.) - (fun () -> - - let span = Time.counter_value t.counter in - send span) in - t.id <- timer_id - - -let delay : t -> float - = fun t -> Time.counter_value t.counter diff --git a/elements/timer.mli b/elements/timer.mli deleted file mode 100755 index 0509ad0..0000000 --- a/elements/timer.mli +++ /dev/null @@ -1,11 +0,0 @@ -open Brr_note_kit - -type t - -val create : unit -> t * Time.span Note.E.t - -val start: t -> float -> unit - -val stop: t -> unit - -val delay : t -> float diff --git a/elements/transfert.ml b/elements/transfert.ml deleted file mode 100755 index ddeecd0..0000000 --- a/elements/transfert.ml +++ /dev/null @@ -1,22 +0,0 @@ -open Js_of_ocaml -open Brr - -let send - : mime_type:Jstr.t -> filename:Jstr.t -> Jstr.t -> unit - = fun ~mime_type ~filename content -> - let btoa = Jv.get Jv.global "btoa" in - let base64data = Jv.apply btoa - [| Jv.of_jstr content |] in - - let mime = (Jv.Id.(of_jv @@ to_jv mime_type)) - and base64 = (Jv.Id.(of_jv @@ to_jv base64data)) - in - - let data = (Js.string "data:")##concat_3 mime (Js.string ";base64,") base64 in - - (* Create the link to download the the element, and simulate a click on it *) - let a = El.a - ~at:At.[ href Jv.Id.(of_jv @@ to_jv data) - ; v (Jstr.v "download") filename ] - [] in - El.click a -- cgit v1.2.3