summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2020-01-18 13:19:38 +0100
committertomsmeding <tom.smeding@gmail.com>2020-01-18 13:19:51 +0100
commit319ee4d184bb7dadf328eabdd925e4416d19fb1d (patch)
tree422a2f83b2ae783de51dadf6b74f4a4da749776a
parente3633fd8e52b866d56422dbe2672c7158f84cc94 (diff)
unicode: Shareable links with URL hashes
-rw-r--r--modules/unicode/index.html21
1 files changed, 16 insertions, 5 deletions
diff --git a/modules/unicode/index.html b/modules/unicode/index.html
index 23492cd..1065575 100644
--- a/modules/unicode/index.html
+++ b/modules/unicode/index.html
@@ -17,9 +17,18 @@ body {
}
</style>
<script>
-function do_lookup() {
- var input = document.getElementById("input").value;
- if (input.length == 0) return;
+function do_lookup(override) {
+ var input;
+ if (override != null) {
+ if (override.length == 0) return;
+ input = override;
+ document.getElementById("input").value = override;
+ } else {
+ input = document.getElementById("input").value;
+ if (input.length == 0) return;
+ }
+
+ location.hash = input;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
@@ -39,8 +48,6 @@ function do_lookup() {
}
function handleResponse(json) {
- console.log(json);
-
var elem;
/* elem = document.getElementById("json");
@@ -81,6 +88,10 @@ function populateCharacter(div, row) {
}
window.addEventListener("load", function() {
+ if (location.hash.length > 0) {
+ do_lookup(decodeURIComponent(location.hash.slice(1)));
+ }
+
document.getElementById("input").focus();
});
</script>