-
Notifications
You must be signed in to change notification settings - Fork 0
/
tournabox.ml
35 lines (29 loc) · 957 Bytes
/
tournabox.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Lib = Tournabox_lib
let report_error str = Dom_html.window##alert (Js.string ("Tournabox:\n" ^ str));;
let run _ =
Tlog.infof ~section:Tlog.input "Onload Event Invoked";
let all_good_shells shells =
List.iter (function (None, str) -> report_error str | _ -> ()) shells;
let unwrap_option = function (Some x, _) -> x | (None, _) -> assert false in
let somes = function (None, _) -> false | (Some _, _) -> true in
Util.filter_then_map ~mapf:unwrap_option ~filterf:somes shells
in
let all_good = all_good_shells
(Lib.get_all_tourney_shells ()) in
let play shell =
try
Lib.play shell
with Failure str ->
report_error str
in
List.iter play all_good;
Js._true; (* Allow default action *)
in
Tlog.infof ~section:Tlog.input "Starting Up. This should only happen once.";
ignore(
Dom_html.addEventListener
(Dom_html.window)
Dom_html.Event.load
(Dom_html.handler run)
Js._true
)