' + + '"); continue; } @@ -307,6 +321,77 @@ tocEl.appendChild(ul); } + /* Every document in index order, with the group it belongs to. */ + var FLAT = []; + DOCS.forEach(function (g) { + g.items.forEach(function (it) { FLAT.push({ path: it[0], title: it[1], group: g.group }); }); + }); + function indexOf(path) { + for (var k = 0; k < FLAT.length; k++) if (FLAT[k].path === path) return k; + return -1; + } + + /* Where the reader is, how long it will take, and where the file lives -- + above the document, because a page arrived at from a search has no other + way to say which part of the docs it belongs to. */ + function header(path, text) { + var at = FLAT[indexOf(path)] || { group: "Docs", title: path }; + var words = text.split(/\s+/).length; + var mins = Math.max(1, Math.round(words / 230)); + return '' + + '' + esc(lang || "text") + "" + + '' + + " " + + '"); + ">" + esc(buf.join("\n")) + "" + esc(buf.join("\n")) + "
" + title + "
" + body; tocEl.hidden = true; @@ -322,8 +407,9 @@ return r.text(); }).then(function (text) { var headings = []; - article.innerHTML = render(text, path, headings); + article.innerHTML = header(path, text) + render(text, path, headings) + pager(path); buildToc(headings); + watchHeadings(); article.removeAttribute("aria-busy"); if (headings.length) document.title = headings[0].text + " — SchOS docs"; var hash = location.hash.slice(1); @@ -340,7 +426,7 @@ "Browsers block fetch() on file:// URLs, so the " +
"reader cannot load the Markdown. The rest of the site works from a file; " +
"this page does not. Serve the repository root:
cd /home/nexoniarz/Dokumenty/Projects/SchOS\n' +
+ 'cd path/to/SchOS\n' +
"python3 -m http.server 8000
" +
"Then open http://localhost:8000/docs/Website/docs.html.
" +
'Or read this one directly: ' + esc(path) + "
");
@@ -365,6 +451,54 @@
buildNav();
load(pathFromUrl());
+ /* Fold the index on a narrow screen, and fold it again after picking a
+ document there -- the choice is made, and the document is what was asked
+ for. */
+ var fold = document.getElementById("docindex");
+ var narrow = window.matchMedia && window.matchMedia("(max-width: 64rem)");
+ if (fold && narrow && narrow.matches) fold.open = false;
+ nav.addEventListener("click", function () {
+ if (fold && narrow && narrow.matches) fold.open = false;
+ });
+
+ /* Filter the index as you type. Groups with nothing left in them go too,
+ so the heading of an empty section does not sit there implying a match. */
+ var filter = document.getElementById("docfilter");
+ if (filter) filter.addEventListener("input", function () {
+ var q = filter.value.trim().toLowerCase();
+ Array.prototype.forEach.call(nav.querySelectorAll(".nv-nav__list"), function (ul) {
+ var any = false;
+ Array.prototype.forEach.call(ul.querySelectorAll("li"), function (li) {
+ var hit = !q || li.textContent.toLowerCase().indexOf(q) >= 0;
+ li.hidden = !hit;
+ any = any || hit;
+ });
+ ul.hidden = !any;
+ if (ul.previousElementSibling) ul.previousElementSibling.hidden = !any;
+ });
+ });
+
+ /* Copy a code block. The label says what happened, then goes back. */
+ article.addEventListener("click", function (ev) {
+ var b = ev.target.closest ? ev.target.closest("[data-copy]") : null;
+ if (!b) return;
+ var code = b.closest(".codeframe").querySelector("code").textContent;
+ var done = function (ok) {
+ b.textContent = ok ? "Copied" : "Select and copy";
+ setTimeout(function () { b.textContent = "Copy"; }, 1600);
+ };
+ if (navigator.clipboard) navigator.clipboard.writeText(code).then(function () { done(true); }, function () { done(false); });
+ else done(false);
+ });
+
+ /* How far down the document the reader is: a hairline under the bar. */
+ var bar = document.getElementById("readbar");
+ if (bar) window.addEventListener("scroll", function () {
+ var h = document.documentElement;
+ var f = h.scrollHeight > h.clientHeight ? h.scrollTop / (h.scrollHeight - h.clientHeight) : 0;
+ bar.style.transform = "scaleX(" + Math.min(1, Math.max(0, f)) + ")";
+ }, { passive: true });
+
/* Intercept in-page navigation so the reader does not reload its own shell. */
document.addEventListener("click", function (ev) {
var a = ev.target.closest ? ev.target.closest("a") : null;
diff --git a/docs/Website/index.html b/docs/Website/index.html
index d6c4818..80340e8 100644
--- a/docs/Website/index.html
+++ b/docs/Website/index.html
@@ -3,7 +3,7 @@
-SchOS — a 64-bit operating system written from scratch
+SchOS — every layer its own
@@ -47,6 +47,7 @@
What it has
Hybrid
Numbers
+ Wallpapers
@@ -69,7 +70,9 @@
-
+
+
+
@@ -77,9 +80,11 @@
-
SchOS
+
SchOS
+ Every layer its own — from the first instruction to the last pixel.
+
A 64-bit operating system written from scratch — its own kernel, its own
filesystem, its own bootloader. It boots on UEFI, drives real hardware,
@@ -109,13 +114,14 @@
+
+
+
+
+