diff options
author | tomsmeding <tom.smeding@gmail.com> | 2020-01-18 13:19:38 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2020-01-18 13:19:51 +0100 |
commit | 319ee4d184bb7dadf328eabdd925e4416d19fb1d (patch) | |
tree | 422a2f83b2ae783de51dadf6b74f4a4da749776a /modules | |
parent | e3633fd8e52b866d56422dbe2672c7158f84cc94 (diff) |
unicode: Shareable links with URL hashes
Diffstat (limited to 'modules')
-rw-r--r-- | modules/unicode/index.html | 21 |
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> |