diff --git a/index.html b/index.html index dffc768..bc0dd68 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ -Нарушения законодательства РК — справочник +Нарушения законодательства РК — поиск по НПА @@ -176,11 +205,20 @@ footer a { color: var(--cyan); text-decoration: none; }
-

📜 Нарушения законодательства РК

-

Опишите ситуацию или введите ключевые слова — найдём соответствующие статьи кодексов, законов и правил РК.

-
@@ -214,7 +252,7 @@ footer a { color: var(--cyan); text-decoration: none; } @@ -332,6 +370,25 @@ function matchesQuery(v, query) { ); } +function adiletSearchUrl(query) { + const src = query || currentQuery; + return "https://adilet.zan.kz/rus/search/all?q=" + encodeURIComponent(src.trim()); +} + +function updateAdiletBar() { + const bar = document.getElementById("adiletBar"); + const queryEl = document.getElementById("adiletQuery"); + const btn = document.getElementById("adiletBtn"); + const q = currentQuery.trim(); + if (q.length > 0) { + bar.classList.add("active"); + queryEl.textContent = q; + btn.href = adiletSearchUrl(q); + } else { + bar.classList.remove("active"); + } +} + function render(results, query) { const grid = document.getElementById("results"); const empty = document.getElementById("empty"); @@ -347,8 +404,9 @@ function render(results, query) { return; } empty.style.display = "none"; - grid.innerHTML = results.map(v => ` -
+ grid.innerHTML = results.map(v => { + const searchQ = encodeURIComponent(v.article + " " + v.desc.split(" —")[0]); + return `

${highlight(v.desc, query)}

@@ -358,9 +416,10 @@ function render(results, query) {
Наказание: ${v.penalty} + 🔗 Открыть на adilet.zan.kz
-
- `).join(""); +
`; + }).join(""); } function filterAndSearch() { @@ -372,6 +431,7 @@ function filterAndSearch() { results = results.filter(v => matchesQuery(v, currentQuery)); } render(results, currentQuery); + updateAdiletBar(); } function search() { @@ -388,7 +448,14 @@ function setFilter(code, btn) { document.getElementById("search").addEventListener("input", search); document.getElementById("search").addEventListener("keydown", function(e) { - if (e.key === "Enter") search(); + if (e.key === "Enter") { + currentQuery = this.value; + filterAndSearch(); + updateAdiletBar(); + if (currentQuery.trim()) { + window.open(adiletSearchUrl(currentQuery.trim()), "_blank"); + } + } }); filterAndSearch();