on master help sign in
Indice navigation JS (first time)
commit209a84c36a2ed4bc424f6b8d33590727fb332845 authorMatilde Park <matilde@tlon.io> dateTue 10 Sep 2019, 14:53 (7 years ago) parent7840b9c
4 files changed+49−14
content/faq.md+2−2 sass/_main.scss+3 static/scripts.js+43−11 templates/page_indiced.html+1−1
content/faq.md+2−2
@@ -53,13 +53,13 @@ Moons are 64 bits, issued by planets, and have names like `~doznec-salfun-naptul
5353
5454Comets are 128 bits and have no parents. They can be launched by anyone. They are temporary, disposable identities. Being disposable and essentially unlimited, they will likely not be trusted by default by others on the Arvo network, though you shouldn't have any problem until the network grows much larger. They have long, hard-to-memorize names, like `~racmus-mollen-fallyt-linpex--watres-sibbur-modlux-rinmex`.
5555
56−### What is a `@p`? Why is my username generated for me? {#what-is-@p}
56+### What is a `@p`? Why is my username generated for me? {#what-is-patp}
5757
5858A `@p` (pronounced *pat-pee*) is a name like `~zod` or `~lodleb-ritrul` composed of pronounceable, three-letter phonemic elements like `zod`, `lod`, `leb`, `rit` and `rul`. Shorter names, such as `~zod` and `~marzod`, are assigned to ships with special duties on the Arvo network ([stars and galaxies](@/docs/concepts/galaxies-stars-and-planets.md), respectively. Longer names like `~palfun-foslup` are identities for typical users.
5959
6060These names map directly to a corresponding number in the urbit address space. Galaxies occupy the 8-bit address space, so any galaxy is actually a number between zero and 255. Stars occupy the 16-bit address space, and planets occupy the 32-bit address space.
6161
62−### Can I change my `@p`? {#change-my-@p}
62+### Can I change my `@p`? {#change-my-patp}
6363
6464Unfortunately not, since there is a 1:1 mapping between name and point.
6565
sass/_main.scss+3
@@ -391,4 +391,7 @@ body.page-indiced {
391391 max-height: 100vh;
392392 overflow-y: scroll;
393393 }
394+ a.current {
395+ font-weight: 600;
396+ }
394397}
static/scripts.js+43−11
@@ -314,18 +314,7 @@ if (document.readyState === "complete" ||
314314 });
315315}
316316
317−// Scroll to current document in nav list.
318−// let docsNavScroll = function() {
319−// let docsNav = document.querySelectorAll("ul.content-nav__index a")
320−// for (let link in docsNav) {
321−// if (window.location.href.includes(docsNav[link].href)) {
322−// docsNav[link].scrollIntoView()
323−// }
324−// }
325−//}
326−
327317if (window.location.href.includes("docs")) {
328−// docsNavScroll();
329318 tippy('.tooltip', {
330319 content(reference) {
331320 const title = reference.getAttribute('title')
@@ -335,4 +324,47 @@ if (window.location.href.includes("docs")) {
335324 animateFill: false,
336325 animation: 'fade'
337326 })
327+}
328+
329+// same-page navigation on-scroll behaviour
330+
331+if (document.body.classList.contains("page-indiced")) {
332+let h2 = document.getElementsByTagName("h2");
333+let h3 = document.getElementsByTagName("h3");
334+let all = document.querySelectorAll("nav details li a");
335+let headers = document.querySelectorAll("details summary");
336+
337+// smooth scrolling on click
338+all.forEach(link => {
339+ link.addEventListener("click", event => {
340+ event.preventDefault();
341+ let target = document.querySelector(event.target.hash);
342+ target.scrollIntoView({
343+ behavior: "smooth",
344+ block: "start"
345+ });
346+ });
347+});
348+
349+let lastId;
350+let cur = [];
351+
352+window.addEventListener("scroll", event => {
353+ let fromTop = window.scrollY;
354+
355+ all.forEach(link => {
356+ let section = document.querySelector(link.hash);
357+
358+ if (
359+ section.offsetTop <= fromTop &&
360+ section.offsetTop + section.offsetHeight > fromTop
361+ ) {
362+ link.classList.add("current");
363+ } else {
364+ link.classList.remove("current");
365+ }
366+ });
367+
368+});
369+
338370}
templates/page_indiced.html+1−1
@@ -38,7 +38,7 @@
3838{% if h2.children %}
3939<details class="page-indiced"><summary>{{ h2.title }}</summary>
4040 {% for h3 in h2.children %}
41− <li class="ml3 mv1"><a href="{{h3.permalink}}">{{h3.title}}</a></li>
41+ <li class="ml3 mv1"><a href="{{h3.permalink | safe}}">{{h3.title}}</a></li>
4242 {% endfor %}
4343</details>
4444{% else %}