Skip to content

Commit

Permalink
Only show shortened name by default
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jan 19, 2024
1 parent 9edb870 commit 9f4bfb4
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lippukala/templates/lippukala/pos.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@
return div.innerHTML;
}

function shortenName(name) {
if (name) {
const [word1, word2] = name.trim().split(/\s+/);
return `${word1} ${word2[0]}.`;
}
return "";
}

function Tee(template, env) {
return template.replace(/\{(.+?)\}/g, (_, m) => escapeHtml(env[m] || "").replace(/\n/g, "<br>"));
}
Expand All @@ -79,8 +87,8 @@
if (code) {
currentlyShownId = code.id;
statusDiv.innerHTML = Tee(
"<div class=cd><span class=pfx>{prefix}</span>{code}</div>{lit}<div class=product>{prod}</div><div class=addr>{name}</div><div class=comment>{comment}</div>",
code,
"<div class=cd><span class=pfx>{prefix}</span>{code}</div>{lit}<div class=product>{prod}</div><div class=addr>{short_name}<div class=fulladdr>{name}</div></div><div class=comment>{comment}</div>",
{ ...code, short_name: shortenName(code.name) },
);
let cls = "code-unused";
if (code.used) cls = "code-used";
Expand Down Expand Up @@ -302,6 +310,18 @@
color: #fff;
}

.fulladdr {
font-size: 75%;
margin-top: 0.5em;
color: transparent;
border: 1px dashed rgb(255, 255, 255, 0.5);
}

.fulladdr:hover {
color: inherit;
border-color: transparent;
}

#codeform {
margin: auto;
text-align: center;
Expand Down

0 comments on commit 9f4bfb4

Please sign in to comment.