Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016679RwmHsuTFfxt26wP6rk
119 lines
6.8 KiB
HTML
119 lines
6.8 KiB
HTML
<!doctype html>
|
|
<html lang="lv">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Pašvaldību reģistrs</title>
|
|
<style>
|
|
:root { --bg:#ffffff; --fg:#1d2329; --muted:#5f6b76; --line:#dde2e7; --head:#f4f6f8; --accent:#0b5cad; --tag:#eef3f9; }
|
|
@media (prefers-color-scheme: dark) { :root { --bg:#16191d; --fg:#e4e8ec; --muted:#9aa5b0; --line:#2c3238; --head:#1e2328; --accent:#6aa7e8; --tag:#1f2a36; } }
|
|
* { box-sizing: border-box; }
|
|
body { margin:0; background:var(--bg); color:var(--fg); font:14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
|
|
main { max-width: 980px; margin: 0 auto; padding: 16px; }
|
|
h1 { font-size: 20px; margin: 0 0 4px; }
|
|
.meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
|
|
.meta a { color: var(--accent); }
|
|
.bar { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom: 10px; }
|
|
input[type=search], select { font: inherit; color: var(--fg); background: var(--bg); border:1px solid var(--line); border-radius:6px; padding:6px 8px; }
|
|
input[type=search] { flex: 1 1 220px; }
|
|
.count { color: var(--muted); font-size: 13px; margin-left: auto; }
|
|
.wrap { overflow-x: auto; border:1px solid var(--line); border-radius: 8px; }
|
|
table { border-collapse: collapse; width: 100%; }
|
|
th, td { text-align:left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
|
|
th { background: var(--head); font-weight: 600; font-size: 13px; position: sticky; top: 0; }
|
|
tr:last-child td { border-bottom: 0; }
|
|
td.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
|
|
.tag { display:inline-block; padding: 1px 8px; border-radius: 10px; background: var(--tag); font-size: 12px; }
|
|
.note { color: var(--muted); font-size: 12px; margin-top: 12px; }
|
|
.err { color: #b3261e; }
|
|
.pgv { display:none; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<div class="pgv" id="pgv"></div>
|
|
<h1 id="title">Pašvaldību reģistrs</h1>
|
|
<div class="meta" id="meta">Ielādē…</div>
|
|
<div class="bar">
|
|
<input type="search" id="q" placeholder="Meklēt pēc nosaukuma vai ATVK koda" aria-label="Meklēt">
|
|
<select id="kind" aria-label="Tips">
|
|
<option value="">Visi tipi</option>
|
|
<option value="valstspilseta">Valstspilsētas</option>
|
|
<option value="novads">Novadi</option>
|
|
</select>
|
|
<span class="count" id="count"></span>
|
|
</div>
|
|
<div class="wrap">
|
|
<table>
|
|
<thead><tr><th>ATVK kods</th><th>Nosaukums</th><th>Tips</th><th>Iepriekšējie kodi</th></tr></thead>
|
|
<tbody id="rows"></tbody>
|
|
</table>
|
|
</div>
|
|
<p class="note">Pašvaldības identifikators citās Valsts PirmKods datu kopās ir ATVK kods. Juridiski saistošs ir oficiālajā izdevumā „Latvijas Vēstnesis” publicētais normatīvā akta teksts. PPPA koncepcijas demonstrācija, nav oficiāls valsts reģistrs.</p>
|
|
</main>
|
|
<script>
|
|
(function () {
|
|
"use strict";
|
|
var NS = "urn:pppa:vpk:pasvaldibas:0.1", KIND = { valstspilseta: "valstspilsēta", novads: "novads" }, ROWS = [];
|
|
function $(id) { return document.getElementById(id); }
|
|
function kids(el, name) { return Array.prototype.filter.call(el.childNodes, function (n) { return n.nodeType === 1 && n.localName === name && n.namespaceURI === NS; }); }
|
|
function text(el, name) { var k = kids(el, name)[0]; return k ? k.textContent.trim() : ""; }
|
|
function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return { "&": "&", "<": "<", ">": ">", '"': """ }[c]; }); }
|
|
|
|
function show(xmlText) {
|
|
var doc = new DOMParser().parseFromString(xmlText, "application/xml"), root = doc.documentElement;
|
|
if (!root || root.localName !== "MunicipalityRegistry" || root.namespaceURI !== NS) throw new Error("datne nav pašvaldību reģistrs");
|
|
var md = kids(root, "Metadata")[0], src = kids(md, "Source")[0], dv = kids(md, "DataVersion")[0];
|
|
$("title").textContent = text(md, "Title") || "Pašvaldību reģistrs";
|
|
var url = text(src, "Url");
|
|
$("meta").innerHTML = esc(text(src, "Act")) + (url ? ' · <a href="' + esc(url) + '" target="_blank" rel="noopener">likumi.lv</a>' : "") +
|
|
"<br>Spēkā no " + esc(src.getAttribute("inForce") || "") + " · datu versija " + esc(dv.getAttribute("number")) + " (" + esc(dv.getAttribute("date")) + ")";
|
|
ROWS = kids(root, "Municipality").map(function (m) {
|
|
return { atvk: m.getAttribute("atvk"), name: text(m, "Name"), kind: m.getAttribute("kind"),
|
|
former: kids(m, "FormerCode").map(function (f) { return f.textContent.trim(); }).join(", ") };
|
|
});
|
|
render();
|
|
}
|
|
|
|
function render() {
|
|
var q = $("q").value.trim().toLowerCase(), k = $("kind").value;
|
|
var list = ROWS.filter(function (r) {
|
|
return (!k || r.kind === k) && (!q || r.name.toLowerCase().indexOf(q) >= 0 || r.atvk.indexOf(q) >= 0 || r.former.indexOf(q) >= 0);
|
|
});
|
|
$("rows").innerHTML = list.map(function (r) {
|
|
return '<tr><td class="code">' + esc(r.atvk) + "</td><td>" + esc(r.name) + '</td><td><span class="tag">' + esc(KIND[r.kind] || r.kind) +
|
|
'</span></td><td class="code">' + esc(r.former) + "</td></tr>";
|
|
}).join("");
|
|
$("count").textContent = list.length + " no " + ROWS.length;
|
|
}
|
|
|
|
function fail(e) { $("meta").innerHTML = '<span class="err">Neizdevās ielādēt datni: ' + esc(e.message || e) + "</span>"; }
|
|
$("q").addEventListener("input", render);
|
|
$("kind").addEventListener("change", render);
|
|
|
|
/* ProcessGit skatītājs (data/processgit.viewer.json): PGV_READY → PGV_INIT → PGV_FETCH */
|
|
function pgvFetch(url) {
|
|
return new Promise(function (res, rej) {
|
|
var tm = setTimeout(function () { removeEventListener("message", hd); rej(new Error("PGV_FETCH timeout")); }, 15000);
|
|
function hd(ev) { var m = ev.data; if (!m || m.type !== "PGV_FETCH_RESULT" || m.url !== url) return;
|
|
clearTimeout(tm); removeEventListener("message", hd); m.ok ? res(m.text) : rej(new Error(m.error || "fetch failed")); }
|
|
addEventListener("message", hd); parent.postMessage({ type: "PGV_FETCH", url: url }, "*");
|
|
});
|
|
}
|
|
if (window.parent && window.parent !== window) {
|
|
addEventListener("message", function (ev) {
|
|
var m = ev.data; if (!m || typeof m !== "object" || m.type !== "PGV_INIT") return;
|
|
var p = m.payload || {}, url = (p.targets && p.targets.xml) || (p.repoLink + "/raw/branch/" + p.branch + "/" + p.path);
|
|
var bar = $("pgv"); bar.style.display = "block";
|
|
bar.textContent = "ProcessGit · " + (p.branch || "") + " · " + (p.path || "") + (p.lastCommit ? " · " + p.lastCommit.slice(0, 7) : "");
|
|
pgvFetch(url).then(show).catch(fail);
|
|
});
|
|
try { parent.postMessage({ type: "PGV_READY" }, "*"); } catch (e) {}
|
|
} else {
|
|
fetch("../data/pasvaldibas-atvk.xml").then(function (r) { if (!r.ok) throw new Error("HTTP " + r.status); return r.text(); }).then(show).catch(fail);
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|