aboutsummaryrefslogtreecommitdiff
path: root/viz.js
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-06-04 09:16:54 +0200
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:22:43 +0100
commit6a20c03a2d08bddfaeee23f4237d29f9bb67c7a2 (patch)
treeb39b72ae821d26160fc3ec37d968207d90b72195 /viz.js
parentd24dd97a0335b2fbd28d1b9bfed9c8f5d0d1f7af (diff)
Introduced common librairy into viz.js
Diffstat (limited to 'viz.js')
-rwxr-xr-xviz.js/convert.ml17
-rwxr-xr-xviz.js/dune2
-rwxr-xr-xviz.js/index.html2
3 files changed, 10 insertions, 11 deletions
diff --git a/viz.js/convert.ml b/viz.js/convert.ml
index 75c4fcd..68bf244 100755
--- a/viz.js/convert.ml
+++ b/viz.js/convert.ml
@@ -26,13 +26,6 @@ let on_result_svg
()
end
-let download data (filename : Js.js_string Js.t) (mime: Js.js_string Js.t)
- = Js.Unsafe.(
- fun_call (js_expr "download")
- [| inject data
- ; inject filename
- ; inject mime |])
-
(** Message send by the worker *)
type message = Process.t
type worker = (Js.js_string Js.t, message) Worker.worker Js.t
@@ -78,7 +71,10 @@ let load () =
(* Download the dot file *)
dot_button##.onclick := Dom_html.handler (fun _ev ->
- let _ = download input (Js.string "output.dot") (Js.string "text/plain") in
+ let _ = Elements.Transfert.send
+ ~mime_type:(Jstr.v "text/plain")
+ ~filename:(Jstr.v "output.dot")
+ (Obj.magic input) in
Js._false
);
@@ -86,7 +82,10 @@ let load () =
output_button##.onclick := Dom_html.handler (fun _->
(*download image*)
CanvasTool.generate_png image (fun image ->
- let _ = download image (Js.string "output.png") (Js.string "text/plain") in
+ let _ =
+ Elements.Transfert.send_raw
+ ~filename:(Jstr.v "output.png")
+ (Obj.magic image) in
()
);
Js._false
diff --git a/viz.js/dune b/viz.js/dune
index d6eba67..18ba438 100755
--- a/viz.js/dune
+++ b/viz.js/dune
@@ -5,6 +5,8 @@
js_of_ocaml-lwt
promise
process
+ elements
+ brr
)
(modes js)
(preprocess (pps js_of_ocaml-ppx))
diff --git a/viz.js/index.html b/viz.js/index.html
index abb158c..2c4952e 100755
--- a/viz.js/index.html
+++ b/viz.js/index.html
@@ -102,8 +102,6 @@
</div>
</div>
</div>
-
- <script src="download.js"></script>
<script src="convert.js"></script>
</body>
</html>