1515module XmlHttpRequest = Js_of_ocaml_lwt. XmlHttpRequest
1616
1717(* Debug mode. Set to true if you want to use the debug mode. Used by "log".
18- *)
18+ *)
1919let debug = false
2020
2121(* If debug mode is activated, a paragraph is created and a message is printed
@@ -73,17 +73,17 @@ let rec add_retry_button wake msg =
7373 (Js_of_ocaml.Js. string " Retry" ));
7474 btn##.onclick :=
7575 Js_of_ocaml.Dom_html. handler (fun _ ->
76- Js_of_ocaml.Dom. removeChild container p;
77- container##.className := Js_of_ocaml.Js. string " app blink" ;
78- if ! update_failed
79- then (
80- update_failed := false ;
81- ignore Js_of_ocaml.Js.Unsafe. global##.chcp##fetchUpdate );
82- if ! data_upload_failed
83- then (
84- data_upload_failed := false ;
85- Lwt. async (fun () -> get_data wake));
86- Js_of_ocaml.Js. _false);
76+ Js_of_ocaml.Dom. removeChild container p;
77+ container##.className := Js_of_ocaml.Js. string " app blink" ;
78+ if ! update_failed
79+ then (
80+ update_failed := false ;
81+ ignore Js_of_ocaml.Js.Unsafe. global##.chcp##fetchUpdate );
82+ if ! data_upload_failed
83+ then (
84+ data_upload_failed := false ;
85+ Lwt. async (fun () -> get_data wake));
86+ Js_of_ocaml.Js. _false);
8787 btn##.id := Js_of_ocaml.Js. string " retry-button" ;
8888 Js_of_ocaml.Dom. appendChild p btn;
8989 Js_of_ocaml.Dom. appendChild container p
@@ -119,9 +119,9 @@ let _ =
119119 @@ Js_of_ocaml.Dom. addEventListener Js_of_ocaml.Dom_html. document
120120 (Js_of_ocaml.Dom_html.Event. make " resume" )
121121 (Js_of_ocaml.Dom. handler (fun _ ->
122- log " Resume" ;
123- ignore Js_of_ocaml.Js.Unsafe. global##.chcp##fetchUpdate ;
124- Js_of_ocaml.Js. _true))
122+ log " Resume" ;
123+ ignore Js_of_ocaml.Js.Unsafe. global##.chcp##fetchUpdate ;
124+ Js_of_ocaml.Js. _true))
125125 Js_of_ocaml.Js. _false;
126126 (* Create two threads for success callbacks and error callbacks. *)
127127 let wait_success, wake_success = Lwt. wait () in
@@ -132,26 +132,26 @@ let _ =
132132 *)
133133 let callback ev =
134134 Js_of_ocaml.Dom. handler (fun _ ->
135- log ev;
136- update_failed := false ;
137- Lwt. wakeup wake_success () ;
138- Js_of_ocaml.Js. _true)
135+ log ev;
136+ update_failed := false ;
137+ Lwt. wakeup wake_success () ;
138+ Js_of_ocaml.Js. _true)
139139 in
140140 (* Callback when errors.
141141 * Calls by the event chcp_nothingToUpdate.
142142 *)
143143 let error_callback name =
144144 Js_of_ocaml.Dom. handler (fun ev ->
145- log
146- (name ^ " : "
147- ^ Js_of_ocaml.Js. to_string ev##.detail##.error##.description);
148- update_failed := true ;
149- if not ! data_upload_failed
150- then
151- add_retry_button wake_error
152- (Js_of_ocaml.Js. to_string ev##.detail##.error##.description
153- ^ " . Please try again later." );
154- Js_of_ocaml.Js. bool true )
145+ log
146+ (name ^ " : "
147+ ^ Js_of_ocaml.Js. to_string ev##.detail##.error##.description);
148+ update_failed := true ;
149+ if not ! data_upload_failed
150+ then
151+ add_retry_button wake_error
152+ (Js_of_ocaml.Js. to_string ev##.detail##.error##.description
153+ ^ " . Please try again later." );
154+ Js_of_ocaml.Js. bool true )
155155 in
156156 (* Callback to print a message *)
157157 let status_callback name =
@@ -160,20 +160,20 @@ let _ =
160160 (* Binding to chcp_nothingToUpdate. Calls [callback ev]. *)
161161 List. iter
162162 (fun ev ->
163- ignore
164- @@ Js_of_ocaml.Dom. addEventListener Js_of_ocaml.Dom_html. document
165- (Js_of_ocaml.Dom_html.Event. make ev)
166- (callback ev) Js_of_ocaml.Js. _false)
163+ ignore
164+ @@ Js_of_ocaml.Dom. addEventListener Js_of_ocaml.Dom_html. document
165+ (Js_of_ocaml.Dom_html.Event. make ev)
166+ (callback ev) Js_of_ocaml.Js. _false)
167167 [" chcp_nothingToUpdate" ];
168168 (* Binding to chcp_updateLoadFailed, chcp_updateInstallFailed and
169169 * chcp_assetsInstallationError. It calls [error_callback ev].
170170 *)
171171 List. iter
172172 (fun ev ->
173- ignore
174- @@ Js_of_ocaml.Dom. addEventListener Js_of_ocaml.Dom_html. document
175- (Js_of_ocaml.Dom_html.Event. make ev)
176- (error_callback ev) Js_of_ocaml.Js. _false)
173+ ignore
174+ @@ Js_of_ocaml.Dom. addEventListener Js_of_ocaml.Dom_html. document
175+ (Js_of_ocaml.Dom_html.Event. make ev)
176+ (error_callback ev) Js_of_ocaml.Js. _false)
177177 [ " chcp_updateLoadFailed"
178178 ; " chcp_updateInstallFailed"
179179 ; " chcp_assetsInstallationError" ];
@@ -182,10 +182,10 @@ let _ =
182182 *)
183183 List. iter
184184 (fun ev ->
185- ignore
186- @@ Js_of_ocaml.Dom. addEventListener Js_of_ocaml.Dom_html. document
187- (Js_of_ocaml.Dom_html.Event. make ev)
188- (status_callback ev) Js_of_ocaml.Js. _false)
185+ ignore
186+ @@ Js_of_ocaml.Dom. addEventListener Js_of_ocaml.Dom_html. document
187+ (Js_of_ocaml.Dom_html.Event. make ev)
188+ (status_callback ev) Js_of_ocaml.Js. _false)
189189 [ " chcp_updateIsReadyToInstall"
190190 ; " chcp_beforeInstall"
191191 ; " chcp_nothingToInstall"
0 commit comments