summaryrefslogtreecommitdiffabout
diff options
context:
space:
mode:
authorArmaël Guéneau <armael.gueneau@ens-lyon.org>2020-11-02 23:03:39 (CET)
committer Armaël Guéneau <armael.gueneau@ens-lyon.org>2020-11-02 23:03:39 (CET)
commitfb7bf3d7cecfb0c8771d7f72b2ccdd9a07ef3cf7 (patch)
treea9b4d3be9100478af6d7e13d4ae5934de3d30438
parent037af9409dcbdc0c6047a086c074288779d966f1 (diff)
downloaddict-fb7bf3d7cecfb0c8771d7f72b2ccdd9a07ef3cf7.tar.gz
dict-fb7bf3d7cecfb0c8771d7f72b2ccdd9a07ef3cf7.tar.bz2
Implement #foo (anchors) in the url as the predefined search query
-rw-r--r--dict.ml7
-rw-r--r--dune2
2 files changed, 8 insertions, 1 deletions
diff --git a/dict.ml b/dict.ml
index 95c204b..bbfb575 100644
--- a/dict.ml
+++ b/dict.ml
@@ -112,6 +112,13 @@ let () =
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);
+ set_search frag
+ | None -> ()
+ end;
return ()
);
diff --git a/dune b/dune
index ae1c471..e8c8c15 100644
--- a/dune
+++ b/dune
@@ -1,7 +1,7 @@
(executable
(name dict)
(modes js)
- (libraries containers js_of_ocaml-lwt js_of_ocaml-tyxml)
+ (libraries containers js_of_ocaml-lwt js_of_ocaml-tyxml uri)
(preprocess (pps js_of_ocaml-ppx))
(link_flags (:standard -no-check-prims))
)