aboutsummaryrefslogtreecommitdiff
path: root/motus/js
diff options
context:
space:
mode:
Diffstat (limited to 'motus/js')
-rw-r--r--motus/js/dune2
-rw-r--r--motus/js/fieldList.ml2
-rw-r--r--motus/js/motus.ml67
3 files changed, 29 insertions, 42 deletions
diff --git a/motus/js/dune b/motus/js/dune
index 9dd3113..b7b511a 100644
--- a/motus/js/dune
+++ b/motus/js/dune
@@ -2,7 +2,7 @@
(name motus)
(libraries
brr
- brr.note
+ note.brr
application
elements
motus_lib
diff --git a/motus/js/fieldList.ml b/motus/js/fieldList.ml
index 5af5e92..7453bf5 100644
--- a/motus/js/fieldList.ml
+++ b/motus/js/fieldList.ml
@@ -1,6 +1,6 @@
open Brr
open Note
-open Brr_note
+open Note_brr
open StdLabels
type elements = Brr.El.t list
diff --git a/motus/js/motus.ml b/motus/js/motus.ml
index 5e1252a..47ea15c 100644
--- a/motus/js/motus.ml
+++ b/motus/js/motus.ml
@@ -1,5 +1,5 @@
open Brr
-open Brr_note
+open Note_brr
open Motus_lib
open Note
open StdLabels
@@ -7,18 +7,15 @@ open StdLabels
let ( let=? ) : 'a option -> ('a -> unit) -> unit =
fun f opt -> Option.iter opt f
-
let get_int_value element =
let value = El.prop El.Prop.value element in
match Jstr.to_int value with
| Some v -> v
| None -> 0
-
let get_element_by_id id =
id |> Jv.Id.of_jv |> Jv.to_jstr |> Brr.Document.find_el_by_id Brr.G.document
-
let rule_to_element rule =
match rule with
| Criteria.Lenght l ->
@@ -26,7 +23,8 @@ let rule_to_element rule =
| Contain (c, None) -> Jstr.concat [ Jstr.v "Doit contenir "; Jstr.of_char c ]
| Contain (c, Some l) ->
Jstr.concat
- [ Jstr.v "Doit contenir "
+ [
+ Jstr.v "Doit contenir "
; Jstr.of_char c
; Jstr.v " à la position "
; Jstr.of_int l
@@ -35,22 +33,15 @@ let rule_to_element rule =
Jstr.concat [ Jstr.v "Ne doit pas contenir "; Jstr.of_char c ]
| NotContain (c, Some l) ->
Jstr.concat
- [ Jstr.v "Ne doit pas contenir "
+ [
+ Jstr.v "Ne doit pas contenir "
; Jstr.of_char c
; Jstr.v " à la position "
; Jstr.of_int l
]
-
-let main
- length_id
- send_id
- dictionnary_id
- proposition_id
- rules_id
- table_id
- next_btn_id
- reload =
+let main length_id send_id dictionnary_id proposition_id rules_id table_id
+ next_btn_id reload =
let=? length_element = get_element_by_id length_id in
let=? send_btn = get_element_by_id send_id in
let=? dictionnary_element = get_element_by_id dictionnary_id in
@@ -69,8 +60,7 @@ let main
let initial_prop = FieldList.build proposition_element length_signal in
let start_event =
- Evr.on_el
- Ev.click
+ Evr.on_el Ev.click
(fun _ ->
(* Load the appropriate dictionnary *)
let dict_value =
@@ -89,7 +79,7 @@ let main
|> E.map (fun html_response ->
State.App.dispatch
(module Initialize)
- Initialize.{ length; html_response; sender; proposition } ) )
+ Initialize.{ length; html_response; sender; proposition }))
send_btn
|> E.join
in
@@ -99,7 +89,7 @@ let main
(fun (position, letter, validity) ->
State.App.dispatch
(module UpdateProposition)
- UpdateProposition.{ position; letter; validity } )
+ UpdateProposition.{ position; letter; validity })
change_event
in
@@ -112,37 +102,34 @@ let main
in
let ev =
- State.App.run
- ~eq:State.eq
- (State.init ())
+ State.App.run ~eq:State.eq (State.init ())
(E.select
- [ start_event (* Load a fresh dictionnary and start a new analysis *)
+ [
+ start_event (* Load a fresh dictionnary and start a new analysis *)
; change_event' (* Update the proposition *)
; btn_event (* Next line *)
; update_event
- ] )
+ ])
in
(* Display all the rules on the right side *)
- Elr.def_children
- rules_element
+ Elr.def_children rules_element
(S.map
(fun State.{ rules; current_prop; _ } ->
let prev_rules =
List.map rules ~f:(fun e ->
let message = rule_to_element e in
- El.li [ El.txt message ] )
+ El.li [ El.txt message ])
and new_rules =
List.map (State.get_current_rules current_prop) ~f:(fun e ->
let message = rule_to_element e in
- El.li [ El.txt message ] )
+ El.li [ El.txt message ])
in
- [ El.div prev_rules; El.hr (); El.div new_rules ] )
- ev );
+ [ El.div prev_rules; El.hr (); El.div new_rules ])
+ ev);
(* Create the letter table *)
- Elr.def_children
- table_element
+ Elr.def_children table_element
(S.map
(fun State.{ propositions; fields; _ } ->
let props = propositions in
@@ -156,18 +143,19 @@ let main
El.input
~at:
At.
- [ type' (Jstr.v "text")
+ [
+ type' (Jstr.v "text")
; v (Jstr.v "maxLength") (Jstr.v "1")
; value letter
; class' (FieldList.get_class validity)
]
()
in
- El.td [ input ] )
- |> El.tr )
+ El.td [ input ])
+ |> El.tr)
in
- El.tr fields :: previous )
- ev );
+ El.tr fields :: previous)
+ ev);
let last_element =
S.map
@@ -176,7 +164,7 @@ let main
(ev.State.current_prop, Motus_lib.Wordlist.list_size ev.State.analysis)
with
| [], _ | _, 1 -> Some (Jstr.v "true")
- | _, _ -> None )
+ | _, _ -> None)
ev
in
@@ -192,7 +180,6 @@ let main
Logr.hold (S.log initial_prop log);
Logr.hold (S.log ev log)
-
let () =
let open Jv in
let main = obj [| ("run", repr main) |] in