aboutsummaryrefslogtreecommitdiff
path: root/motus/js/fieldList.ml
diff options
context:
space:
mode:
Diffstat (limited to 'motus/js/fieldList.ml')
-rw-r--r--motus/js/fieldList.ml17
1 files changed, 12 insertions, 5 deletions
diff --git a/motus/js/fieldList.ml b/motus/js/fieldList.ml
index 428f364..26b89bb 100644
--- a/motus/js/fieldList.ml
+++ b/motus/js/fieldList.ml
@@ -61,6 +61,7 @@ let make : int -> (int * Jstr.t * Motus_lib.Validity.t) E.send -> elements =
let validity = get_validity_from_element input in
change_sender (i, El.prop El.Prop.value input, validity) )
(El.as_target input);
+
Ev.listen
Ev.click
(fun _ ->
@@ -82,13 +83,17 @@ let set_with_props :
State.proposition -> elements -> Motus_lib.Criteria.t list -> unit =
fun current_prop fields rules ->
let i = ref 0 in
+
List.iter2 current_prop fields ~f:(fun prop field ->
- (* Check if we have a rule for this letter *)
let wellplaced =
- List.exists rules ~f:(function
- | Motus_lib.Criteria.Contain (_, Some i') when !i = i' -> true
- | _ -> false )
+ match prop with
+ | None -> false
+ | Some v ->
+ let c = String.get (Jstr.to_string (fst v)) 0 in
+ let contain = Motus_lib.Criteria.Contain (c, Some !i) in
+ List.mem contain ~set:rules
in
+
incr i;
match (wellplaced, El.children field, prop) with
@@ -101,12 +106,14 @@ let set_with_props :
| _, hd :: _, None ->
El.set_class (Jstr.v "wellplaced") false hd;
El.set_class (Jstr.v "misplaced") false hd;
- El.set_class (Jstr.v "missing") false hd
+ El.set_class (Jstr.v "missing") false hd;
+ El.set_at (Jstr.v "readonly") (Some (Jstr.v "false")) hd
| false, hd :: _, Some (letter, validity) ->
El.set_prop El.Prop.value letter hd;
El.set_class (Jstr.v "wellplaced") false hd;
El.set_class (Jstr.v "misplaced") false hd;
El.set_class (Jstr.v "missing") false hd;
+ El.set_at (Jstr.v "readonly") (Some (Jstr.v "false")) hd;
El.set_class (get_class validity) true hd
| _, [], _ -> () )