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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
open Js_of_ocaml
let doc = Dom_html.document
let _s = Js.string
type configuration = {
controls : bool;
progress : bool;
slide_number : bool;
history : bool;
keyboard : bool;
overview : bool;
center : bool;
touch : bool;
loop : bool;
rtl : bool;
fragments : bool;
embedded : bool;
help : bool;
show_notes : bool;
auto_slide : float;
auto_slide_stoppable : bool;
mouse_wheel : bool;
hide_address_bar : bool;
preview_links : bool;
transition : Slides.transition;
transition_speed : Slides.speed;
background_transition : Slides.transition;
view_distance : int;
remote : bool;
}
class type math = object
method config : Js.js_string Js.t Js.prop
end
class type dependencies = object
method src : Js.js_string Js.t Js.prop
method condition : unit -> bool Js.t Js.prop
method callback : unit -> bool Js.t Js.prop
method async : bool Js.t Js.prop
end
class type reveal = object
method controls: bool Js.t Js.prop
method progress: bool Js.t Js.prop
method slideNumber: bool Js.t Js.prop
method history: bool Js.t Js.prop
method keyboard: bool Js.t Js.prop
method overview: bool Js.t Js.prop
method center: bool Js.t Js.prop
method touch: bool Js.t Js.prop
method loop: bool Js.t Js.prop
method rtl: bool Js.t Js.prop
method fragments: bool Js.t Js.prop
method embedded: bool Js.t Js.prop
method help: bool Js.t Js.prop
method showNotes: bool Js.t Js.prop
method autoSlide: float Js.prop
method autoSlideStoppable : bool Js.t Js.prop
method mouseWheel: bool Js.t Js.prop
method hideAddressBar: bool Js.t Js.prop
method previewLinks: bool Js.t Js.prop
method transition: Js.js_string Js.t Js.prop
method transitionSpeed: Js.js_string Js.t Js.prop
method backgroundTransition: Js.js_string Js.t Js.prop
method viewDistance: int Js.prop
method remote: bool Js.t Js.prop
method math: math Js.t Js.prop
method dependencies: dependencies Js.t Js.js_array Js.t Js.prop
end
let default_global_config = {
controls = true;
progress = true;
slide_number = true;
history = false;
keyboard = true;
overview = true;
center = true;
touch = true;
loop = false;
rtl = false;
fragments = true;
embedded = false;
help = true;
show_notes= false;
auto_slide= 0.;
auto_slide_stoppable = true;
mouse_wheel = false;
hide_address_bar = true;
preview_links = false;
transition = Slides.None;
transition_speed = Slides.Default;
background_transition = Slides.None;
view_distance = 3;
remote = true;
}
let dep ?(async=None) ?(condition=None) ?(callback=None) src =
let obj = Js.Unsafe.obj [||] in
obj##.src := _s src;
begin match async with
| None -> ()
| Some async -> obj##.async := async
end;
begin match condition with
| None -> ()
| Some condition -> obj##.condition := condition
end;
begin match callback with
| None -> ()
| Some callback -> obj##.callback := callback
end;
obj
let initialize ?configuration:(c=default_global_config) () =
let open External_js in
let math : math Js.t = Js.Unsafe.obj [||] in
math##.config := _s "TeX-AMS_HTML-full";
let deps = Js.array [|
(** Cross-browser shim that fully implements classList -
https://github.com/eligrey/classList.js/ *)
dep
~async:None
~condition:(Some (fun () ->
doc##.body##.classList##.length <> 0))
classList_js;
(** Interpret Markdown in <section> elements. *)
dep
~condition:(Some (fun () -> doc##querySelector (_s "[data-markdown]")))
marked_js;
dep
~async:None
~condition:(Some (fun () -> doc##querySelector (_s "[data-markdown]")))
markdown_js;
(** Syntax highlight for <code> elements. *)
dep
~callback:(Some (fun () -> (Js.Unsafe.global##.hljs)##initHighlighting()))
highlight_js;
(** Speaker notes. *)
dep note_js;
(** MathJax : math equations (cf latex syntax) *)
dep math_js;
(** Zoom in and out with Alt+click *)
dep ~async:(Some Js._true) zoom_js |] in
let reveal : reveal Js.t = Js.Unsafe.obj [||] in
reveal##.controls := Js.bool c.controls;
reveal##.progress := Js.bool c.progress;
reveal##.slideNumber := Js.bool c.slide_number;
reveal##.history := Js.bool c.history;
reveal##.keyboard := Js.bool c.keyboard;
reveal##.overview := Js.bool c.overview;
reveal##.center := Js.bool c.center;
reveal##.touch := Js.bool c.touch;
reveal##.loop := Js.bool c.loop;
reveal##.rtl := Js.bool c.rtl;
reveal##.fragments := Js.bool c.fragments;
reveal##.embedded := Js.bool c.embedded;
reveal##.help := Js.bool c.help;
reveal##.showNotes := Js.bool c.show_notes;
reveal##.autoSlide := c.auto_slide;
reveal##.autoSlideStoppable := Js.bool c.auto_slide_stoppable;
reveal##.mouseWheel := Js.bool c.mouse_wheel;
reveal##.hideAddressBar := Js.bool c.hide_address_bar;
reveal##.previewLinks := Js.bool c.preview_links;
reveal##.transition := _s @@ Slides.string_of_transition c.transition;
reveal##.transitionSpeed := _s @@ Slides.string_of_speed c.transition_speed;
reveal##.backgroundTransition :=
_s @@ Slides.string_of_transition c.background_transition;
reveal##.viewDistance := c.view_distance;
reveal##.remote := Js.bool c.remote;
reveal##.math := math;
reveal##.dependencies := deps;
Dom_html.window##.onload :=
Dom_html.handler (fun _ ->
ignore (Js.Unsafe.global##.Reveal##initialize reveal);
Js.bool true);