diff options
Diffstat (limited to 'assets')
-rw-r--r-- | assets/logo.svg | 1 | ||||
-rw-r--r-- | assets/script.js | 48 | ||||
-rw-r--r-- | assets/style.css | 40 |
3 files changed, 89 insertions, 0 deletions
diff --git a/assets/logo.svg b/assets/logo.svg new file mode 100644 index 0000000..45de364 --- /dev/null +++ b/assets/logo.svg @@ -0,0 +1 @@ +<svg height="360.71" width="242.76" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="b" gradientTransform="matrix(-1 0 0 -.7998 213.15 303.4)" gradientUnits="userSpaceOnUse" x1="171.09" x2="20.17" xlink:href="#a" y1="112.23" y2="112.23"/><linearGradient id="a"><stop offset="0" stop-color="#32a8ff"/><stop offset="1" stop-color="#3d5cff"/></linearGradient><linearGradient id="c" gradientTransform="matrix(1 0 0 .7998 20.85 0)" gradientUnits="userSpaceOnUse" x1="51.7" x2="17" xlink:href="#a" y1="80" y2="201.2"/><path d="M124.85 303.4c41.3-.4 68.5-20.95 68.5-52.95 0-19.2-6.4-28.39-32.6-47.5l-33.7-22.4c-2.7-1.6-5.5-3.36-8.7-5.6l-6.9-4.8-16.5-11.35c-14.3-9.92-19.8-16.88-19.8-24.24.44-11.07 11.96-19.78 25.8-19.51 10.5.55 20.52 3.68 28.7 8.96v-.08l-38-22.88h-2.7c-26.7 0-48.3 20.64-48.3 46.39 0 11.76 3.2 20.95 11 30.87 8.76 11.33 19.8 21.41 32.7 29.83l49.8 26.64c17.9 11.2 27 21.91 24.2 31.35-3 10.88-18 19.5-38.2 20.39-20.2.8-44.7-8.16-44.7-8.16-8.2 20.8 41.8 25.04 49.4 25.04z" fill="url(#b)"/><path d="M109.15 0c-41.3.4-68.5 20.95-68.5 52.95 0 19.2 6.4 28.39 32.6 47.5l33.7 22.4c2.7 1.6 5.5 3.36 8.7 5.6l6.9 4.8 16.5 11.35c14.3 9.92 19.8 16.88 19.8 24.24-.43 11.07-11.95 19.78-25.8 19.51-10.49-.55-20.51-3.67-28.7-8.96v.08l38 22.88h2.7c26.7 0 48.3-20.64 48.3-46.39 0-11.76-3.2-20.95-11-30.87-8.75-11.33-19.8-21.41-32.7-29.83l-49.8-26.64c-17.9-11.2-27-21.91-24.2-31.35 3-10.88 18-19.5 38.2-20.39 20.2-.8 44.7 8.16 44.7 8.16C166.75 4.24 116.75 0 109.15 0z" fill="url(#c)"/><ellipse cx="207.61" cy="78.82" fill="#47e0e1" rx="79" ry="17.8" transform="rotate(37.5)"/><g fill="none" stroke="#000" stroke-linecap="round" stroke-linejoin="round"><path d="M103.55 171.65l1-30.4 57.7-7.9-25.2 24 3.8 44.7" stroke-width="15.5"/><path d="M162.25 133.35l-21-45.1-37.5 11.8m37.5-11.8l41 17.3" stroke-width="15"/></g><circle cx="141.55" cy="60.55" r="15.7"/><g stroke-width="121.41"><path d="M0 360.03v-50.4h9.54v50.4zM34.34 360.7q-8.29 0-12.74-4.88-4.45-4.93-4.45-14.34 0-9.1 4.52-14 4.52-4.88 12.8-4.88 7.92 0 12.1 5.26 4.18 5.23 4.18 15.36v.27H27.17q0 5.36 1.97 8.12 2 2.71 5.68 2.71 5.06 0 6.38-4.38l9 .78q-3.9 9.99-15.86 9.99zm0-32.09q-3.36 0-5.2 2.34-1.8 2.35-1.9 6.56h14.27q-.27-4.45-2.14-6.66-1.87-2.24-5.03-2.24zM80.98 360.03l-8.56-13.32-8.63 13.32H53.63l13.46-18.99-12.81-17.76h10.3l7.84 12.02 7.81-12.02h10.36l-12.8 17.66 13.55 19.09zM96.6 360.03v-10.36h9.82v10.36zM147.01 349.3q0 5.33-4.38 8.39-4.35 3.02-12.06 3.02-7.57 0-11.62-2.38-4-2.41-5.33-7.47l8.39-1.26q.71 2.62 2.45 3.7 1.76 1.1 6.11 1.1 4 0 5.84-1.03 1.84-1.02 1.84-3.2 0-1.76-1.5-2.78-1.46-1.05-5-1.76-8.08-1.6-10.9-2.96-2.81-1.39-4.3-3.56-1.47-2.21-1.47-5.4 0-5.27 4.04-8.2 4.08-2.95 11.52-2.95 6.55 0 10.53 2.55 4 2.55 5 7.37l-8.47.89q-.4-2.25-2-3.33-1.6-1.12-5.06-1.12-3.4 0-5.1.88-1.7.85-1.7 2.89 0 1.6 1.3 2.54 1.32.92 4.41 1.53 4.31.89 7.64 1.84 3.37.91 5.37 2.2 2.04 1.3 3.23 3.33 1.22 2 1.22 5.17zM163.76 323.28v20.62q0 9.68 6.52 9.68 3.46 0 5.57-2.96 2.14-2.99 2.14-7.64v-19.7h9.54v28.53q0 4.69.27 8.22h-9.1q-.4-4.9-.4-7.3h-.18q-1.9 4.17-4.85 6.08-2.92 1.9-6.97 1.9-5.84 0-8.96-3.57-3.13-3.6-3.13-10.53v-23.33zM197.28 360.03v-28.12q0-3.03-.1-5.03-.07-2.04-.17-3.6h9.1q.1.6.27 3.73.17 3.1.17 4.11h.14q1.4-3.87 2.48-5.43 1.09-1.6 2.58-2.34 1.5-.79 3.74-.79 1.83 0 2.95.51v7.99q-2.3-.51-4.07-.51-3.57 0-5.57 2.88-1.97 2.9-1.97 8.56v18.04zM235.53 329.73v30.3h-9.51v-30.3h-5.37v-6.45h5.37v-3.84q0-5 2.65-7.4 2.65-2.42 8.05-2.42 2.68 0 6.04.55v6.14q-1.39-.3-2.78-.3-2.45 0-3.47.98-.98.95-.98 3.4v2.89h7.23v6.45z"/></g></svg>
\ No newline at end of file diff --git a/assets/script.js b/assets/script.js new file mode 100644 index 0000000..4b4b5c5 --- /dev/null +++ b/assets/script.js @@ -0,0 +1,48 @@ +const searchInput = document.getElementById('search'); +const suggestionsDiv = document.getElementById('suggestions'); + +(async function(){ + const res = await fetch('/laws.json'); + const laws = await res.json(); + searchInput.addEventListener('input', (e) => { + if (searchInput.value == '') { + suggestionsDiv.innerHTML = ''; + return; + } + + const titleRegex = new RegExp(searchInput.value, 'i'); + const abbrRegex = new RegExp('^' + searchInput.value, 'i'); + const suggestions = []; + + laws.map(l => { + const titleMatch = titleRegex.exec(l.title); + const abbrMatch = abbrRegex.exec(l.abbr); + + return { + law: l, + titleScore: titleMatch ? titleMatch.index : Number.MAX_VALUE, + abbrScore: abbrMatch ? abbrMatch.index: Number.MAX_VALUE, + } + }) + .filter(l => l.titleScore < Number.MAX_VALUE || l.abbrScore < Number.MAX_VALUE) + .sort((a,b) => { + let abbrDiff = a.abbrScore - b.abbrScore; + if (a.law.abbr && b.law.abbr && abbrDiff == 0 && a.abbrScore != Number.MAX_VALUE) { + abbrDiff = a.law.abbr.length - b.law.abbr.length; + } + return abbrDiff || a.titleScore - b.titleScore; + }) + .slice(0, 30) + .forEach(x => { + const l = x.law; + const a = document.createElement('a'); + a.href = l.url; + a.textContent = l.title; + const li = document.createElement('li'); + li.appendChild(a); + suggestions.push(li); + }); + + suggestionsDiv.replaceChildren(...suggestions); + }); +})(); diff --git a/assets/style.css b/assets/style.css new file mode 100644 index 0000000..3b064c2 --- /dev/null +++ b/assets/style.css @@ -0,0 +1,40 @@ +body { + font-family: Roboto, Helvetica, Arial, sans-serif; + max-width: 500px; + margin: 0.5em auto; + text-align: center; +} + +.countries { + text-align: left; + border: 1px solid #ccc; + border-radius: 5px; + + display: grid; + grid-template-columns: repeat(auto-fit, minmax(50px, 1fr)); +} + +.cc-link { + display: inline-block; + line-height: 50px; + text-align: center; + color: inherit; + text-decoration: navajowhite; + font-size: 1.2em; + border: 2px solid transparent; + box-sizing: border-box; +} + +.cc-link:hover { + background: #e6f3ff; + border-radius: 5px; +} + +h2 { + font-weight: normal; + margin-top: 0.5em; +} + +#suggestions { + text-align: left; +}
\ No newline at end of file |