diff --git a/examples/README.md b/examples/README.md index 874256517..842b7ba6b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -10,4 +10,17 @@ Or a single one: $> dune build @examples//default ``` +Add the `--profile wasm` option to compile to Wasm: +``` +$> dune build @examples/boulderdash/default --profile wasm +``` + Compilation artifacts can be found in `${REPO_ROOT}/_build/default/examples/`. + +When generating JavaScript code, you can directly open the +`index.html` files in a browser. When generating Wasm code, you need +to serve the files, for instance with the following command: +``` +python -m http.server -d _build/default/examples/boulderdash/ +``` +and then open `http://localhost:8000` in a browser. diff --git a/examples/boulderdash/boulderdash.ml b/examples/boulderdash/boulderdash.ml index f5d0f8b5a..c2b1bc962 100644 --- a/examples/boulderdash/boulderdash.ml +++ b/examples/boulderdash/boulderdash.ml @@ -326,7 +326,7 @@ let http_get url = let msg = r.XmlHttpRequest.content in if cod = 0 || cod = 200 then Lwt.return msg else fst (Lwt.wait ()) -let getfile f = try Lwt.return (Sys_js.read_file ~name:f) with Not_found -> http_get f +let getfile f = try Lwt.return (Sys_js.read_file ~name:f) with Sys_error _ -> http_get f exception Eos @@ -507,8 +507,4 @@ let start _ = Dom.appendChild body div; Lwt.return () -let _ = - Html.window##.onload := - Html.handler (fun _ -> - ignore (start ()); - Js._false) +let () = Lwt.async start diff --git a/examples/boulderdash/dune b/examples/boulderdash/dune index 952ee4939..3f26cd2f5 100644 --- a/examples/boulderdash/dune +++ b/examples/boulderdash/dune @@ -1,30 +1,25 @@ (executables (names boulderdash) (libraries js_of_ocaml-lwt) - (modes byte) + (modes js wasm) + (js_of_ocaml + (flags :standard --file %{dep:maps.txt} --file maps)) + (link_deps + (glob_files maps/*.map)) (preprocess (pps js_of_ocaml-ppx))) (rule - (targets boulderdash.js) - (deps - (glob_files maps/*.map)) (action - (run - %{bin:js_of_ocaml} - --source-map - %{dep:boulderdash.bc} - -o - %{targets} - --pretty - --file - %{dep:maps.txt} - --file - maps))) + (copy boulderdash.bc.wasm.js boulderdash.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) (alias (name default) (deps - boulderdash.js + boulderdash.bc.js index.html + maps.txt + (glob_files maps/*.map) (glob_files sprites/*.{png,svg}))) diff --git a/examples/boulderdash/index.html b/examples/boulderdash/index.html index 1ccdf3e96..fcd89ea7d 100644 --- a/examples/boulderdash/index.html +++ b/examples/boulderdash/index.html @@ -5,7 +5,7 @@ Boulder Dash - + diff --git a/examples/cubes/dune b/examples/cubes/dune index 56d43c509..f945ab2f6 100644 --- a/examples/cubes/dune +++ b/examples/cubes/dune @@ -1,21 +1,16 @@ (executables (names cubes) (libraries js_of_ocaml-lwt) - (modes byte) + (modes js wasm) (preprocess (pps js_of_ocaml-ppx))) (rule - (targets cubes.js) (action - (run - %{bin:js_of_ocaml} - --source-map - %{dep:cubes.bc} - -o - %{targets} - --pretty))) + (copy cubes.bc.wasm.js cubes.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) (alias (name default) - (deps cubes.js index.html)) + (deps cubes.bc.js index.html)) diff --git a/examples/cubes/index.html b/examples/cubes/index.html index b4cadb1ff..09508370d 100644 --- a/examples/cubes/index.html +++ b/examples/cubes/index.html @@ -4,7 +4,7 @@ Cubes - + diff --git a/examples/graph_viewer/dune b/examples/graph_viewer/dune index b22b3d62c..e67a55a76 100644 --- a/examples/graph_viewer/dune +++ b/examples/graph_viewer/dune @@ -1,7 +1,7 @@ (executables (names viewer_js) ;; add converter & viewer (libraries js_of_ocaml-lwt) - (modes byte) + (modes js wasm) (modules (:standard \ @@ -13,24 +13,19 @@ dot_lexer dot_graph dot_render)) + (js_of_ocaml + (flags :standard --file %{dep:scene.json})) (preprocess - (pps js_of_ocaml-ppx))) + (pps js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json))) (ocamllex dot_lexer) (rule - (targets viewer_js.js) (action - (run - %{bin:js_of_ocaml} - --source-map - %{dep:viewer_js.bc} - -o - %{targets} - --pretty - --file - %{dep:scene.json}))) + (copy viewer_js.bc.wasm.js viewer_js.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) (alias (name default) - (deps viewer_js.js index.html)) + (deps viewer_js.bc.js scene.json index.html)) diff --git a/examples/graph_viewer/index.html b/examples/graph_viewer/index.html index 857bf5eaf..b4c6d482b 100644 --- a/examples/graph_viewer/index.html +++ b/examples/graph_viewer/index.html @@ -4,7 +4,7 @@ Graph viewer - + diff --git a/examples/graph_viewer/scene.ml b/examples/graph_viewer/scene.ml index 8185bb8d9..9a917e21e 100644 --- a/examples/graph_viewer/scene.ml +++ b/examples/graph_viewer/scene.ml @@ -17,9 +17,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +[@@@warning "-39"] + type command = | Move_to of float * float | Curve_to of float * float * float * float * float * float +[@@deriving json] type color = float * float * float @@ -28,6 +31,7 @@ type ('color, 'font, 'text) element = | Polygon of (float * float) array * 'color option * 'color option | Ellipse of float * float * float * float * 'color option * 'color option | Text of float * float * 'text * 'font * 'color option * 'color option +[@@deriving json] (****) diff --git a/examples/graph_viewer/scene.mli b/examples/graph_viewer/scene.mli index 685a9584b..935ee5168 100644 --- a/examples/graph_viewer/scene.mli +++ b/examples/graph_viewer/scene.mli @@ -20,6 +20,7 @@ type command = | Move_to of float * float | Curve_to of float * float * float * float * float * float +[@@deriving json] type color = float * float * float @@ -28,6 +29,7 @@ type ('color, 'font, 'text) element = | Polygon of (float * float) array * 'color option * 'color option | Ellipse of float * float * float * float * 'color option * 'color option | Text of float * float * 'text * 'font * 'color option * 'color option +[@@deriving json] (****) diff --git a/examples/graph_viewer/viewer_js.ml b/examples/graph_viewer/viewer_js.ml index a0e731690..0e37cdff6 100644 --- a/examples/graph_viewer/viewer_js.ml +++ b/examples/graph_viewer/viewer_js.ml @@ -166,15 +166,8 @@ open Common let redraw st s h v (canvas : Html.canvasElement Js.t) = let width = canvas##.width in let height = canvas##.height in - (*Firebug.console##time (Js.string "draw");*) redraw st s h v canvas { x = 0; y = 0; width; height } 0 0 width height -(* -;Firebug.console##timeEnd (Js.string "draw") -;Firebug.console##log_2 (Js.string "draw", Js.date##now()) -*) -let json : < parse : Js.js_string Js.t -> 'a > Js.t = Js.Unsafe.pure_js_expr "JSON" - let ( >>= ) = Lwt.bind let http_get url = @@ -182,7 +175,7 @@ let http_get url = >>= fun { XmlHttpRequest.code = cod; content = msg; _ } -> if cod = 0 || cod = 200 then Lwt.return msg else fst (Lwt.wait ()) -let getfile f = try Lwt.return (Sys_js.read_file ~name:f) with Not_found -> http_get f +let getfile f = try Lwt.return (Sys_js.read_file ~name:f) with Sys_error _ -> http_get f class adjustment ?(value = 0.) @@ -275,6 +268,25 @@ let handle_drag element f = in this example. *) Js._true) +let of_json ~typ v = + match Sys.backend_type with + | Other "js_of_ocaml" -> Js._JSON##parse (Js.string v) + | _ -> Deriving_Json.from_string typ v + +type js_string = Js.js_string Js.t + +let js_string_to_json _ _ : unit = assert false + +let js_string_of_json buf = Js.bytestring (Deriving_Json.Json_string.read buf) + +[@@@warning "-20-39"] + +type scene = + (float * float * float * float) + * (float * float * float * float) array + * (js_string, js_string, js_string) Scene.element array +[@@deriving json] + let start () = let doc = Html.document in let page = doc##.documentElement in @@ -300,7 +312,7 @@ let start () = Firebug.console##timeEnd(Js.string "loading"); Firebug.console##time(Js.string "parsing"); *) - let (x1, y1, x2, y2), bboxes, scene = json##parse (Js.string s) in + let (x1, y1, x2, y2), bboxes, scene = of_json ~typ:[%json: scene] s in (* Firebug.console##timeEnd(Js.string "parsing"); Firebug.console##time(Js.string "init"); @@ -560,8 +572,4 @@ Firebug.console##timeEnd(Js.string "init"); *) Lwt.return () -let _ = - Html.window##.onload := - Html.handler (fun _ -> - ignore (start ()); - Js._false) +let () = Lwt.async start diff --git a/examples/graphics/dune b/examples/graphics/dune index cecdf2462..da1fd0f11 100644 --- a/examples/graphics/dune +++ b/examples/graphics/dune @@ -5,6 +5,12 @@ (preprocess (pps js_of_ocaml-ppx))) +(rule + (action + (copy main.bc.wasm.js main.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) + (alias (name default) (deps main.bc.js index.html)) diff --git a/examples/hyperbolic/dune b/examples/hyperbolic/dune index f1fb55f99..7a6788b70 100644 --- a/examples/hyperbolic/dune +++ b/examples/hyperbolic/dune @@ -1,31 +1,32 @@ (executables (names hypertree) (libraries js_of_ocaml-lwt) - (modes byte) - (preprocess - (pps js_of_ocaml-ppx))) - -(rule - (targets hypertree.js) - (action - (run - %{bin:js_of_ocaml} - --source-map - %{dep:hypertree.bc} - -o - %{targets} - --pretty + (modes js wasm) + (js_of_ocaml + (flags + :standard --file %{dep:image_info.json} --file %{dep:messages.json} --file - %{dep:tree.json}))) + %{dep:tree.json})) + (preprocess + (pps js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json))) + +(rule + (action + (copy hypertree.bc.wasm.js hypertree.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) (alias (name default) (deps - hypertree.js + hypertree.bc.js index.html + image_info.json + messages.json + tree.json (glob_files icons/*.{png,jpg}) (glob_files thumbnails/*.{png,jpg}))) diff --git a/examples/hyperbolic/hypertree.ml b/examples/hyperbolic/hypertree.ml index aacebb611..b6d55991b 100644 --- a/examples/hyperbolic/hypertree.ml +++ b/examples/hyperbolic/hypertree.ml @@ -248,8 +248,6 @@ let lwt_wrap f = module Html = Dom_html -let json : < parse : Js.js_string Js.t -> 'a > Js.t = Js.Unsafe.pure_js_expr "JSON" - let http_get url = XmlHttpRequest.get url >>= fun r -> @@ -257,7 +255,7 @@ let http_get url = let msg = r.XmlHttpRequest.content in if cod = 0 || cod = 200 then Lwt.return msg else fst (Lwt.wait ()) -let getfile f = try Lwt.return (Sys_js.read_file ~name:f) with Not_found -> http_get f +let getfile f = try Lwt.return (Sys_js.read_file ~name:f) with Sys_error _ -> http_get f let load_image src = let img = Html.createImg Html.document in @@ -524,6 +522,13 @@ let text_size font txt = (******) +let of_json ~typ v = + match Sys.backend_type with + | Other "js_of_ocaml" -> Js._JSON##parse (Js.string v) + | _ -> Deriving_Json.from_string typ v + +(******) + let default_language () = (Js.Optdef.get Dom_html.window##.navigator##.language @@ -546,7 +551,7 @@ let set_language lang = language := lang let load_messages () = - getfile "messages.json" >>= fun s -> Lwt.return (json##parse (Js.string s)) + getfile "messages.json" >>= fun s -> Lwt.return (Js._JSON##parse (Js.string s)) let local_messages msgs : messages Js.t = option (Js.Unsafe.get msgs !language) @@ -794,7 +799,7 @@ let tree_url = "tree.json" let ( >> ) x f = f x -type 'a tree = Node of 'a * 'a tree array +type 'a tree = Node of 'a * 'a tree array [@@deriving json] let rec tree_vertice_count n = let (Node (_, l)) = n in @@ -1067,17 +1072,22 @@ let tree_layout node_names root = compute_text_nodes node_names nodes; vertices, edges, nodes, boxes +type js_string = Js.js_string Js.t + +let js_string_to_json _ _ : unit = assert false + +let js_string_of_json buf = Js.bytestring (Deriving_Json.Json_string.read buf) + +[@@@warning "-20-39"] + +type tree_info = + js_string tree * (js_string * (js_string * js_string) array * js_string) array +[@@deriving json] + let load_tree () = getfile tree_url >>= fun s -> - let info : - Js.js_string Js.t tree - * (Js.js_string Js.t - * (Js.js_string Js.t * Js.js_string Js.t) array - * Js.js_string Js.t) - array = - json##parse (Js.string s) - in + let info : tree_info = of_json ~typ:[%json: tree_info] s in let tree, node_names = info in randomize_tree tree; let node_names = @@ -1091,17 +1101,18 @@ let load_tree () = Lwt.return (tree_layout node_names tree, node_names) type info = - { name : Js.js_string Js.t - ; url : Js.js_string Js.t - ; attribution : Js.js_string Js.t + { name : js_string + ; url : js_string + ; attribution : js_string ; width : int ; height : int - ; links : (Js.js_string Js.t * Js.js_string Js.t * Js.js_string Js.t) array - ; img_url : Js.js_string Js.t option + ; links : (js_string * js_string * js_string) array + ; img_url : js_string option } +[@@deriving json] let load_image_info () : info array Lwt.t = - getfile "image_info.json" >>= fun s -> Lwt.return (json##parse (Js.string s)) + getfile "image_info.json" >>= fun s -> Lwt.return (of_json ~typ:[%json: info array] s) let close_button over = let color = opt_style style##.buttonColor (Js.string "#888888") in @@ -1845,6 +1856,7 @@ debug_msg (Format.sprintf "Resize %d %d" w h); prev_buttons := Some buttons in make_buttons (); + (* let img = Html.createImg doc in img##.src := icon "ocsigen-powered.png"; let a = Html.createA doc in @@ -1857,15 +1869,11 @@ debug_msg (Format.sprintf "Resize %d %d" w h); logo##.style##.bottom := Js.string "0"; Dom.appendChild logo a; Dom.appendChild doc##.body logo; - Lwt.return ()); - Js._false +*) + Lwt.return ()) -let start _ = +let () = try ignore (Html.createCanvas Html.window##.document); start () - with Html.Canvas_not_available -> - unsupported_messages (); - Js._false - -let _ = Html.window##.onload := Html.handler start + with Html.Canvas_not_available -> unsupported_messages () diff --git a/examples/hyperbolic/index.html b/examples/hyperbolic/index.html index 6d29554d6..6b9f6e1c4 100644 --- a/examples/hyperbolic/index.html +++ b/examples/hyperbolic/index.html @@ -78,6 +78,6 @@ - + diff --git a/examples/minesweeper/dune b/examples/minesweeper/dune index f393dd49c..12a574195 100644 --- a/examples/minesweeper/dune +++ b/examples/minesweeper/dune @@ -1,18 +1,19 @@ (executables (names main) (libraries js_of_ocaml-lwt) - (modes byte) + (modes js wasm) (preprocess (pps js_of_ocaml-ppx))) (rule - (targets main.js) (action - (run %{bin:js_of_ocaml} --source-map %{dep:main.bc} -o %{targets} --pretty))) + (copy main.bc.wasm.js main.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) (alias (name default) (deps - main.js + main.bc.js index.html (glob_files sprites/*.{png,svg}))) diff --git a/examples/minesweeper/index.html b/examples/minesweeper/index.html index 43eef95f1..f4243fca7 100644 --- a/examples/minesweeper/index.html +++ b/examples/minesweeper/index.html @@ -5,7 +5,7 @@ Minesweeper - +
diff --git a/examples/minesweeper/main.ml b/examples/minesweeper/main.ml index 32bd38b5a..0851c819f 100644 --- a/examples/minesweeper/main.ml +++ b/examples/minesweeper/main.ml @@ -35,7 +35,7 @@ let button name callback = Dom.appendChild res input; res -let onload _ = +let () = let main = Js.Opt.get (document##getElementById (js "main")) (fun () -> assert false) in let nbr, nbc, nbm = ref 10, ref 12, ref 15 in Dom.appendChild main (int_input "Number of columns" nbr); @@ -50,7 +50,4 @@ let onload _ = let div = Html.createDiv document in Dom.appendChild main div; Minesweeper.run div !nbc !nbr !nbm; - Js._false)); - Js._false - -let () = Html.window##.onload := Html.handler onload + Js._false)) diff --git a/examples/planet/dune b/examples/planet/dune index 30e038884..c1c9db4ec 100644 --- a/examples/planet/dune +++ b/examples/planet/dune @@ -1,21 +1,16 @@ (executables (names planet) (libraries js_of_ocaml-lwt) - (modes byte) + (modes js wasm) (preprocess (pps js_of_ocaml-ppx))) (rule - (targets planet.js) (action - (run - %{bin:js_of_ocaml} - --source-map - %{dep:planet.bc} - -o - %{targets} - --pretty))) + (copy planet.bc.wasm.js planet.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) (alias (name default) - (deps planet.js index.html texture.jpg)) + (deps planet.bc.js index.html texture.jpg)) diff --git a/examples/planet/index.html b/examples/planet/index.html index eeeae461f..aba6071fd 100644 --- a/examples/planet/index.html +++ b/examples/planet/index.html @@ -13,7 +13,7 @@ p {clear:left;} --> - + diff --git a/examples/planet/planet.ml b/examples/planet/planet.ml index 1e55fdf5c..25d0f4a72 100644 --- a/examples/planet/planet.ml +++ b/examples/planet/planet.ml @@ -592,9 +592,9 @@ let _texture = Js.string "black.jpg" let _texture = Js.string "../planet/land_ocean_ice_cloud_2048.jpg" -let texture = Js.string "../planet/texture.jpg" +let texture = Js.string "texture.jpg" -let start _ = +let () = Lwt.ignore_result (load_image texture >>= fun texture -> @@ -776,7 +776,4 @@ if true then Lwt.return () else if (not !paused) && !follow then phi_rot := !phi_rot +. angle; loop t' (if !paused then phi else phi +. angle) in - loop (Js.to_float (new%js Js.date_now)##getTime) 0.); - Js._false - -let _ = Html.window##.onload := Html.handler start + loop (Js.to_float (new%js Js.date_now)##getTime) 0.) diff --git a/examples/test_wheel/dune b/examples/test_wheel/dune index ba4be3c0a..09de8f259 100644 --- a/examples/test_wheel/dune +++ b/examples/test_wheel/dune @@ -4,3 +4,9 @@ (modes js wasm) (preprocess (pps js_of_ocaml-ppx))) + +(rule + (action + (copy test_wheel.bc.wasm.js test_wheel.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) diff --git a/examples/webgl/dune b/examples/webgl/dune index 8025ac85f..dd0cbcdd3 100644 --- a/examples/webgl/dune +++ b/examples/webgl/dune @@ -1,23 +1,18 @@ (executables (names webgldemo) (libraries js_of_ocaml-lwt) - (modes byte) + (modes js wasm) + (js_of_ocaml + (flags :standard --file %{dep:monkey.model})) (preprocess (pps js_of_ocaml-ppx))) (rule - (targets webgldemo.js) (action - (run - %{bin:js_of_ocaml} - --source-map - %{dep:webgldemo.bc} - -o - %{targets} - --pretty - --file - %{dep:monkey.model}))) + (copy webgldemo.bc.wasm.js webgldemo.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) (alias (name default) - (deps webgldemo.js index.html)) + (deps webgldemo.bc.js monkey.model index.html)) diff --git a/examples/webgl/index.html b/examples/webgl/index.html index 3110e5b81..da0ce73cf 100644 --- a/examples/webgl/index.html +++ b/examples/webgl/index.html @@ -42,7 +42,7 @@ gl_FragColor = vec4( col * lighting + u_ambientLight, 1); } - + diff --git a/examples/webgl/webgldemo.ml b/examples/webgl/webgldemo.ml index c071713e7..082b6be79 100644 --- a/examples/webgl/webgldemo.ml +++ b/examples/webgl/webgldemo.ml @@ -220,7 +220,8 @@ let http_get url = if cod = 0 || cod = 200 then Lwt.return msg else fst (Lwt.wait ()) let getfile f = - try Lwt.return (Sys_js.read_file ~name:f) with Not_found -> http_get f >|= fun s -> s + try Lwt.return (Sys_js.read_file ~name:f) + with Sys_error _ -> http_get f >|= fun s -> s let fetch_model s = getfile s @@ -298,12 +299,9 @@ let start (pos, norm) = in f () -let go _ = +let () = ignore (debug "fetching model"; catch (fun () -> fetch_model "monkey.model" >>= start) - (fun exn -> error "uncaught exception: %s" (Printexc.to_string exn))); - _true - -let _ = Dom_html.window##.onload := Dom_html.handler go + (fun exn -> error "uncaught exception: %s" (Printexc.to_string exn))) diff --git a/examples/wiki/dune b/examples/wiki/dune index 93735a283..ee357ad4a 100644 --- a/examples/wiki/dune +++ b/examples/wiki/dune @@ -1,17 +1,18 @@ (executables (names main) (libraries js_of_ocaml-lwt) - (modes byte) + (modes js wasm) (preprocess (pps js_of_ocaml-ppx))) (ocamllex wikicreole) (rule - (targets main.js) (action - (run %{bin:js_of_ocaml} --source-map %{dep:main.bc} -o %{targets} --pretty))) + (copy main.bc.wasm.js main.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) (alias (name default) - (deps main.js index.html)) + (deps main.bc.js index.html)) diff --git a/examples/wiki/index.html b/examples/wiki/index.html index aa4519299..8d8ff3fb6 100644 --- a/examples/wiki/index.html +++ b/examples/wiki/index.html @@ -5,7 +5,7 @@ Realtime wiki syntax parsing - + diff --git a/examples/wiki/main.ml b/examples/wiki/main.ml index d7f8ea48c..c9359e570 100644 --- a/examples/wiki/main.ml +++ b/examples/wiki/main.ml @@ -27,7 +27,7 @@ let replace_child p n = Js.Opt.iter p##.firstChild (fun c -> Dom.removeChild p c); Dom.appendChild p n -let onload _ = +let () = let d = Html.document in let body = Js.Opt.get (d##getElementById (Js.string "wiki_demo")) (fun () -> assert false) @@ -56,7 +56,4 @@ let onload _ = in Lwt_js.sleep (if n = 0 then 0.5 else 0.1) >>= fun () -> dyn_preview text n in - ignore (dyn_preview "" 0); - Js._false - -let _ = Html.window##.onload := Html.handler onload + ignore (dyn_preview "" 0) diff --git a/examples/wysiwyg/dune b/examples/wysiwyg/dune index 45c74c83c..ef6b073cb 100644 --- a/examples/wysiwyg/dune +++ b/examples/wysiwyg/dune @@ -1,15 +1,16 @@ (executables (names main) (libraries js_of_ocaml-lwt) - (modes byte) + (modes js wasm) (preprocess (pps js_of_ocaml-ppx))) (rule - (targets main.js) (action - (run %{bin:js_of_ocaml} --source-map %{dep:main.bc} -o %{targets} --pretty))) + (copy main.bc.wasm.js main.bc.js)) + (enabled_if + (not %{env:js-enabled=}))) (alias (name default) - (deps main.js index.html)) + (deps main.bc.js index.html)) diff --git a/examples/wysiwyg/index.html b/examples/wysiwyg/index.html index 57a2a9239..1631d03c6 100644 --- a/examples/wysiwyg/index.html +++ b/examples/wysiwyg/index.html @@ -5,7 +5,7 @@ Kakadu's WYSIWYG wiki editor - + diff --git a/examples/wysiwyg/main.ml b/examples/wysiwyg/main.ml index 43341cecd..d28b5f586 100644 --- a/examples/wysiwyg/main.ml +++ b/examples/wysiwyg/main.ml @@ -102,7 +102,7 @@ let rec html2wiki body = done; Buffer.contents ans -let onload _ = +let () = let d = Html.document in let body = Js.Opt.get (d##getElementById (Js.string "wiki_demo")) (fun () -> assert false) @@ -212,7 +212,4 @@ let onload _ = in Lwt_js.sleep (if n = 0 then 0.5 else 0.1) >>= fun () -> dyn_preview text n in - ignore (dyn_preview "" 0)); - Js._false - -let _ = Html.window##.onload := Html.handler onload + ignore (dyn_preview "" 0))