refactor(frontend): encapsulate JS state, add wikipedia TOC tree visualization, collapsible nodes, language select, and favicon animation

This commit is contained in:
Tibo De Peuter 2026-08-18 18:21:56 +02:00
parent 31a5808b81
commit 80ba98478b
3 changed files with 741 additions and 170 deletions

339
style.css
View file

@ -1,17 +1,16 @@
/*
Waarschijnlijk eerder de enigste file die niet deftig gedocumenteerd is.
Ach, de kans dat jullie dit bekijken is hoe dan ook klein.
*/
/* Algemeen */
body {
font-family: 'Linux Libertine','Georgia','Times',serif;
font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
padding: 0 1.5em 1.5em 1.5em;
line-height: 1.6;
margin: 0;
color: #202122;
background-color: #ffffff;
}
h1 {
font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
margin-bottom: 0.25em;
padding: 0;
line-height: 1.3;
@ -20,97 +19,365 @@ h1 {
border-bottom: 1px solid #a2a9b1;
}
li ul {
margin: 0.2vh 1ch 0 1ch;
padding: 0.2vh 1vw;
}
/* Header */
.header {
display: flex;
align-items: center;
gap: 0.8em;
padding: 0.5em 0;
}
.header img {
height: 1.8em;
margin-top: 0.3em;
float: left;
height: 2.2em;
width: auto;
flex-shrink: 0;
}
.header-content {
flex: 1;
}
.header h1 {
font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
margin: 0;
padding: 0;
line-height: 1.2;
font-size: 1.8em;
font-weight: normal;
border-bottom: none;
}
.header p {
font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
margin: 0.2em 0 0 0;
font-size: 92%;
display: block;
color: #202122;
font-family: sans-serif;
}
/* Box */
/* Loading Animation */
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.spinning {
animation: spin 1.2s linear infinite;
will-change: transform;
}
/* Controls & Box Layout */
.box {
font-family: sans-serif;
font-size: 95%;
padding: 7px;
padding: 10px 14px;
border: 1px solid #a2a9b1;
background-color: #f8f9fa;
color: #202122;
position: sticky;
top: 7px;
}
.box p {
padding: 0;
margin: 0;
main > .box:first-child {
position: sticky;
top: 7px;
z-index: 10;
}
.form-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px 12px;
}
.form-group {
display: inline-flex;
align-items: center;
gap: 4px;
}
.form-group input[type="text"],
.form-group select {
padding: 3px 6px;
border: 1px solid #a2a9b1;
border-radius: 2px;
font-size: 0.95em;
font-family: sans-serif;
background-color: #ffffff;
}
#taal {
min-width: 9em;
}
#start, #einde {
min-width: 140px;
flex: 1 1 auto;
}
/* Full-Width Statistics Box at Bottom */
.stats-box {
margin-top: 1.2em;
}
.stats-box[hidden] {
display: none !important;
}
.stats-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px 24px;
font-size: 92%;
}
.stat-item {
display: inline-flex;
align-items: center;
gap: 6px;
}
.stat-label {
color: #54595d;
font-weight: bold;
}
.stat-val {
color: #202122;
}
.stats-row button#wisKnop {
margin-left: auto;
}
/* Warning & Error Banners */
#waarschuwing {
display: block;
margin-top: 8px;
font-size: 90%;
color: #54595d;
}
#waarschuwing[hidden] {
display: none !important;
}
#waarschuwing b {
color: #ba0000;
}
/* Visualisatie */
.error-banner {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 8px;
padding: 8px 12px;
background-color: #fdf2f2;
border: 1px solid #d33;
border-left: 4px solid #ba0000;
color: #721c24;
border-radius: 2px;
font-size: 90%;
animation: fadeIn 0.2s ease-in-out;
}
.error-banner[hidden] {
display: none !important;
}
.error-message {
flex: 1;
word-break: break-word;
}
.error-dismiss {
background: none;
border: none;
color: #ba0000;
font-size: 1.3em;
line-height: 1;
cursor: pointer;
padding: 0 4px;
margin-left: 8px;
}
.error-dismiss:hover {
color: #000;
text-decoration: none;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(-3px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Wikipedia Table of Contents (TOC) Style Visualisatie */
#visualisatie {
margin: 0.5em 0;
font-size: 1em;
margin: 1em 0;
font-family: sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
font-size: 0.92em;
line-height: 1.7;
overflow-x: auto;
max-width: 100%;
padding-bottom: 0.5em;
}
#visualisatie ul {
list-style-type: symbols("⬑"); /* alternatieven "↪" "⬉" */
list-style-type: none;
padding-left: 1.2em;
margin: 0.15em 0;
}
ul#wortel {
padding: 0;
padding-left: 0;
list-style-type: none;
font-weight: bold;
}
ul#wortel > li > a.wiki-link {
font-weight: bold;
color: #202122;
font-size: 1.05em;
}
#visualisatie li {
padding: 0.1em 0;
position: relative;
white-space: nowrap;
}
/* Clickable Wikipedia Article Links - Wikipedia Blue */
#visualisatie a.wiki-link {
color: #3366bb;
text-decoration: none;
white-space: nowrap;
transition: color 0.1s, text-decoration 0.1s;
}
#visualisatie a.wiki-link:hover {
color: #0645ad;
text-decoration: underline;
}
#visualisatie a.wiki-link:visited {
color: #0b0080;
}
/* Pixel-Perfect Tree Connector Lines:
- Primary branch (Branch 1) draws a clean vertical line starting at parent and ending at split point.
- Secondary branch (Branch 2) draws a horizontal tick starting at x=0 that seamlessly meets the vertical line. */
#visualisatie ul.branch-primary {
border-left: 2px solid #3366bb;
padding-left: 1.2em;
margin-left: 0;
}
#visualisatie ul.branch-split {
margin-top: 6px;
padding-left: 1.2em;
position: relative;
}
#visualisatie ul.branch-split::before {
content: "";
position: absolute;
top: 0.85em;
left: 0;
width: 0.85em;
height: 0;
border-top: 2px solid #3366bb;
}
/* Collapsible Node Toggle Chevron (Wikipedia Style) */
.toggle-btn {
display: inline-block;
cursor: pointer;
user-select: none;
font-size: 70%;
margin-right: 5px;
color: #72777d;
transition: transform 0.15s ease;
width: 0.9em;
text-align: center;
vertical-align: middle;
}
.toggle-btn:hover {
color: #202122;
}
li.collapsed > ul {
display: none !important;
}
li.collapsed > .toggle-btn {
transform: rotate(-90deg);
}
/* Loop node marker in tree */
.loop-marker {
display: inline-block;
margin-left: 6px;
padding: 1px 6px;
font-size: 80%;
font-family: sans-serif;
border-radius: 2px;
background-color: #fcf3cf;
color: #7d6608;
border: 1px solid #f9e79f;
font-weight: normal;
}
/* Footer */
footer {
text-align: center;
margin-top: 1.5em;
}
/* Wikipedia-achtige knop */
/* Wikipedia Buttons */
button {
cursor: pointer;
border: none;
background: none;
color: #3366bb;
font-size: 0.95em;
}
button:disabled {
color: #ba0000;
color: #72777d;
cursor: not-allowed;
}
button:hover {
button:not(:disabled):hover {
text-decoration: underline;
}
button:before {
#toevoegKnop:before {
color: #54595d;
margin-right: 0.25em;
content: "[";
}
button:after {
#toevoegKnop:after {
color: #54595d;
margin-left: 0.25em;
content: "]";