summaryrefslogtreecommitdiff
path: root/modules/unicode/index.html
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-05-21 11:48:51 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-05-21 11:48:51 +0200
commit11d61f3c6f82bd36b365c75146d5c698abd40e8b (patch)
tree153347d77e71c5cebc5300a3bab2ab25bded170b /modules/unicode/index.html
parente6d6f325b463b0874f1c76c4450e0be71a9176bf (diff)
unicode: Parse direct codepoint numbers
Diffstat (limited to 'modules/unicode/index.html')
-rw-r--r--modules/unicode/index.html35
1 files changed, 29 insertions, 6 deletions
diff --git a/modules/unicode/index.html b/modules/unicode/index.html
index 1065575..1832fe8 100644
--- a/modules/unicode/index.html
+++ b/modules/unicode/index.html
@@ -15,6 +15,9 @@ body {
max-height: 300px;
overflow-y: scroll;
}
+.invisible {
+ display: none;
+}
</style>
<script>
function do_lookup(override) {
@@ -34,7 +37,7 @@ function do_lookup(override) {
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
- handleResponse(JSON.parse(xhr.responseText));
+ handleResponse(JSON.parse(xhr.responseText), input);
} else {
alert("Request failed: " + xhr.responseText);
}
@@ -47,13 +50,24 @@ function do_lookup(override) {
xhr.send();
}
-function handleResponse(json) {
+function handleResponse(json, input) {
var elem;
/* elem = document.getElementById("json");
elem.innerHTML = "";
elem.appendChild(document.createTextNode(JSON.stringify(json))); */
+ var index_container = document.getElementById("index_container");
+ if ("index" in json) {
+ index_container.classList.remove("invisible");
+ document.getElementById("index_input").innerHTML = input;
+ elem = document.getElementById("index");
+ elem.innerHTML = "";
+ elem.appendChild(makeCharacterDiv(json["index"]));
+ } else if (!index_container.classList.contains("invisible")) {
+ index_container.classList.add("invisible");
+ }
+
var keys = ["chars", "search"];
for (var i = 0; i < keys.length; i++) {
@@ -62,14 +76,18 @@ function handleResponse(json) {
elem = document.getElementById(keys[i]);
elem.innerHTML = "";
for (var j = 0; j < json[keys[i]].length; j++) {
- var div = document.createElement("div");
- div.classList.add("character");
- populateCharacter(div, json[keys[i]][j]);
- elem.appendChild(div);
+ elem.appendChild(makeCharacterDiv(json[keys[i]][j]));
}
}
}
+function makeCharacterDiv(row) {
+ var div = document.createElement("div");
+ div.classList.add("character");
+ populateCharacter(div, row);
+ return div;
+}
+
function populateCharacter(div, row) {
var span = document.createElement("span");
span.setAttribute("style", "display: inline-block; width: 7em; font-weight: bold;");
@@ -105,6 +123,11 @@ window.addEventListener("load", function() {
<!-- <pre id="json"></pre><br> -->
+ <div id="index_container" class="invisible">
+ <h3>Codepoint <span id="index_input"></span></h3>
+ <div id="index" class="table"></div>
+ </div>
+
<h3>Characters <span id="chars_num"></span></h3>
<div id="chars" class="table"></div>