Commit 99052513 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Use <input> element for the number of credentials

parent b6c245ab
...@@ -46,3 +46,16 @@ let set_textarea id z = ...@@ -46,3 +46,16 @@ let set_textarea id z =
(Dom_html.CoerceTo.textarea e) (Dom_html.CoerceTo.textarea e)
(fun x -> x##value <- Js.string z) (fun x -> x##value <- Js.string z)
) )
let get_input id =
let res = ref None in
Js.Opt.iter
(document##getElementById (Js.string id))
(fun e ->
Js.Opt.iter
(Dom_html.CoerceTo.input e)
(fun x -> res := Some (Js.to_string (x##value)))
);
match !res with
| None -> raise Not_found
| Some x -> x
...@@ -25,7 +25,7 @@ open Tool_js_common ...@@ -25,7 +25,7 @@ open Tool_js_common
open Tool_credgen open Tool_credgen
let generate _ = let generate _ =
let number = get_textarea "number" |> int_of_string in let number = get_input "number" |> int_of_string in
let ids = generate_ids number in let ids = generate_ids number in
let module P : PARAMS = struct let module P : PARAMS = struct
let uuid = get_textarea "uuid" let uuid = get_textarea "uuid"
...@@ -58,17 +58,16 @@ let fill_interactivity _ = ...@@ -58,17 +58,16 @@ let fill_interactivity _ =
let x = document##createElement (Js.string "div") in let x = document##createElement (Js.string "div") in
let t = document##createTextNode (Js.string "Number of credentials to generate: ") in let t = document##createTextNode (Js.string "Number of credentials to generate: ") in
Dom.appendChild x t; Dom.appendChild x t;
let y = document##createElement (Js.string "textarea") in let y = document##createElement (Js.string "input") in
y##setAttribute (Js.string "id", Js.string "number"); y##setAttribute (Js.string "id", Js.string "number");
y##setAttribute (Js.string "rows", Js.string "1"); y##setAttribute (Js.string "size", Js.string "5");
y##setAttribute (Js.string "cols", Js.string "5");
Dom.appendChild x y; Dom.appendChild x y;
Dom.appendChild e x; Dom.appendChild e x;
let b = document##createElement (Js.string "button") in let b = document##createElement (Js.string "button") in
let t = document##createTextNode (Js.string "Generate credentials") in let t = document##createTextNode (Js.string "Generate") in
b##onclick <- Dom_html.handler generate; b##onclick <- Dom_html.handler generate;
Dom.appendChild b t; Dom.appendChild b t;
Dom.appendChild e b; Dom.appendChild x b;
); );
Js._false Js._false
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment