Files
oplevel/oplevel.ml

39 lines
1.1 KiB
OCaml

open Js_of_ocaml
open Js_of_ocaml_tyxml
open Lwt
open Store
let by_id s = Dom_html.getElementById s
let by_id_coerce s f =
Js.Opt.get
(f (Dom_html.getElementById s))
(fun () -> raise Not_found)
let do_by_id s f =
try f (Dom_html.getElementById s) with Not_found -> ()
let _ =
Dom_html.window##.onload
:= Dom_html.handler (fun _ ->
Lwt.async (fun () ->
let output = by_id "output" in
let rootstore = Store.test_pull () in
rootstore >>= fun rs ->
(try Store.S.Tree.get rs [ ".config"; "init.ml" ] with
| Not_found | Invalid_argument _ ->
Lwt.return
"print_newline \"rootstore://.config/init.ml not \
found\";;"
| exc ->
Firebug.console##log_3
(Js.string ".config/init.ml load exception")
(Js.string (Printexc.to_string exc))
exc;
Lwt.return ";;")
>>= fun init ->
Toplevel.run ~init ~output ();
Lwt.return_unit);
Js._false)