tracker/templates/file.html
{{define "file"}}<!doctype html>
<html lang="th">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<script>/* apply the saved theme before first paint */try{var t=localStorage.getItem("tracker-theme");if(t==="light"||t==="dark")document.documentElement.dataset.theme=t}catch(e){}</script>
<title>{{.Title}} | ไฟล์ใน repo</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bai+Jamjuree:wght@500;600;700&family=IBM+Plex+Sans+Thai:wght@400;500;600&display=swap">
<link rel="stylesheet" href="{{asset "style.css"}}">
</head>
<body class="viewer">
<header class="viewer-bar">
<a class="viewer-home" href="/">ความคืบหน้างาน</a>
{{template "crumbs" .Crumbs}}
{{if .RawHref}}<a class="viewer-raw" href="{{.RawHref}}">ไฟล์ต้นฉบับ</a>{{end}}
</header>
<div class="viewer-shell{{if .TOC}} has-toc{{end}}">
{{if .TOC}}
<nav class="viewer-toc" aria-label="สารบัญ">
<p class="viewer-toc-head">สารบัญ</p>
<ol>{{range .TOC}}{{if ne .Level 1}}<li class="toc-l{{.Level}}"><a href="#{{.ID}}">{{.Text}}</a></li>{{end}}{{end}}</ol>
</nav>
{{end}}
<main class="viewer-main" id="main">
{{if .Filtered}}
<div class="viewer-filter">
<label for="row-filter">ค้นหาในตาราง</label>
<input id="row-filter" type="search" placeholder="เช่น การเงิน, DEAN, L4, W-14" autocomplete="off">
<span class="viewer-filter-count" id="row-filter-count" aria-live="polite"></span>
</div>
{{end}}
{{if eq .Kind "markdown"}}
<article class="doc md">{{.HTML}}</article>
{{else if eq .Kind "text"}}
<h1 class="viewer-title">{{.Path}}</h1>
<pre class="viewer-code"><code>{{.Text}}</code></pre>
{{else if eq .Kind "dir"}}
<h1 class="viewer-title">{{if .Path}}{{.Path}}/{{else}}repo{{end}}</h1>
<ul class="viewer-dir">
{{range .Entries}}<li class="{{if .IsDir}}is-dir{{end}}"><a href="{{.Href}}">{{.Name}}{{if .IsDir}}/{{end}}</a></li>{{else}}<li class="muted">โฟลเดอร์ว่าง</li>{{end}}
</ul>
{{else}}
<h1 class="viewer-title">{{.Path}}</h1>
<p class="empty">ไฟล์ชนิดนี้แสดงในเบราว์เซอร์ไม่ได้ <a href="{{.RawHref}}">ดาวน์โหลดไฟล์</a></p>
{{end}}
</main>
</div>
{{if .Filtered}}
<script>
// Row filter: hide table rows that do not contain the typed text.
(() => {
const input = document.getElementById("row-filter");
const count = document.getElementById("row-filter-count");
const rows = [...document.querySelectorAll(".doc table tbody tr")];
input.addEventListener("input", () => {
const q = input.value.trim().toLowerCase();
let shown = 0;
rows.forEach((tr) => {
const hit = !q || tr.textContent.toLowerCase().includes(q);
tr.hidden = !hit;
if (hit) shown++;
});
document.querySelectorAll(".doc .md-table").forEach((t) => {
t.hidden = q !== "" && !t.querySelector("tbody tr:not([hidden])");
});
count.textContent = q ? `พบ ${shown} แถว` : "";
});
})();
</script>
{{end}}
{{if eq .Kind "markdown"}}
<script type="module">
// Diagrams: render ```mermaid blocks when the page has any.
if (document.querySelector("pre.mermaid")) {
const { default: mermaid } = await import("https://cdn.jsdelivr.net/npm/mermaid@11.4.1/dist/mermaid.esm.min.mjs");
const dark = document.documentElement.dataset.theme === "dark" ||
(!document.documentElement.dataset.theme && matchMedia("(prefers-color-scheme: dark)").matches);
mermaid.initialize({ startOnLoad: false, theme: dark ? "dark" : "default", securityLevel: "strict" });
await mermaid.run({ querySelector: "pre.mermaid" });
}
</script>
{{end}}
</body>
</html>{{end}}