File tree 5 files changed +18
-1
lines changed
5 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ let get_by_name id =
29
29
List. hd (Dom. list_of_nodeList (doc##getElementsByTagName (Js. string id))) in
30
30
Js. to_string div##innerHTML
31
31
32
+ let read_from_input ?msg :(msg = " " ) ?default:(default= " " ) =
33
+ Js. to_string (window##prompt (_s msg, _s default))
34
+
32
35
let jsnew0 (constr : 'a Js.t Js.constr ) () =
33
36
(Js.Unsafe. new_obj constr [| |] : 'a Js.t )
34
37
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ val get_by_id : string -> string
19
19
20
20
val get_by_name : string -> string
21
21
22
+ val read_from_input : ?msg : string -> ?default : string -> string
23
+
22
24
(* * {2 Constructors} *)
23
25
24
26
(* * [jsnew0] is a function to build an object using contructor [constr]
Original file line number Diff line number Diff line change @@ -706,6 +706,8 @@ let run () =
706
706
Cookie. set_cookie " step" s;
707
707
Tutorial. step (int_of_string s) in
708
708
update_lesson_step ! Tutorial. this_lesson ! Tutorial. this_step;
709
+ let _ =
710
+ Tutorial. read_fun := (fun msg default -> read_from_input ~msg: msg ~default: default) in
709
711
Js. _false
710
712
711
713
let main () =
Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ let debug = ref false
3
3
4
4
let debug_fun = ref (fun _ -> () )
5
5
let update_lang_fun = ref (fun _ -> () )
6
+ let read_fun = ref (fun _ _ -> " " )
7
+ let read_bool = fun () -> bool_of_string (! read_fun " Enter your answer" " " )
8
+ let read_string = fun () -> ! read_fun " Enter your answer" " "
9
+ let read_int = fun () -> int_of_string (! read_fun " Enter your answer" " " )
10
+ let read_float = fun () -> float_of_string (! read_fun " Enter your answer" " " )
6
11
7
12
let print_debug s = if ! debug then (! debug_fun) s
8
13
@@ -208,7 +213,6 @@ let set_lang lang =
208
213
209
214
let lang () = ! current_lang
210
215
211
-
212
216
external int_of_int : int -> int = " %identity"
213
217
external nativeint_of_nativeint : nativeint -> nativeint = " %identity"
214
218
external float_of_float : float -> float = " %identity"
Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ val lessons_table : (string * string * (string * (string * string)) list * (stri
19
19
val debug_fun : (string -> unit ) ref
20
20
val message_fun : (string -> unit ) ref
21
21
val update_lang_fun : (unit -> unit ) ref
22
+ val read_fun : (string -> string -> string ) ref
23
+ val read_bool : unit -> bool
24
+ val read_string : unit -> string
25
+ val read_int : unit -> int
26
+ val read_float : unit -> float
27
+
22
28
23
29
val lessons : unit -> unit
24
30
val steps : unit -> unit
You can’t perform that action at this time.
0 commit comments