Commit 9aa9561a authored by Benoit Barbot's avatar Benoit Barbot
Browse files

improve link

parent ce18173c
Pipeline #1695 passed with stages
in 32 seconds
......@@ -55,6 +55,18 @@ let build_cmd_elem (opt,x,help) =
if !(S.content) = S.def then ""
else Printf.sprintf " %s %s" opt (S.to_string !(S.content))
let reset (_,x,_) = match x with
Bool a -> a:= false
| Set_int a -> a:= None
| Set_float a -> a:= None
| Set_string a -> a:= None
| Int (a,d) -> a := d
| Float (a,d) -> a := d
| String (a,d) -> a := d
| Symbol s->
let module S = (val s:SYM) in
S.content := S.def
let build_cmd l =
let str = List.fold_left (fun acc elem -> acc ^ (build_cmd_elem elem)) "wordgen" l in
str
......
open Html
open Common
open Js_of_ocaml
let build_interface_elem up (opt,x,help) =
let open Arguments in
let input = match x with
| Bool f -> [checkbox_input ~on_change:(fun x -> f:= x;up ()) false ]
| Set_int a -> [text_input ~_type:"number" ~on_change:(fun x -> a:= int_of_string_opt x; up ()) ("")]
| Bool f -> [checkbox_input ~on_change:(fun x -> f:= x;up ()) !f ]
| Set_int a -> [text_input ~_type:"number" ~on_change:(fun x -> a:= int_of_string_opt x; up ())
(!a |>>> string_of_int |>>| "")]
| Set_float a -> [text_input ~_type:"text" ~on_change:(fun x -> a := float_of_string_opt x;up ())
(!a |>>> string_of_float |>>| "")]
| Set_string f -> [text_input ~_type:"text" ~on_change:(fun x -> f := if x = "" then None else Some x;up ())
(!f |>>| "")]
| Int (f,df) -> [text_input ~_type:"number" ~on_change:(fun x ->
(match int_of_string_opt x with
None -> f := df
| Some v -> f:= v);up ()) (string_of_int df)]
| Set_float (a) -> [text_input ~_type:"text" ~on_change:(fun x -> a := float_of_string_opt x;up ()) ""]
| Float (f,df) -> [text_input ~_type:"text" ~on_change:(fun x ->
(match float_of_string_opt x with
None -> f := df
| Some v -> f :=v);up ()) (string_of_float df)]
| Set_string f -> [text_input ~_type:"text" ~on_change:(fun x -> f := if x = "" then None else Some x;up ()) ""]
| String (a,ds) -> [text_input ~_type:"text" ~on_change:(fun x -> a:= x;up ()) ds]
| Symbol s ->
let module S = (val s : SYM) in
[select S.list ~def:(S.to_string S.def) ~on_change:(fun x -> S.content := S.of_string x;up ())]
[select S.list ~def:(S.to_string !S.content) ~on_change:(fun x -> S.content := S.of_string x;up ())]
in
div ~class_:"cmdelem" ~title:help ([text opt; text " : " ] @ input )
......@@ -52,14 +56,21 @@ endinvariant
[b] (y<2)& (x<3) -> (x'=0);
endmodule"
open Arguments
let _ = run @@ fun () ->
let open Js_of_ocaml.Url in
let args = Current.arguments in
(match List.assoc_opt "q" args with
(match List.assoc_opt "automata" args with
None -> ()
| Some q -> file_content := urldecode q);
(match List.assoc_opt "cmd" args with
None -> ()
| Some q -> file_content := urldecode q);
| Some cmd -> ("wordgen " ^cmd)
|> urldecode
|> String.split_on_char ' '
|> Array.of_list
|> (fun a -> Arg.parse_argv a Arguments.spec_caml_arg (fun _ -> ()) Arguments.usage_str)
);
let stdoutput,stdoutput_up = text_area' ~class_:"code col-sm-6" ~is_read_only:true "" in
......@@ -72,11 +83,10 @@ let _ = run @@ fun () ->
let buffstd = Buffer.create 100 in
let buffdata = Buffer.create 100 in
let dirlink,dirlink_up = div' [] in
let dirup x =
file_content:=x;
let dirup () =
let open Js_of_ocaml.Url in
let link = Current.path_string in
dirlink_up [a ~href:(link^"?q="^(urlencode x)) [text "Direct link"] ] in
dirlink_up [a ~href:(Printf.sprintf "%s?automata=%s&cmd=%s" link (urlencode !file_content) (urlencode (build_cmd Arguments.spec_short)) ) [text "Direct link"] ] in
worker##.onmessage := ( Dom.handler (fun m -> (match m##.data with
| Worker_sync.StdOut s ->
Buffer.add_string buffstd s;
......@@ -98,7 +108,7 @@ let _ = run @@ fun () ->
alert_up [];
| Finish ->
sig_up [text "Computation Finished"];
(match OutFormat.plot_of_style !out_style !store_traj "myData.dat" with
(match OutFormat.plot_of_style !Arguments.out_style !Arguments.store_traj "myData.dat" with
Some plot ->
Js.Unsafe.fun_call (Js.Unsafe.js_expr "compute_gnuplot") [|
Js.Unsafe.inject (gnuplotvis);
......@@ -108,7 +118,9 @@ let _ = run @@ fun () ->
print_endline ("Computation finished")
);Js._true));
let launch_compt b =
Arguments.post_parse ();
let open Arguments in
dirup ();
post_parse ();
stdoutput_up "";
outfile_up "";
sig_up [];
......@@ -134,9 +146,8 @@ let _ = run @@ fun () ->
}) in
let txin = text_area ~class_:"input_file col-sm-6" ~on_change:(fun x->
dirup x;
file_content:=x;
launch_compt false) !file_content in
dirup !file_content;
launch_compt true;
div ~class_:"main container-fluid"[
div ~class_:"jumbotron cmdline" [
......@@ -146,7 +157,7 @@ let _ = run @@ fun () ->
a ~href:"https://git.lacl.fr/barbot/wordgen" [text "the source repository page"];
text ". Be aware the tool Wordgen is a native commandline tool, this website if limited in speed and functionalities.";
];
build_interface ~class_:"" ~stop:(fun () -> worker##postMessage (Worker_sync.Stop)) launch_compt spec_short;];
build_interface ~class_:"" ~stop:(fun () -> worker##postMessage (Worker_sync.Stop)) launch_compt Arguments.spec_short;];
div ~class_:"" [div ~class_:"output" [ txin; container]];
dirlink;
br ();
......
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