summaryrefslogtreecommitdiffabout
diff options
context:
space:
mode:
authorArmaël Guéneau <armael.gueneau@ens-lyon.org>2020-11-02 23:15:22 (CET)
committer Armaël Guéneau <armael.gueneau@ens-lyon.org>2020-11-02 23:15:22 (CET)
commitc457432a3a7bdd037bbb60ebe48e96091362aded (patch)
tree5ce0f63d2178d34ba831696825ce4fa8abe51e28
parentfb7bf3d7cecfb0c8771d7f72b2ccdd9a07ef3cf7 (diff)
downloaddict-c457432a3a7bdd037bbb60ebe48e96091362aded.tar.gz
dict-c457432a3a7bdd037bbb60ebe48e96091362aded.tar.bz2
Keep the URL in sync with the current search
-rw-r--r--dict.ml5
1 files changed, 4 insertions, 1 deletions
diff --git a/dict.ml b/dict.ml
index bbfb575..c23dc8d 100644
--- a/dict.ml
+++ b/dict.ml
@@ -108,11 +108,12 @@ let results_html =
let () =
let main = Dom_html.getElementById "main" in
let input_node = Tyxml_js.To_dom.of_input input_box in
+ let page_uri = Dom_html.window##.location##.href |> Js.to_string |> Uri.of_string in
+
Lwt.async (fun _ ->
Lwt_js_events.domContentLoaded () >>= fun _ ->
main##appendChild (Tyxml_js.To_dom.of_node search_box) |> ignore;
main##appendChild (Tyxml_js.To_dom.of_node results_html) |> ignore;
- let page_uri = Dom_html.window##.location##.href |> Js.to_string |> Uri.of_string in
begin match Uri.fragment page_uri with
| Some frag ->
input_node##.value := (Js.string frag);
@@ -127,6 +128,8 @@ let () =
Lwt_js_events.input input_node (fun _ _ ->
let text = Js.to_string ((Tyxml_js.To_dom.of_input input_box)##.value) in
set_search text;
+ let uri = Uri.with_fragment page_uri (Some text) in
+ Dom_html.window##.location##.href := Js.string (Uri.to_string uri);
return ()
)
)