added shiroa

This commit is contained in:
2025-04-23 22:51:03 +02:00
parent 35c0e7f876
commit e7fa48c168
47 changed files with 12885 additions and 17 deletions

View File

@@ -54,9 +54,6 @@ Grundlage fuer die ersten Wochen
Newton II. BWGL Newton II. BWGL
// Arrow und dot in typstar
// TODO: make it work with subscripts
$ $
dot(arrow(p)) = dif / (dif t) arrow(p) = m dot.double(r) = sum_(i=0)^(n) arrow(F_i) (arrow(r) dot(arrow(r))) dot(arrow(p)) = dif / (dif t) arrow(p) = m dot.double(r) = sum_(i=0)^(n) arrow(F_i) (arrow(r) dot(arrow(r)))
$ <bwg> $ <bwg>

View File

161
S2/CWR/VL/CwrVL2.typ Normal file
View File

@@ -0,0 +1,161 @@
// Diff template
#import "../preamble.typ": *
#show: conf.with(num: 2)
= Differentialgleichungen
ODEs
Mechankik: $dot.double(x) + omega_0 ^2 x=0$ ist eine ODE der Ordnung 2
$m dot.double(x) = F(x, dot(x), t)$ Newtons'sche Mechanik
zuruck fueren auf ein System von ODEs 1. Ordnung
Hamilton'sche Mechanik:
$
(partial HH(q, p)) / (partial d) = p/m, HH(q, p) = (p^2 ) / (2m) + V(q)\
dot(p)=-(partial HH) / (partial q) = - (partial V) / (partial q)
$
Anfangsbedingungen $q(t=0) = q_0 "und" p(t=0) = p_0 $.\
Beispiele sind Ratengleichungen, radioaktiver Zerfall und Populationsdynamik.
== Pearl-Unschulat Modell
$n(t): "Anzahl der Individuen"$
$
(dif n) / (dif t) = sqrt(n)n\
sqrt(n)="const"\
n(t) = n(0)exp(sqrt(t)) \
sqrt(n)=r_0 (1-k_n ), k="const">0
$
allgemeine Formulierung: $y^((n)) (t)=g (y, y', ..., y^((n+1)), t )$
$
y_(n)=y^((n)) \
y^((n+1))+y^((n)) = g(y,y_1 , ..., y_(n-1), t)\
y'_(n-2) =y_(n-1) \
y'=g_1
$
$
dot(arrow(y)) = arrow(g)(y_1, ..., y_(n-1) )\
(dif y) / (dif t) = g(y, t)
$
Diskretisierung der Zeit $[0, T], t_0 = 0, t_1 =Delta t, t_n =n Delta t=T$
$
y (t_i ) =y(t_(i-1)) +integral_(t_i )^(t_(i-1)) d t g (y (t), t) approx^("Euler-Cauchy") y (t_(i-1))+g (y (t_(i-1) , t_(i-1) )) Delta t + O(Delta t^2 )\
$
mit globalem Fehler bei Integration ueber $[Q, T]$
$
E ~ (T) / (Delta t) Delta t^2 ~ T Delta t ~ O(Delta t)
$
Beispiel Ratengleichung $r (n)=r- (1-k_n )$
$
n (t_i ) = n (t_(i-1) )+r_0 (1-k_n / t_(i-1) )n (t_(i-1) Delta t)\
n (t_i )=(1+Delta t r_0 )n (t_(i-1) ) (1- (Delta t r_0 k) / (1+ Delta t r_0 ) n (t_(i-1) ))
$
Variable $x (t_(i-1))=(Delta t r_0 k) / (1+Delta t r_0 ) n (t_(i-1) )$
$
x (t_i )=4 mu x (t_(i-1) ) (1- x (t_(i-1) )), 4 mu=1+Delta t r_0
$
Zuletzt: $Delta t$ klein
$
n (t)=1/k, x (t)=(Delta t r_0 ) / (1+ r_0 Delta t)=(4 mu-1) / (4 mu)
$
Pointcarre Abbildung mit Bifurkation.
== Leapfrog Algorithmus
// TODO: implement nl and Delta t in tyupstar as well as +
$
y'=g (y,t), y' (t_i ) (y (t_i )-y (t_(i-1) ) ) / (Delta t) + O (Delta t)\
y' (t_i )=(y (t_(i+1)) -y (t_(i-1) )) / (Delta t) + O (Delta t)
$
#highlight[TODO: Implement this algorithmus as well as the global error]
== Velocity-Verlet Algorithmus fuer klassische Mechanik
$
dot(arrow(t))=vec(dot(x) (t),dot(v) (t))=vec(v (t),a (x_(i) t))\
v (t_(i+1) )=x (t_(i-1) )+2v (t_i )Delta t+O (Delta t^3 )\
v (t_(i_1) )=v (t_(i-1) )+2a (x (t_i ),t_1 )Delta t+O(Delta t^3 )
$
Umschreiben der zweiten Gleichung:
Es wird von $t_(i-1) "nach" t_(i+1)$ gegangen.
$
v (t_i )=v (t_(i-1) )+a (x (t_(i_1) ), t_(i-1) )Delta t\
x (i_(i+1) )= x (t_(i-1) )+2v (t_i ) Delta t \
v (t_(i+1) )=v (t_i )+a (x (t_(i+1) ),t_(i+1))Delta t
$
Das ergibt
$
v (t_(i+2) )=v (t_(i+1) )+a (x (t_(i+1) )t_(i+1) )Delta t
$
$==>$ $v (t_(i+2) )=v (t_i )+2a (x (t_(i+1) ), t_(i+1) )Delta t$
$2 Delta t = delta t$
$
v (t+(delta t) / (alpha) )=v (t)+a (x (t),t) (delta t) / (2) \
x (t+delta t)=x (t)+v (t+(delta t) / (2))delta t\
v (t+delta t)=v (t+(delta t) / (s))+a (x (t+delta t),t+delta t)(delta t) / (2) \
$
== Forderungen an einen guten Integrator der klassischen Mechanik
- Energieerhaltung
- Zeitumkehrinvarianz
+ der Bewegungsgleichungen sind zeitumkehrbar invariant. Jeder vernuenftige Algorithmus erfuellt dies zu der Ordnung $O(delta t^2 )$\
$
vec(x_0, v_0 )=vec(x (t),v (t))->^(T (Delta t)) vec(x (t+Delta t),v (t+Delta t))-> $
+ des Algorithmus $x_0 -x_1 =0, v_0 -v_1 = 0$
- Phasenraumerhaltung symplektisch
$t_(i-1) -> t_(i+1) $
Zeitumkehr
$
arrow(x)' (t_(i+1) )=arrow(x) (t_(i+1) )\
arrow(v)' (t_(i+1) )= - arrow(v) (t_(i+1) )
$
$t_(i+1) -> t_(i+3) $
$
v' (t_(i+2))= v' (t_(i+1) )+a (x' (t_(i+1) ),t_(i+1) ) Delta t =-v (t_(i+1)) +a (x (t_(i-1) ))Delta t \
x' (t_(i+1) )= x' (t_(i+1) )+2v' (t_(i+1) )Delta t\
= x (t_(i+1) )+2 [-v (t_(i+1) )+a (x (t_(i+1) ))Delta t]Delta t \
= x (t_(i-1) )+2 Delta t [v (t_i )-v (t_(i+1) )+a (x (t_(i+1) ))Delta t]\
= x (t_(i-1) )
$
=== Takeways
- Ableitung diskretisierung
- Taylorentwicklung der Ableitung
- Mit Euler-Cauchy kann am einfachsten nach vorne integriert werden

BIN
S2/CWR/pdfs/CwrVL2.pdf Normal file
View File

Binary file not shown.

14
S2/CWR/preamble.typ Normal file
View File

@@ -0,0 +1,14 @@
#import "../../default.typ": *
#let conf(num: none, ueb: false, body) = {
// Global settings
show: default
// Set the header
[CWR \ Vorlesung #(num)]
// Make tcahe outline
outline()
// load the document
body
}

View File

@@ -1,3 +1,7 @@
// Diff template
#import "./preamble.typ": *
#show: conf.with(num: 1)
= Uebersicht = Uebersicht

View File

@@ -46,8 +46,6 @@ Wir schreiben $underline(x)$ fuer einen Vektor $x$. Ich werde einfache Symbole v
Wir definieren das *Standard-Skalarprodukt* als $angle.l dot, dot angle.r: CC^n times CC^n -> CC$. Wir definieren das *Standard-Skalarprodukt* als $angle.l dot, dot angle.r: CC^n times CC^n -> CC$.
// TODO: add angles to typstar
#lemma[ #lemma[
Cauchy-Schwarz Ungleichung Cauchy-Schwarz Ungleichung
@@ -57,7 +55,7 @@ Wir definieren das *Standard-Skalarprodukt* als $angle.l dot, dot angle.r: CC^n
] ]
#proof[ #proof[
#highlight[TODO] #highlight[TODO: Create proof for cauchy schwarz]
] ]
#lemma[ #lemma[
@@ -65,7 +63,7 @@ Wir definieren das *Standard-Skalarprodukt* als $angle.l dot, dot angle.r: CC^n
] ]
#proof[ #proof[
#highlight[TODO] #highlight[TODO: Proof, dass die euklidische Metrik eine Metrik auf R^n ist]
// Hier wird der Teil 3 ueber das Ausschreiben von abs(x+y)^2 gemacht // Hier wird der Teil 3 ueber das Ausschreiben von abs(x+y)^2 gemacht
// Dannach kann die Cauchy Schwarz ungleichung verwendet werden um eine Abschaetzung nach oben zu gewinnen // Dannach kann die Cauchy Schwarz ungleichung verwendet werden um eine Abschaetzung nach oben zu gewinnen
// Mit der binomischen // Mit der binomischen
@@ -91,7 +89,7 @@ Sei $x_k, k in NN$ eine Folge im $RR^n$
]<lem3> ]<lem3>
#proof[ #proof[
#highlight[TODO] #highlight[TODO: proof fuer das lemma, dass folgen komponentenweise konvergieren]
Idee: verwende die Ungleichung $abs(x_k-a_l) <= abs(x_k-a) <= sum_(i=0)^(n) abs(x_k-a_l )$ Idee: verwende die Ungleichung $abs(x_k-a_l) <= abs(x_k-a) <= sum_(i=0)^(n) abs(x_k-a_l )$
] ]
@@ -119,7 +117,7 @@ Sei $x_k, k in NN$ eine Folge im $RR^n$
Dann ist diese Folge beschraenkt auf $RR^n$ eine beschraenkte folge mit konvergenter Teilfolge. Dann ist diese Folge beschraenkt auf $RR^n$ eine beschraenkte folge mit konvergenter Teilfolge.
#highlight[TODO] #highlight[TODO: Finish proof of Bolzano weierstrass fuer R^n]
] ]
#theorem[ #theorem[

BIN
S2/DiffII/pdfs/DiIIVL1.pdf Normal file
View File

Binary file not shown.

14
S2/DiffII/preamble.typ Normal file
View File

@@ -0,0 +1,14 @@
#import "../../default.typ": *
#let conf(num: none, ueb: false, body) = {
// Global settings
show: default
// Set the header
[Diff II \ Vorlesung #(num)]
// Make tcahe outline
outline()
// load the document
body
}

View File

@@ -80,12 +80,13 @@ Geschicktlich fielen drei Phaenomene der Elektrodynamik auf, ohne dass Zusammenh
+ Licht + Licht
+ Elektrizitaet + Elektrizitaet
+ Magnetismus + Magnetismus
Diese wurden von verschiedenen Personen zu verschiedenen Zeiten entdeckt. Diese wurden von verschiedenen Personen zu verschiedenen Zeiten entdeckt.
- Erste Gesetzmaessigketen des Lichts (Licht nimmt immer den kuerzesten Weg): Heron v. Alexandrea (ca. 60 n.Chr.) - Erste Gesetzmaessigketen des Lichts (Licht nimmt immer den kuerzesten Weg): Heron v. Alexandrea (ca. 60 n.Chr.)
- Elektrizitaet: Thales von Milet (600 n. Chr.), geriebener Bernstein (griechisch: "electron") zieht leichte Koerper an - Elektrizitaet: Thales von Milet (600 n. Chr.), geriebener Bernstein (griechisch: "electron") zieht leichte Koerper an
- Magnetismus: Petrus Peregrinu (1269) fuehrte erste Beobachtungen zu magnetischen Feldlinien durch - Magnetismus: Petrus Peregrinu (1269) fuehrte erste Beobachtungen zu magnetischen Feldlinien durch
- Gilbert (1544-1605) erkannte wichtigen Unterschied zu $arrow(E)$ & $arrow(B)$ Feldern: Magnete rufen Drehwirkung hervor, elektrische Kraft aeussert sich als Anziehungs-Kraft - Gilbert (1544-1605) erkannte wichtigen Unterschied zu $arrow(E)$ & $arrow(B)$ Feldern: Magnete rufen Drehwirkung hervor, elektrische Kraft aeussert sich als Anziehungs-Kraft
Fuer weitere geschichtliche Entwicklung z.B. siehe Geschichte der Elektrizitaet, H. Bortias. Fuer weitere geschichtliche Entwicklung z.B. siehe Geschichte der Elektrizitaet, H. Bortias
= 1. Elektrostatik = 1. Elektrostatik
@@ -93,7 +94,8 @@ Fuer weitere geschichtliche Entwicklung z.B. siehe Geschichte der Elektrizitaet,
=== 1.1.1 Zusammenfassung historischer Beobachtungen === 1.1.1 Zusammenfassung historischer Beobachtungen
+ Es existieren zwei verschiedene Ladungen (+,-), diese koennen durch ihre kraftwirkung aufeinander und Ablenkung in elektischen Feldern unterschieden werden. + Es existieren zwei verschiedene Ladungen (+,-), diese koennen durch ihre kraftwirkung aufeinander und Ablenkung in elektischen Feldern unterschieden werden
+ Ladungen gleichen Vorzeichens stossen sich ab. Ladungen mit unterschiedlichen Vorzeichen ziehen sich an (*Unterschied* zur immer attraktiven Gravitation) + Ladungen gleichen Vorzeichens stossen sich ab. Ladungen mit unterschiedlichen Vorzeichen ziehen sich an (*Unterschied* zur immer attraktiven Gravitation)
+ Ladungen sind an Teilchen gebunden, insbesondere Elektronen ($e^(-)$) und Protonen ($p^(+)$) dessen Ladung sich nicht mit der Geschwindigkeit aendert + Ladungen sind an Teilchen gebunden, insbesondere Elektronen ($e^(-)$) und Protonen ($p^(+)$) dessen Ladung sich nicht mit der Geschwindigkeit aendert
+ Ladung der Elektronen und Protonen stellt die kleinste #underline[frei] beobachtete Ladungen dar (Ausnahmen stellen kurzlebige Teilchen dar) + Ladung der Elektronen und Protonen stellt die kleinste #underline[frei] beobachtete Ladungen dar (Ausnahmen stellen kurzlebige Teilchen dar)

98
S2/ExPhyII/VL/ExIIVL2.typ Normal file
View File

@@ -0,0 +1,98 @@
#import "../preamble.typ": *
#show: conf.with(num: 2)
= Organisatorisches
Zeiten: 0810-0953 mit 5min Pause.
=== 1.1.1 Weitere Beobachtungen (Ergaenzung zu VL1)
5. Ladungen koennen weder erzeugt noch vernichtet werden. In abgeschlossenen Systemen bleibt die Gesamtladung konstant (Ladnung lann aber in einem System getrennt werden).
+ Es gibt Stoffe in denen elektrische Ladungen frei verschiebbar sind (Leiter z.B. Metalle, Ionen (z.B. Elektrolyt, Plasma), Halbleiter) und Stoffe in denen die Ladungen fest gebunden sind (z.B. Diamant)
+ Ein Ladungstransport stellt einen elektrischen Strom dar dieser ist mit Massetransport verbunden (Ladung ist immer Materie gebunden)
Q: Werden herkoemmliche A Batterien schwerer oder leichter wenn man die Ladung veraendert?
=== 1.1.2. Bespielhafte Experimente die die o.g. Beobachtungen demonstrieren
- Reibungselektrizitaet
*Durchfuehrung*: Katzenfell wird an einem PVC-Stab gerieben, wodurch die Ladungen vom Fell auf den Stab uebergehen. Anschliessend wird die Vorhandene Spannung mit einer neutral geladenen Metallkugel verdeutlicht.
*Beobachtung*: Nach dem Reiben wird die Kugel von dem Stab angezogen.
*Erklaerung*: Durch die Influenz werden die Ladungen in der Kugel getrennt. Die negativen Ladungen sammeln sich an der Gegenueberligenden Seite, wodurch die zugewandte Seite positive geladen ist. Falls sich die Objekte beruehren kommt es zu einem Ladungsaustauch und beide sind so negativ geladen und es kommt zum Abstossen.
Die positiven Ladungen sind nach dem Reiben im Katzenfell (Ladungserhaltung).
Ladungen koennen durch Influenz getrennt werden, dann ueberfuehrt werden und schlussendlich so in verschiedene Objekte getrennt werden.
A: Graphit wird zur Monolage mit Tesafilm, wodurch dann Stroeme gemessen werden koennen.
- Influenzmaschine
Zwei gleich grosse isolierte Scheiben drehen sich gegeneinander. Durch zufaellige Influenz gekoppelt mit Ladungsabnehmern werden Spannungen von bis zu 60 kV erzeugt. Die Funkenentladung an Luft braucht eine Spannung von $3"kV"slash"mm"$
Q: Ist die Influenz in der Infzluenzmaschine zufaellig?
Q: Wie enstehen die Funken?\
A: Wenn ein Elektrisches Feld zu stark wird dann Ionisiert die Luft und es ensteht ein Plasma, welches fuer den Ladungsausgleich sorgt.
- Lichtenbergfiguren (Georg Friedrich Lichtenberg, Goettingen Dozent wegweisend fuer die moderne Physik aufgrund siners analytischen Denkens (1762 - 1798))
*Durchfuehrung*: Eine metallene Spitze wird ueber eine Plexigasscheibe gehalten die auf einer Metallplatte liegt und diese Metallplatte ist mit der Erde verbunden.
*Beobachtung*: Die positive Lichtenbergfigur erstellt sich durch Staub auf der Platte und ist durch radiale Linien vom Mittelpunkt nach Aussen gegennzeichnet. Die negative Figur ist viel zentrierter und dichter am Mittelpunkt.
PAUSE
=== 1.1.3 Coulomb'sche Gesetz
Fuer die Kraft die $q_1 $ auf Testladung $q_2 $ ausuebt wurde experimentell festgestellt
$
arrow(F)_(12) = (1) / (4 pi epsilon_0) (q_1 q_2 ) / (r^(2)_(12) ) hat(e)_(12) ,
$
wobei $epsilon_0 = 8.854 dot 10^(-12) ("As") / ("Vm")$ die Dielektrizitaetskonstante ist.
$
r_(12) = abs(arrow(r)_(2) - arrow(r)_(1) )\
hat(e)_(12) = "Einheitsvektor in Richtung"arrow(r)_(1) -> arrow(r)_(2) \
arrow(F)_(12): "Kraft von" q_1 "auf" q_2
$
$q_1 "und" q_2 $ werden mit Vorzeichen eingesetzt.
- Es gilt, dass sich gleiche Ladungen abstossen
- Actio gleich Reactio $->$ auf $q_1 $ wirkt $-arrow(F)_(12) = arrow(F)_(21) $
Messung erfolgt mit der Coulombschen Drehwaage: Messung $(1) / (r^2) $ Abhaengigkeit.
Diese Messung ist parrallel zu der Gravitationswaage bei der Gravitation
Die Messung kann auch funktionieren durch mehrere Messungen wenn die Ladungen gleich bleiben (dafuer ist eine geringe Luftfeuchtigkeit notwendig).
Fuer die Coulombkraft gilt das Superpositiionsprinzip
$
arrow(F)_(i) = sum_(j) (q_i q_j ) / (4 pi epsilon_0 ) (arrow(r)_(i) - arrow(r)_(j) ) / (abs(arrow(r)_(i) - arrow(r)_(j) ^3 ))
$
es ueberlagern sich also die Kraefte von Quellladungen auf die Testladung. \
$->$ Dieses Prinzip ist keine logische Notwendigkeit sondern ain experimenteller Befund.
= Einheiten
Hier wird das SI-System verwendet.\
Die Masseinheit der Ladung ist Coulomb $[Q] = 1 "Coulomb" = 1"C" = 1"As"$.
Anderes System: *Causs'sche cgs System*
$->$ setze $(1) / (4 pi epsilon_0 ) = 1 -> [F] = ([Q^2 ]) / ([r^2 ]) -> [Q] = 1"ESL" = ("gcm") / ("s") $
$->$ wird oft in theoretischer Physik verwendet. Elementarladung in cgs: $q_(e) = 4,803 dot 10^(10) ("cm"^(3/2) g^(1/2) ) / (s) $.
=== 1.1.4. Vergleich Coulomb mit Gravitationskraft
Coulomb: $arrow(F)_(C) = (1) / (4 pi epsilon_0 ) (q_1 q_2 ) / (r^2 ) hat(e)$
Gravitation: $arrow(F)_(G) = -G (m_1 m_2 ) / (r^2 ) hat(e)$
- beide in $(1) / (r^2 ) $ Abhaengigkeit
- Vergleiche Groessen: $(1) / (4 pi epsilon_0 ) =889 dot 10^(9) ("Nm"^2 ) / ("C"^2 ) >>> G = 6.67 dot 10^(-11) ("m"^3 ) / ("kg""s"^2 ) $
- im Mikroskopischen dominiert die Coulombkraft (z.B. haelt der Atomkern und Elektronenzonen)

BIN
S2/ExPhyII/pdfs/ExIIVL2.pdf Normal file
View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

@@ -1,4 +1,4 @@
#import "./preamble.typ": * #import "../preamble.typ": *
#show: conf.with(num: 1) #show: conf.with(num: 1)

View File

View File

@@ -1,6 +1,13 @@
#import "./preamble.typ": * = Verpasster Stoff
#show: conf.with(num: 1)
= Uebersicht Ich bin erst um 12:30 gekommen und habe deshalb viel Stoff verpasst.
= Modelle des menschlichen Gehirns
Es gibt verschiedene Ebenen auf welchen das Gehirn modelliert werden kann:
- Als Ganzes
- ... ?
- Synapsen
- Molekuele

BIN
S2/Neuro/pdfs/NeuroVL1.pdf Normal file
View File

Binary file not shown.

27
book.typ Normal file
View File

@@ -0,0 +1,27 @@
#import "@preview/shiroa:0.2.2": *
#show: book
#book-meta( // put metadata of your book like book.toml of mdbook
title: "shiroa",
description: "shiroa Documentation",
repository: "https://github.com/Myriad-Dreamin/shiroa",
authors: ("Myriad-Dreamin", "7mile"),
language: "en",
summary: [ // this field works like summary.md of mdbook
= Introduction
- #chapter("S2/ExPhyII/VL/ExIIVL1.typ", section: "1.1")[Installation]
- #chapter(none, section: "1.2.1")[Drafting chapter]
]
)

View File

@@ -4,8 +4,13 @@
#let default(body) = { #let default(body) = {
// page setup // page setup
set page(margin: 2cm, numbering: "1") //set page(margin: 2cm, numbering: "1")
set text(lang: "de", hyphenate: false) set text(lang: "de", hyphenate: false)
set align(left)
// For now no automatic numbering
// set heading(numbering: "1.1")
set par(justify: true)
// set par(justify: true) // set par(justify: true)
// equation setup // equation setup

View File

Binary file not shown.

View File

Binary file not shown.

View File

@@ -0,0 +1,281 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>shiroa</title>
<!-- Custom HTML head -->
<!-- Put your customized HTML <head> meta here. -->
<meta name="description" content="ExPhy II
Vorlesung 1
16.04.2025
Jonas Hahn
InhaltsverzeichnisOrganisatorisches .........................................................................................
1Behandelte Themen ...................................................................................
1Literatur ................................................................................................
10. Einleitung ...............................................................................................
10.1 Vektrora">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="stylesheet" href="/theme/css/variables.css">
<link rel="stylesheet" href="/theme/css/general.css">
<link rel="stylesheet" href="/theme/css/chrome.css">
<!-- Fonts -->
<link rel="stylesheet" href="/theme/FontAwesome/css/font-awesome.css">
<!-- Custom theme stylesheets -->
<style>
.typst-app { position: relative; }
</style>
<script>
/// https://segmentfault.com/a/1190000016574288
(function () {
var ie = !!(window.attachEvent && !window.opera);
var wk = /webkit\/(\d+)/i.test(navigator.userAgent) && RegExp.$1 < 525;
var fn = [];
var run = function () {
for (var i = 0; i < fn.length; i++) fn[i]();
};
var d = document;
d.ready = function (f) {
if (!ie && !wk && d.addEventListener) return d.addEventListener('DOMContentLoaded', f, false);
if (fn.push(f) > 1) return;
if (ie)
(function () {
try {
d.documentElement.doScroll('left');
run();
} catch (err) {
setTimeout(arguments.callee, 0);
}
})();
else if (wk)
var t = setInterval(function () {
if (/^(loaded|complete)$/.test(d.readyState)) clearInterval(t), run();
}, 0);
};
})();
window.captureStack = function() { }
</script>
<script id="shiroa-js" type="module" src="/internal/shiroa.js"></script>
<script>
window.typstRerender = () => { };
window.typstChangeTheme = () => { };
var typstBookJsLoaded = new Promise((resolve, reject) => {
document.getElementById('shiroa-js').addEventListener('load', resolve);
document.getElementById('shiroa-js').addEventListener('error', reject);
});
var rendererWasmModule = fetch('/internal/typst_ts_renderer_bg.wasm');
window.typstBookJsLoaded = typstBookJsLoaded;
window.typstRenderModuleReady = typstBookJsLoaded.then(() => {
var typstRenderModule = window.typstRenderModule =
window.TypstRenderModule.createTypstRenderer();
return typstRenderModule
.init({
getModule: () => rendererWasmModule,
}).then(() => typstRenderModule);
}).catch((err) => {
console.error('shiroa.js failed to load', err);
});
</script>
</head>
<body>
<div id="body-container">
<!-- Provide site root to javascript -->
<script>
var path_to_root = "/";
window.typstPathToRoot = path_to_root;
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "ayu" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
// reserved util next major release
try {
localStorage.removeItem('mdbook-theme');
localStorage.removeItem('mdbook-sidebar');
} catch (e) { }
try {
var theme = localStorage.getItem('shiroa-theme');
var sidebar = localStorage.getItem('shiroa-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('shiroa-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('shiroa-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
window.getTypstTheme = function getTypstTheme() {
var _theme;
try { _theme = localStorage.getItem('shiroa-theme'); } catch (e) { }
if (_theme === null || _theme === undefined) { _theme = default_theme; }
window.typstBookTheme = _theme;
return _theme;
}
window.isTypstLightTheme = function isLightTheme(theme) {
return theme === 'light' || theme === 'rust';
}
var theme = getTypstTheme();
// todo: consistent theme between html and typst
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script>
var html = document.querySelector('html');
var sidebar = null;
if (document.body.clientWidth >= 800) {
try { sidebar = localStorage.getItem('shiroa-sidebar'); } catch (e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded affix "><li class="part-title">Introduction</li><li><ol class="section"><li class="chapter-item expanded "><a href="/S2/ExPhyII/VL/ExIIVL1.html" class="active"><strong aria-hidden="true">1.1.</strong> Installation</a></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">1.2.1.</strong> Drafting chapter</div></li></ol></li></ol></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<!-- Track and set sidebar scroll position -->
<script>
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
sidebarScrollbox.addEventListener('click', function (e) {
if (e.target.tagName === 'A') {
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
}
}, { passive: true });
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
sessionStorage.removeItem('sidebar-scroll');
if (sidebarScrollTop) {
// preserve sidebar scroll position when navigating via links within sidebar
sidebarScrollbox.scrollTop = sidebarScrollTop;
} else {
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
var activeSection = document.querySelector('#sidebar .active');
if (activeSection) {
activeSection.scrollIntoView({ block: 'center' });
}
}
</script>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<!-- Put your customized page header here. --> <div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents"
aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme"
aria-label="Change theme" aria-haspopup="true" aria-expanded="false"
aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)"
aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S"
aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">shiroa</h1>
<div class="right-buttons">
<a href="https://github.com/Myriad-Dreamin/shiroa" title="Git repository" aria-label="Git repository">
<i id="git-repository-button" class="fa fa-github"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..."
aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function (link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<script>
let appContainer = document.currentScript && document.currentScript.parentElement;
window.typstRenderModuleReady.then((plugin) => {
window.typstBookRenderPage(plugin, "/S2/ExPhyII/VL/ExIIVL1", appContainer);
});
</script>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
</nav>
</div>
<script src="/internal/elasticlunr.min.js"></script>
<script src="/internal/mark.min.js"></script>
<script src="/internal/searcher.js"></script>
<script src="/internal/svg_utils.js"></script>
<script src="/theme/index.js"></script>
</div>
</body>
</html>

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

10
public/internal/elasticlunr.min.js vendored Normal file
View File

File diff suppressed because one or more lines are too long

7
public/internal/mark.min.js vendored Normal file
View File

File diff suppressed because one or more lines are too long

493
public/internal/searcher.js Normal file
View File

@@ -0,0 +1,493 @@
"use strict";
window.search = window.search || {};
(function search(search) {
// Search functionality
//
// You can use !hasFocus() to prevent keyhandling in your key
// event handlers while the user is typing their search.
if (!Mark || !elasticlunr) {
return;
}
//IE 11 Compatibility from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(search, pos) {
return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
};
}
var search_wrap = document.getElementById('search-wrapper'),
searchbar = document.getElementById('searchbar'),
searchbar_outer = document.getElementById('searchbar-outer'),
searchresults = document.getElementById('searchresults'),
searchresults_outer = document.getElementById('searchresults-outer'),
searchresults_header = document.getElementById('searchresults-header'),
searchicon = document.getElementById('search-toggle'),
content = document.getElementById('content'),
searchindex = null,
doc_urls = [],
results_options = {
teaser_word_count: 30,
limit_results: 30,
},
search_options = {
bool: "AND",
expand: true,
fields: {
title: {boost: 1},
body: {boost: 1},
breadcrumbs: {boost: 0}
}
},
mark_exclude = [],
marker = new Mark(content),
current_searchterm = "",
URL_SEARCH_PARAM = 'search',
URL_MARK_PARAM = 'highlight',
teaser_count = 0,
SEARCH_HOTKEY_KEYCODE = 83,
ESCAPE_KEYCODE = 27,
DOWN_KEYCODE = 40,
UP_KEYCODE = 38,
SELECT_KEYCODE = 13;
function hasFocus() {
return searchbar === document.activeElement;
}
function removeChildren(elem) {
while (elem.firstChild) {
elem.removeChild(elem.firstChild);
}
}
// Helper to parse a url into its building blocks.
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
host: a.hostname,
port: a.port,
params: (function(){
var ret = {};
var seg = a.search.replace(/^\?/,'').split('&');
var len = seg.length, i = 0, s;
for (;i<len;i++) {
if (!seg[i]) { continue; }
s = seg[i].split('=');
ret[s[0]] = s[1];
}
return ret;
})(),
file: (a.pathname.match(/\/([^/?#]+)$/i) || [,''])[1],
hash: a.hash.replace('#',''),
path: a.pathname.replace(/^([^/])/,'/$1')
};
}
// Helper to recreate a url string from its building blocks.
function renderURL(urlobject) {
var url = urlobject.protocol + "://" + urlobject.host;
if (urlobject.port != "") {
url += ":" + urlobject.port;
}
url += urlobject.path;
var joiner = "?";
for(var prop in urlobject.params) {
if(urlobject.params.hasOwnProperty(prop)) {
url += joiner + prop + "=" + urlobject.params[prop];
joiner = "&";
}
}
if (urlobject.hash != "") {
url += "#" + urlobject.hash;
}
return url;
}
// Helper to escape html special chars for displaying the teasers
var escapeHTML = (function() {
var MAP = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&#34;',
"'": '&#39;'
};
var repl = function(c) { return MAP[c]; };
return function(s) {
return s.replace(/[&<>'"]/g, repl);
};
})();
function formatSearchMetric(count, searchterm) {
if (count == 1) {
return count + " search result for '" + searchterm + "':";
} else if (count == 0) {
return "No search results for '" + searchterm + "'.";
} else {
return count + " search results for '" + searchterm + "':";
}
}
function formatSearchResult(result, searchterms) {
var teaser = makeTeaser(escapeHTML(result.doc.body), searchterms);
teaser_count++;
// The ?URL_MARK_PARAM= parameter belongs inbetween the page and the #heading-anchor
var url = doc_urls[result.ref].split("#");
if (url.length == 1) { // no anchor found
url.push("");
}
// encodeURIComponent escapes all chars that could allow an XSS except
// for '. Due to that we also manually replace ' with its url-encoded
// representation (%27).
var searchterms = encodeURIComponent(searchterms.join(" ")).replace(/\'/g, "%27");
// todo: shiroa doesn't have highlight feature.
// path_to_root + url[0] + '?' + URL_MARK_PARAM + '=' + searchterms + '#' + url[1]
var goalUrl = url[0];
if (goalUrl.startsWith('/')) {
goalUrl = goalUrl.substring(1);
}
// + '?' + URL_MARK_PARAM + '=' + searchterms + '#' + url[1]
return '<a href="' + path_to_root + goalUrl
+ '" aria-details="teaser_' + teaser_count + '">' + result.doc.breadcrumbs + '</a>'
+ '<span class="teaser" id="teaser_' + teaser_count + '" aria-label="Search Result Teaser">'
+ teaser + '</span>';
}
function makeTeaser(body, searchterms) {
// The strategy is as follows:
// First, assign a value to each word in the document:
// Words that correspond to search terms (stemmer aware): 40
// Normal words: 2
// First word in a sentence: 8
// Then use a sliding window with a constant number of words and count the
// sum of the values of the words within the window. Then use the window that got the
// maximum sum. If there are multiple maximas, then get the last one.
// Enclose the terms in <em>.
var stemmed_searchterms = searchterms.map(function(w) {
return elasticlunr.stemmer(w.toLowerCase());
});
var searchterm_weight = 40;
var weighted = []; // contains elements of ["word", weight, index_in_document]
// split in sentences, then words
var sentences = body.toLowerCase().split('. ');
var index = 0;
var value = 0;
var searchterm_found = false;
for (var sentenceindex in sentences) {
var words = sentences[sentenceindex].split(' ');
value = 8;
for (var wordindex in words) {
var word = words[wordindex];
if (word.length > 0) {
for (var searchtermindex in stemmed_searchterms) {
if (elasticlunr.stemmer(word).startsWith(stemmed_searchterms[searchtermindex])) {
value = searchterm_weight;
searchterm_found = true;
}
};
weighted.push([word, value, index]);
value = 2;
}
index += word.length;
index += 1; // ' ' or '.' if last word in sentence
};
index += 1; // because we split at a two-char boundary '. '
};
if (weighted.length == 0) {
return body;
}
var window_weight = [];
var window_size = Math.min(weighted.length, results_options.teaser_word_count);
var cur_sum = 0;
for (var wordindex = 0; wordindex < window_size; wordindex++) {
cur_sum += weighted[wordindex][1];
};
window_weight.push(cur_sum);
for (var wordindex = 0; wordindex < weighted.length - window_size; wordindex++) {
cur_sum -= weighted[wordindex][1];
cur_sum += weighted[wordindex + window_size][1];
window_weight.push(cur_sum);
};
if (searchterm_found) {
var max_sum = 0;
var max_sum_window_index = 0;
// backwards
for (var i = window_weight.length - 1; i >= 0; i--) {
if (window_weight[i] > max_sum) {
max_sum = window_weight[i];
max_sum_window_index = i;
}
};
} else {
max_sum_window_index = 0;
}
// add <em/> around searchterms
var teaser_split = [];
var index = weighted[max_sum_window_index][2];
for (var i = max_sum_window_index; i < max_sum_window_index+window_size; i++) {
var word = weighted[i];
if (index < word[2]) {
// missing text from index to start of `word`
teaser_split.push(body.substring(index, word[2]));
index = word[2];
}
if (word[1] == searchterm_weight) {
teaser_split.push("<em>")
}
index = word[2] + word[0].length;
teaser_split.push(body.substring(word[2], index));
if (word[1] == searchterm_weight) {
teaser_split.push("</em>")
}
};
return teaser_split.join('');
}
function init(config) {
results_options = config.results_options;
search_options = config.search_options;
searchbar_outer = config.searchbar_outer;
doc_urls = config.doc_urls;
searchindex = elasticlunr.Index.load(config.index);
// Set up events
searchicon.addEventListener('click', function(e) { searchIconClickHandler(); }, false);
searchbar.addEventListener('keyup', function(e) { searchbarKeyUpHandler(); }, false);
document.addEventListener('keydown', function(e) { globalKeyHandler(e); }, false);
// If the user uses the browser buttons, do the same as if a reload happened
window.onpopstate = function(e) { doSearchOrMarkFromUrl(); };
// Suppress "submit" events so the page doesn't reload when the user presses Enter
document.addEventListener('submit', function(e) { e.preventDefault(); }, false);
// If reloaded, do the search or mark again, depending on the current url parameters
doSearchOrMarkFromUrl();
}
function unfocusSearchbar() {
// hacky, but just focusing a div only works once
var tmp = document.createElement('input');
tmp.setAttribute('style', 'position: absolute; opacity: 0;');
searchicon.appendChild(tmp);
tmp.focus();
tmp.remove();
}
// On reload or browser history backwards/forwards events, parse the url and do search or mark
function doSearchOrMarkFromUrl() {
// Check current URL for search request
var url = parseURL(window.location.href);
if (url.params.hasOwnProperty(URL_SEARCH_PARAM)
&& url.params[URL_SEARCH_PARAM] != "") {
showSearch(true);
searchbar.value = decodeURIComponent(
(url.params[URL_SEARCH_PARAM]+'').replace(/\+/g, '%20'));
searchbarKeyUpHandler(); // -> doSearch()
} else {
showSearch(false);
}
if (url.params.hasOwnProperty(URL_MARK_PARAM)) {
var words = decodeURIComponent(url.params[URL_MARK_PARAM]).split(' ');
marker.mark(words, {
exclude: mark_exclude
});
var markers = document.querySelectorAll("mark");
function hide() {
for (var i = 0; i < markers.length; i++) {
markers[i].classList.add("fade-out");
window.setTimeout(function(e) { marker.unmark(); }, 300);
}
}
for (var i = 0; i < markers.length; i++) {
markers[i].addEventListener('click', hide);
}
}
}
// Eventhandler for keyevents on `document`
function globalKeyHandler(e) {
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || e.target.type === 'textarea' || e.target.type === 'text') { return; }
if (e.keyCode === ESCAPE_KEYCODE) {
e.preventDefault();
searchbar.classList.remove("active");
setSearchUrlParameters("",
(searchbar.value.trim() !== "") ? "push" : "replace");
if (hasFocus()) {
unfocusSearchbar();
}
showSearch(false);
marker.unmark();
} else if (!hasFocus() && e.keyCode === SEARCH_HOTKEY_KEYCODE) {
e.preventDefault();
showSearch(true);
window.scrollTo(0, 0);
searchbar.select();
} else if (hasFocus() && e.keyCode === DOWN_KEYCODE) {
e.preventDefault();
unfocusSearchbar();
searchresults.firstElementChild.classList.add("focus");
} else if (!hasFocus() && (e.keyCode === DOWN_KEYCODE
|| e.keyCode === UP_KEYCODE
|| e.keyCode === SELECT_KEYCODE)) {
// not `:focus` because browser does annoying scrolling
var focused = searchresults.querySelector("li.focus");
if (!focused) return;
e.preventDefault();
if (e.keyCode === DOWN_KEYCODE) {
var next = focused.nextElementSibling;
if (next) {
focused.classList.remove("focus");
next.classList.add("focus");
}
} else if (e.keyCode === UP_KEYCODE) {
focused.classList.remove("focus");
var prev = focused.previousElementSibling;
if (prev) {
prev.classList.add("focus");
} else {
searchbar.select();
}
} else { // SELECT_KEYCODE
window.location.assign(focused.querySelector('a'));
}
}
}
function showSearch(yes) {
if (yes) {
search_wrap.classList.remove('hidden');
searchicon.setAttribute('aria-expanded', 'true');
} else {
search_wrap.classList.add('hidden');
searchicon.setAttribute('aria-expanded', 'false');
var results = searchresults.children;
for (var i = 0; i < results.length; i++) {
results[i].classList.remove("focus");
}
}
}
function showResults(yes) {
if (yes) {
searchresults_outer.classList.remove('hidden');
} else {
searchresults_outer.classList.add('hidden');
}
}
// Eventhandler for search icon
function searchIconClickHandler() {
if (search_wrap.classList.contains('hidden')) {
showSearch(true);
window.scrollTo(0, 0);
searchbar.select();
} else {
showSearch(false);
}
}
// Eventhandler for keyevents while the searchbar is focused
function searchbarKeyUpHandler() {
var searchterm = searchbar.value.trim();
if (searchterm != "") {
searchbar.classList.add("active");
doSearch(searchterm);
} else {
searchbar.classList.remove("active");
showResults(false);
removeChildren(searchresults);
}
setSearchUrlParameters(searchterm, "push_if_new_search_else_replace");
// Remove marks
marker.unmark();
}
// Update current url with ?URL_SEARCH_PARAM= parameter, remove ?URL_MARK_PARAM and #heading-anchor .
// `action` can be one of "push", "replace", "push_if_new_search_else_replace"
// and replaces or pushes a new browser history item.
// "push_if_new_search_else_replace" pushes if there is no `?URL_SEARCH_PARAM=abc` yet.
function setSearchUrlParameters(searchterm, action) {
var url = parseURL(window.location.href);
var first_search = ! url.params.hasOwnProperty(URL_SEARCH_PARAM);
if (searchterm != "" || action == "push_if_new_search_else_replace") {
url.params[URL_SEARCH_PARAM] = searchterm;
delete url.params[URL_MARK_PARAM];
url.hash = "";
} else {
delete url.params[URL_MARK_PARAM];
delete url.params[URL_SEARCH_PARAM];
}
// A new search will also add a new history item, so the user can go back
// to the page prior to searching. A updated search term will only replace
// the url.
if (action == "push" || (action == "push_if_new_search_else_replace" && first_search) ) {
history.pushState({}, document.title, renderURL(url));
} else if (action == "replace" || (action == "push_if_new_search_else_replace" && !first_search) ) {
history.replaceState({}, document.title, renderURL(url));
}
}
function doSearch(searchterm) {
// Don't search the same twice
if (current_searchterm == searchterm) { return; }
else { current_searchterm = searchterm; }
if (searchindex == null) { return; }
// Do the actual search
var results = searchindex.search(searchterm, search_options);
var resultcount = Math.min(results.length, results_options.limit_results);
// Display search metrics
searchresults_header.innerText = formatSearchMetric(resultcount, searchterm);
// Clear and insert results
var searchterms = searchterm.split(' ');
removeChildren(searchresults);
for(var i = 0; i < resultcount ; i++){
var resultElem = document.createElement('li');
resultElem.innerHTML = formatSearchResult(results[i], searchterms);
searchresults.appendChild(resultElem);
}
// Display results
showResults(true);
}
fetch(path_to_root + 'searchindex.json')
.then(response => response.json())
.then(json => init(json))
.catch(error => { // Try to load searchindex.js if fetch failed
var script = document.createElement('script');
script.src = path_to_root + 'searchindex.js';
script.onload = () => init(window.search);
document.head.appendChild(script);
});
// Exported functions
search.hasFocus = hasFocus;
})(window.search);

4482
public/internal/shiroa.js Normal file
View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because one or more lines are too long

View File

Binary file not shown.

1
public/searchindex.js Normal file
View File

File diff suppressed because one or more lines are too long

1
public/searchindex.json Normal file
View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because it is too large Load Diff

View File

Binary file not shown.

View File

Binary file not shown.

View File

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 434 KiB

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

567
public/theme/css/chrome.css Normal file
View File

@@ -0,0 +1,567 @@
/* CSS for UI elements (a.k.a. chrome) */
@import 'variables.css';
html {
scrollbar-color: var(--scrollbar) var(--bg);
scrollbar-width: 25px;
}
#searchresults a,
.content a:link,
a:visited,
a > .hljs {
color: var(--links);
}
/*
body-container is necessary because mobile browsers don't seem to like
overflow-x on the body tag when there is a <meta name="viewport"> tag.
*/
#body-container {
/*
This is used when the sidebar pushes the body content off the side of
the screen on small screens. Without it, dragging on mobile Safari
will want to reposition the viewport in a weird way.
*/
overflow-x: clip;
}
/* Menu Bar */
#menu-bar,
#menu-bar-hover-placeholder {
z-index: 101;
margin: auto calc(0px - var(--page-padding));
}
#menu-bar {
position: relative;
display: flex;
flex-wrap: wrap;
background-color: var(--bg);
border-bottom-color: var(--bg);
border-bottom-width: 1px;
border-bottom-style: solid;
}
#menu-bar.sticky,
.js #menu-bar-hover-placeholder:hover + #menu-bar,
.js #menu-bar:hover,
.js.sidebar-visible #menu-bar {
position: -webkit-sticky;
position: sticky;
top: 0 !important;
}
#menu-bar-hover-placeholder {
position: sticky;
position: -webkit-sticky;
top: 0;
height: var(--menu-bar-height);
}
#menu-bar.bordered {
border-bottom-color: var(--table-border-color);
}
#menu-bar i,
#menu-bar .icon-button {
position: relative;
padding: 0 8px;
z-index: 10;
line-height: var(--menu-bar-height);
cursor: pointer;
transition: color 0.5s;
}
@media only screen and (max-width: 420px) {
#menu-bar i,
#menu-bar .icon-button {
padding: 0 5px;
}
}
.icon-button {
border: none;
background: none;
padding: 0;
color: inherit;
}
.icon-button i {
margin: 0;
}
.right-buttons {
margin: 0 15px;
}
.right-buttons a {
text-decoration: none;
}
.left-buttons {
display: flex;
margin: 0 5px;
}
.no-js .left-buttons {
display: none;
}
.menu-title {
display: inline-block;
font-weight: 200;
font-size: 2.4rem;
line-height: var(--menu-bar-height);
text-align: center;
margin: 0;
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.js .menu-title {
cursor: pointer;
}
.menu-bar,
.menu-bar:visited,
.nav-chapters,
.nav-chapters:visited,
.mobile-nav-chapters,
.mobile-nav-chapters:visited,
.menu-bar .icon-button,
.menu-bar a i {
color: var(--icons);
}
.menu-bar i:hover,
.menu-bar .icon-button:hover,
.nav-chapters:hover,
.mobile-nav-chapters i:hover {
color: var(--icons-hover);
}
/* Nav Icons */
.nav-chapters {
font-size: 2.5em;
text-align: center;
text-decoration: none;
position: fixed;
top: 0;
bottom: 0;
margin: 0;
max-width: 150px;
min-width: 90px;
display: flex;
justify-content: center;
align-content: center;
flex-direction: column;
transition: color 0.5s, background-color 0.5s;
}
.nav-chapters:hover {
text-decoration: none;
background-color: var(--theme-hover);
transition: background-color 0.15s, color 0.15s;
}
.nav-wrapper {
margin-top: 50px;
display: none;
}
.mobile-nav-chapters {
font-size: 2.5em;
text-align: center;
text-decoration: none;
width: 90px;
border-radius: 5px;
background-color: var(--sidebar-bg);
}
.previous {
float: left;
}
.next {
float: right;
right: var(--page-padding);
}
@media only screen and (max-width: 1080px) {
.nav-wide-wrapper {
display: none;
}
.nav-wrapper {
display: block;
}
}
@media only screen and (max-width: 1380px) {
.sidebar-visible .nav-wide-wrapper {
display: none;
}
.sidebar-visible .nav-wrapper {
display: block;
}
}
/* Inline code */
:not(pre) > .hljs {
display: inline;
padding: 0.1em 0.3em;
border-radius: 3px;
}
:not(pre):not(a) > .hljs {
color: var(--inline-code-color);
overflow-x: initial;
}
a:hover > .hljs {
text-decoration: underline;
}
pre {
position: relative;
}
pre > .buttons {
position: absolute;
z-index: 100;
right: 0px;
top: 2px;
margin: 0px;
padding: 2px 0px;
color: var(--sidebar-fg);
cursor: pointer;
visibility: hidden;
opacity: 0;
transition: visibility 0.1s linear, opacity 0.1s linear;
}
pre:hover > .buttons {
visibility: visible;
opacity: 1;
}
pre > .buttons :hover {
color: var(--sidebar-active);
border-color: var(--icons-hover);
background-color: var(--theme-hover);
}
pre > .buttons i {
margin-left: 8px;
}
pre > .buttons button {
cursor: inherit;
margin: 0px 5px;
padding: 3px 5px;
font-size: 14px;
border-style: solid;
border-width: 1px;
border-radius: 4px;
border-color: var(--icons);
background-color: var(--theme-popup-bg);
transition: 100ms;
transition-property: color, border-color, background-color;
color: var(--icons);
}
@media (pointer: coarse) {
pre > .buttons button {
/* On mobile, make it easier to tap buttons. */
padding: 0.3rem 1rem;
}
}
pre > code {
padding: 1rem;
}
/* FIXME: ACE editors overlap their buttons because ACE does absolute
positioning within the code block which breaks padding. The only solution I
can think of is to move the padding to the outer pre tag (or insert a div
wrapper), but that would require fixing a whole bunch of CSS rules.
*/
.hljs.ace_editor {
padding: 0rem 0rem;
}
pre > .result {
margin-top: 10px;
}
/* Search */
#searchresults a {
text-decoration: none;
}
mark {
border-radius: 2px;
padding: 0 3px 1px 3px;
margin: 0 -3px -1px -3px;
background-color: var(--search-mark-bg);
transition: background-color 300ms linear;
cursor: pointer;
}
mark.fade-out {
background-color: rgba(0, 0, 0, 0) !important;
cursor: auto;
}
.searchbar-outer {
margin-left: auto;
margin-right: auto;
max-width: var(--content-max-width);
}
#searchbar {
width: 100%;
margin: 5px auto 0px auto;
padding: 10px 16px;
transition: box-shadow 300ms ease-in-out;
border: 1px solid var(--searchbar-border-color);
border-radius: 3px;
background-color: var(--searchbar-bg);
color: var(--searchbar-fg);
}
#searchbar:focus,
#searchbar.active {
box-shadow: 0 0 3px var(--searchbar-shadow-color);
}
.searchresults-header {
font-weight: bold;
font-size: 1em;
padding: 18px 0 0 5px;
color: var(--searchresults-header-fg);
}
.searchresults-outer {
margin-left: auto;
margin-right: auto;
max-width: var(--content-max-width);
border-bottom: 1px dashed var(--searchresults-border-color);
}
ul#searchresults {
list-style: none;
padding-left: 20px;
}
ul#searchresults li {
margin: 10px 0px;
padding: 2px;
border-radius: 2px;
}
ul#searchresults li.focus {
background-color: var(--searchresults-li-bg);
}
ul#searchresults span.teaser {
display: block;
clear: both;
margin: 5px 0 0 20px;
font-size: 0.8em;
}
ul#searchresults span.teaser em {
font-weight: bold;
font-style: normal;
}
/* Sidebar */
.sidebar {
position: fixed;
left: 0;
top: 0;
bottom: 0;
width: var(--sidebar-width);
font-size: 0.875em;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
overscroll-behavior-y: contain;
background-color: var(--sidebar-bg);
color: var(--sidebar-fg);
}
.sidebar-resizing {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.js:not(.sidebar-resizing) .sidebar {
transition: transform 0.3s; /* Animation: slide away */
}
.sidebar code {
line-height: 2em;
}
.sidebar .sidebar-scrollbox {
overflow-y: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 10px 10px;
}
.sidebar .sidebar-resize-handle {
position: absolute;
cursor: col-resize;
width: 0;
right: 0;
top: 0;
bottom: 0;
}
.js .sidebar .sidebar-resize-handle {
cursor: col-resize;
width: 5px;
}
.sidebar-hidden .sidebar {
transform: translateX(calc(0px - var(--sidebar-width)));
}
.sidebar::-webkit-scrollbar {
background: var(--sidebar-bg);
width: 25px;
}
.sidebar::-webkit-scrollbar-thumb {
background: var(--scrollbar);
width: 25px;
}
.sidebar-visible .page-wrapper {
transform: translateX(var(--sidebar-width));
}
.page-wrapper {
min-height: 110vh;
}
@media only screen and (min-width: 620px) {
.sidebar-visible .page-wrapper {
transform: none;
margin-left: var(--sidebar-width);
}
}
.chapter {
list-style: none outside none;
padding-left: 0;
line-height: 2.2em;
}
.chapter ol {
width: 100%;
}
.chapter li {
display: flex;
color: var(--sidebar-non-existant);
}
.chapter li a {
display: block;
padding: 0;
text-decoration: none;
color: var(--sidebar-fg);
}
.chapter li a:hover {
color: var(--sidebar-active);
}
.chapter li a.active {
color: var(--sidebar-active);
}
.chapter li > a.toggle {
cursor: pointer;
display: block;
margin-left: auto;
padding: 0 10px;
user-select: none;
opacity: 0.68;
}
.chapter li > a.toggle div {
transition: transform 0.5s;
}
/* collapse the section */
.chapter li:not(.expanded) + li > ol {
display: none;
}
.chapter li.chapter-item {
line-height: 1.5em;
margin-top: 0.6em;
}
.chapter li.expanded > a.toggle div {
transform: rotate(90deg);
}
.spacer {
width: 100%;
height: 3px;
margin: 5px 0px;
}
.chapter .spacer {
background-color: var(--sidebar-spacer);
}
@media (-moz-touch-enabled: 1), (pointer: coarse) {
.chapter li a {
padding: 5px 0;
}
.spacer {
margin: 10px 0;
}
}
.section {
list-style: none outside none;
padding-left: 20px;
line-height: 1.9em;
}
/* Theme Menu Popup */
.theme-popup {
position: absolute;
left: 10px;
top: var(--menu-bar-height);
z-index: 1000;
border-radius: 4px;
font-size: 0.7em;
color: var(--fg);
background: var(--theme-popup-bg);
border: 1px solid var(--theme-popup-border);
margin: 0;
padding: 0;
list-style: none;
display: none;
/* Don't let the children's background extend past the rounded corners. */
overflow: hidden;
}
.theme-popup .default {
color: var(--icons);
}
.theme-popup .theme {
width: 100%;
border: 0;
margin: 0;
padding: 2px 20px;
line-height: 25px;
white-space: nowrap;
text-align: left;
cursor: pointer;
color: inherit;
background: inherit;
font-size: inherit;
}
.theme-popup .theme:hover {
background-color: var(--theme-hover);
}
.theme-selected::before {
display: inline-block;
content: '✓';
margin-left: -14px;
width: 14px;
}

View File

@@ -0,0 +1,395 @@
/* Base styles and content styles */
@import 'variables.css';
:root {
/* Browser default font-size is 16px, this way 1 rem = 10px */
font-size: 62.5%;
color-scheme: var(--color-scheme);
}
html {
font-family: 'Open Sans', sans-serif;
color: var(--fg);
background-color: var(--bg);
text-size-adjust: none;
-webkit-text-size-adjust: none;
}
body {
margin: 0;
font-size: 1.6rem;
overflow-x: auto;
}
code {
font-family: var(--mono-font) !important;
font-size: var(--code-font-size);
}
/* make long words/inline code not x overflow */
main {
overflow-wrap: break-word;
}
/* make wide tables scroll if they overflow */
.table-wrapper {
overflow-x: auto;
}
/* Don't change font size in headers. */
h1 code,
h2 code,
h3 code,
h4 code,
h5 code,
h6 code {
font-size: unset;
}
.left {
float: left;
}
.right {
float: right;
}
.boring {
opacity: 0.6;
}
.hide-boring .boring {
display: none;
}
.hidden {
display: none !important;
}
h2,
h3 {
margin-top: 2.5em;
}
h4,
h5 {
margin-top: 2em;
}
.header + .header h3,
.header + .header h4,
.header + .header h5 {
margin-top: 1em;
}
h1:target::before,
h2:target::before,
h3:target::before,
h4:target::before,
h5:target::before,
h6:target::before {
display: inline-block;
content: '»';
margin-left: -30px;
width: 30px;
}
/* This is broken on Safari as of version 14, but is fixed
in Safari Technology Preview 117 which I think will be Safari 14.2.
https://bugs.webkit.org/show_bug.cgi?id=218076
*/
:target {
scroll-margin-top: calc(var(--menu-bar-height) + 0.5em);
}
.page {
outline: 0;
padding: 0 var(--page-padding);
margin-top: calc(
0px - var(--menu-bar-height)
); /* Compensate for the #menu-bar-hover-placeholder */
}
.page-wrapper {
box-sizing: border-box;
}
.js:not(.sidebar-resizing) .page-wrapper {
transition:
margin-left 0.3s ease,
transform 0.3s ease; /* Animation: slide away */
}
.content {
overflow-y: auto;
padding: 0 5px 50px 5px;
}
.content main {
margin-left: auto;
margin-right: auto;
max-width: var(--content-max-width);
}
.content p {
line-height: 1.45em;
}
.content ol {
line-height: 1.45em;
}
.content ul {
line-height: 1.45em;
}
.content a {
text-decoration: none;
}
.content a:hover {
text-decoration: underline;
}
.content img,
.content video {
max-width: 100%;
}
.content .header:link,
.content .header:visited {
color: var(--fg);
}
.content .header:link,
.content .header:visited:hover {
text-decoration: none;
}
table {
margin: 0 auto;
border-collapse: collapse;
}
table td {
padding: 3px 20px;
border: 1px var(--table-border-color) solid;
}
table thead {
background: var(--table-header-bg);
}
table thead td {
font-weight: 700;
border: none;
}
table thead th {
padding: 3px 20px;
}
table thead tr {
border: 1px var(--table-header-bg) solid;
}
/* Alternate background colors for rows */
table tbody tr:nth-child(2n) {
background: var(--table-alternate-bg);
}
blockquote {
margin: 20px 0;
padding: 0 20px;
color: var(--fg);
background-color: var(--quote-bg);
border-top: 0.1em solid var(--quote-border);
border-bottom: 0.1em solid var(--quote-border);
}
kbd {
background-color: var(--table-border-color);
border-radius: 4px;
border: solid 1px var(--theme-popup-border);
box-shadow: inset 0 -1px 0 var(--theme-hover);
display: inline-block;
font-size: var(--code-font-size);
font-family: var(--mono-font);
line-height: 10px;
padding: 4px 5px;
vertical-align: middle;
}
:not(.footnote-definition) + .footnote-definition,
.footnote-definition + :not(.footnote-definition) {
margin-top: 2em;
}
.footnote-definition {
font-size: 0.9em;
margin: 0.5em 0;
}
.footnote-definition p {
display: inline;
}
.tooltiptext {
position: absolute;
visibility: hidden;
color: #fff;
background-color: #333;
transform: translateX(-50%); /* Center by moving tooltip 50% of its width left */
left: -8px; /* Half of the width of the icon */
top: -35px;
font-size: 0.8em;
text-align: center;
border-radius: 6px;
padding: 5px 8px;
margin: 5px;
z-index: 1000;
}
.tooltipped .tooltiptext {
visibility: visible;
}
.chapter li.part-title {
color: var(--sidebar-fg);
margin: 5px 0px;
font-weight: bold;
}
.result-no-output {
font-style: italic;
}
.typst-dom-page {
width: var(--data-page-width, 100%);
height: var(--data-page-height);
--data-text-width: 1px;
--data-text-height: 1px;
margin: auto;
}
.typst-back-canvas {
position: absolute;
z-index: -1;
width: var(--data-page-width, 100%);
height: var(--data-page-height);
pointer-events: none;
}
.typst-svg-page {
position: absolute;
z-index: 0;
width: var(--data-page-width, 100%);
height: var(--data-page-height);
}
.typst-html-semantics {
position: absolute;
z-index: 2;
width: var(--data-page-width, 100%);
height: var(--data-page-height);
color: transparent;
font-family: monospace;
white-space: pre;
}
.typst-html-semantics span {
color: transparent;
font-family: monospace;
transform-origin: left top;
position: absolute;
display: inline-block;
left: 0;
top: 0;
}
.typst-content-hint {
position: absolute;
display: inline-block;
width: 1px;
height: 1px;
overflow: hidden;
}
.typst-html-semantics a {
position: absolute;
display: inline-block;
}
/* set transparent itself */
.typst-content-group {
pointer-events: visible;
}
.typst-html-semantics span::-moz-selection {
color: transparent;
background: #7db9dea0;
}
.typst-html-semantics span::selection {
color: transparent;
background: #7db9dea0;
}
.typst-html-semantics *::-moz-selection {
color: transparent;
background: transparent;
}
.typst-html-semantics *::selection {
color: transparent;
background: transparent;
}
.typst-content-fallback {
color: transparent;
background: transparent;
}
.pseudo-link,
.typst-text {
pointer-events: none;
}
.typst-svg-page {
fill: none;
}
.outline_glyph path,
path.outline_glyph {
fill: var(--glyph_fill);
stroke: var(--glyph_stroke);
}
.outline_glyph path,
path.outline_glyph {
transition: 0.2s fill stroke;
}
.hover .typst-text {
--glyph_fill: #66bab7;
--glyph_stroke: #66bab7;
}
.typst-jump-ripple,
.typst-debug-react-ripple {
width: 0;
height: 0;
background-color: transparent;
position: absolute;
border-radius: 50%;
}
.typst-jump-ripple {
border: 1px solid #66bab7;
}
.typst-debug-react-ripple {
border: 1px solid #cb1b45;
}
@keyframes typst-jump-ripple-effect {
to {
width: 10vw;
height: 10vw;
opacity: 0.01;
margin: -5vw;
}
}
@keyframes typst-debug-react-ripple-effect {
to {
width: 3vw;
height: 3vw;
opacity: 0.01;
margin: -1.5vw;
}
}
.focus .typst-text {
--glyph_fill: var(--sidebar-active);
}
a.focus {
/* todo: remove !important */
color: var(--sidebar-active) !important;
}
.focus .typst-text, a.focus {
transition: 0.1s;
transition-property: fill, stroke, color;
}

View File

@@ -0,0 +1,46 @@
#sidebar,
#menu-bar,
.nav-chapters,
.mobile-nav-chapters {
display: none;
}
#page-wrapper.page-wrapper {
transform: none;
margin-left: 0px;
overflow-y: initial;
}
#content {
max-width: none;
margin: 0;
padding: 0;
}
.page {
overflow-y: initial;
}
pre > .buttons {
z-index: 2;
}
a, a:visited, a:active, a:hover {
color: #4183c4;
text-decoration: none;
}
h1, h2, h3, h4, h5, h6 {
page-break-inside: avoid;
page-break-after: avoid;
}
pre, code {
page-break-inside: avoid;
white-space: pre-wrap;
}
.fa {
display: none !important;
}

View File

@@ -0,0 +1,265 @@
/* Globals */
:root {
--sidebar-width: min(300px, max(23.6vw, 200px));
--page-padding: 15px;
--content-max-width: 750px;
--menu-bar-height: 50px;
--mono-font: 'Source Code Pro', Consolas, 'Ubuntu Mono', Menlo, 'DejaVu Sans Mono', monospace,
monospace;
--code-font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */
}
/* Themes */
.ayu {
--bg: hsl(210, 25%, 8%);
--fg: #c5c5c5;
--sidebar-bg: #14191f;
--sidebar-fg: #c8c9db;
--sidebar-non-existant: #5c6773;
--sidebar-active: #ffb454;
--sidebar-spacer: #2d334f;
--scrollbar: var(--sidebar-fg);
--icons: #737480;
--icons-hover: #b7b9cc;
--links: #0096cf;
--inline-code-color: #ffb454;
--theme-popup-bg: #14191f;
--theme-popup-border: #5c6773;
--theme-hover: #191f26;
--quote-bg: hsl(226, 15%, 17%);
--quote-border: hsl(226, 15%, 22%);
--table-border-color: hsl(210, 25%, 13%);
--table-header-bg: hsl(210, 25%, 28%);
--table-alternate-bg: hsl(210, 25%, 11%);
--searchbar-border-color: #848484;
--searchbar-bg: #424242;
--searchbar-fg: #fff;
--searchbar-shadow-color: #d4c89f;
--searchresults-header-fg: #666;
--searchresults-border-color: #888;
--searchresults-li-bg: #252932;
--search-mark-bg: #e3b171;
--color-scheme: dark;
}
.coal {
--bg: hsl(200, 7%, 8%);
--fg: #98a3ad;
--sidebar-bg: #292c2f;
--sidebar-fg: #a1adb8;
--sidebar-non-existant: #505254;
--sidebar-active: #3473ad;
--sidebar-spacer: #393939;
--scrollbar: var(--sidebar-fg);
--icons: #43484d;
--icons-hover: #b3c0cc;
--links: #2b79a2;
--inline-code-color: #c5c8c6;
--theme-popup-bg: #141617;
--theme-popup-border: #43484d;
--theme-hover: #1f2124;
--quote-bg: hsl(234, 21%, 18%);
--quote-border: hsl(234, 21%, 23%);
--table-border-color: hsl(200, 7%, 13%);
--table-header-bg: hsl(200, 7%, 28%);
--table-alternate-bg: hsl(200, 7%, 11%);
--searchbar-border-color: #aaa;
--searchbar-bg: #b7b7b7;
--searchbar-fg: #000;
--searchbar-shadow-color: #aaa;
--searchresults-header-fg: #666;
--searchresults-border-color: #98a3ad;
--searchresults-li-bg: #2b2b2f;
--search-mark-bg: #355c7d;
--color-scheme: dark;
}
.light {
--bg: hsl(0, 0%, 100%);
--fg: hsl(0, 0%, 0%);
--sidebar-bg: #fafafa;
--sidebar-fg: hsl(0, 0%, 0%);
--sidebar-non-existant: #aaaaaa;
--sidebar-active: #1f1fff;
--sidebar-spacer: #f4f4f4;
--scrollbar: #8f8f8f;
--icons: #747474;
--icons-hover: #000000;
--links: #20609f;
--inline-code-color: #301900;
--theme-popup-bg: #fafafa;
--theme-popup-border: #cccccc;
--theme-hover: #e6e6e6;
--quote-bg: hsl(197, 37%, 96%);
--quote-border: hsl(197, 37%, 91%);
--table-border-color: hsl(0, 0%, 95%);
--table-header-bg: hsl(0, 0%, 80%);
--table-alternate-bg: hsl(0, 0%, 97%);
--searchbar-border-color: #aaa;
--searchbar-bg: #fafafa;
--searchbar-fg: #000;
--searchbar-shadow-color: #aaa;
--searchresults-header-fg: #666;
--searchresults-border-color: #888;
--searchresults-li-bg: #e4f2fe;
--search-mark-bg: #a2cff5;
--color-scheme: light;
}
.navy {
--bg: hsl(226, 23%, 11%);
--fg: #bcbdd0;
--sidebar-bg: #282d3f;
--sidebar-fg: #c8c9db;
--sidebar-non-existant: #505274;
--sidebar-active: #2b79a2;
--sidebar-spacer: #2d334f;
--scrollbar: var(--sidebar-fg);
--icons: #737480;
--icons-hover: #b7b9cc;
--links: #2b79a2;
--inline-code-color: #c5c8c6;
--theme-popup-bg: #161923;
--theme-popup-border: #737480;
--theme-hover: #282e40;
--quote-bg: hsl(226, 15%, 17%);
--quote-border: hsl(226, 15%, 22%);
--table-border-color: hsl(226, 23%, 16%);
--table-header-bg: hsl(226, 23%, 31%);
--table-alternate-bg: hsl(226, 23%, 14%);
--searchbar-border-color: #aaa;
--searchbar-bg: #aeaec6;
--searchbar-fg: #000;
--searchbar-shadow-color: #aaa;
--searchresults-header-fg: #5f5f71;
--searchresults-border-color: #5c5c68;
--searchresults-li-bg: #242430;
--search-mark-bg: #a2cff5;
--color-scheme: dark;
}
.rust {
--bg: hsl(60, 9%, 87%);
--fg: #262625;
--sidebar-bg: #3b2e2a;
--sidebar-fg: #c8c9db;
--sidebar-non-existant: #505254;
--sidebar-active: #e69f67;
--sidebar-spacer: #45373a;
--scrollbar: var(--sidebar-fg);
--icons: #737480;
--icons-hover: #262625;
--links: #2b79a2;
--inline-code-color: #6e6b5e;
--theme-popup-bg: #e1e1db;
--theme-popup-border: #b38f6b;
--theme-hover: #99908a;
--quote-bg: hsl(60, 5%, 75%);
--quote-border: hsl(60, 5%, 70%);
--table-border-color: hsl(60, 9%, 82%);
--table-header-bg: #b3a497;
--table-alternate-bg: hsl(60, 9%, 84%);
--searchbar-border-color: #aaa;
--searchbar-bg: #fafafa;
--searchbar-fg: #000;
--searchbar-shadow-color: #aaa;
--searchresults-header-fg: #666;
--searchresults-border-color: #888;
--searchresults-li-bg: #dec2a2;
--search-mark-bg: #e69f67;
--color-scheme: light;
}
@media (prefers-color-scheme: dark) {
.light.no-js {
--bg: hsl(200, 7%, 8%);
--fg: #98a3ad;
--sidebar-bg: #292c2f;
--sidebar-fg: #a1adb8;
--sidebar-non-existant: #505254;
--sidebar-active: #3473ad;
--sidebar-spacer: #393939;
--scrollbar: var(--sidebar-fg);
--icons: #43484d;
--icons-hover: #b3c0cc;
--links: #2b79a2;
--inline-code-color: #c5c8c6;
--theme-popup-bg: #141617;
--theme-popup-border: #43484d;
--theme-hover: #1f2124;
--quote-bg: hsl(234, 21%, 18%);
--quote-border: hsl(234, 21%, 23%);
--table-border-color: hsl(200, 7%, 13%);
--table-header-bg: hsl(200, 7%, 28%);
--table-alternate-bg: hsl(200, 7%, 11%);
--searchbar-border-color: #aaa;
--searchbar-bg: #b7b7b7;
--searchbar-fg: #000;
--searchbar-shadow-color: #aaa;
--searchresults-header-fg: #666;
--searchresults-border-color: #98a3ad;
--searchresults-li-bg: #2b2b2f;
--search-mark-bg: #355c7d;
}
}

270
public/theme/index.js Normal file
View File

@@ -0,0 +1,270 @@
(function themes() {
var html = document.querySelector('html');
var themeToggleButton = document.getElementById('theme-toggle');
var themePopup = document.getElementById('theme-list');
var themeColorMetaTag = document.querySelector('meta[name="theme-color"]');
function showThemes() {
themePopup.style.display = 'block';
themeToggleButton.setAttribute('aria-expanded', true);
themePopup.querySelector('button#' + get_theme()).focus();
}
function updateThemeSelected() {
themePopup.querySelectorAll('.theme-selected').forEach(function (el) {
el.classList.remove('theme-selected');
});
themePopup.querySelector('button#' + get_theme()).classList.add('theme-selected');
window.typstChangeTheme();
}
function hideThemes() {
themePopup.style.display = 'none';
themeToggleButton.setAttribute('aria-expanded', false);
themeToggleButton.focus();
}
function get_theme() {
var theme;
try {
theme = localStorage.getItem('shiroa-theme');
} catch (e) {}
if (theme === null || theme === undefined) {
return default_theme;
} else {
return theme;
}
}
function set_theme(theme, store = true) {
setTimeout(function () {
themeColorMetaTag.content = getComputedStyle(document.documentElement).backgroundColor;
}, 1);
var previousTheme = get_theme();
if (store) {
try {
localStorage.setItem('shiroa-theme', theme);
} catch (e) {}
}
html.classList.remove(previousTheme);
html.classList.add(theme);
updateThemeSelected();
}
// Set theme
var theme = get_theme();
set_theme(theme, false);
themeToggleButton.addEventListener('click', function () {
if (themePopup.style.display === 'block') {
hideThemes();
} else {
showThemes();
}
});
themePopup.addEventListener('click', function (e) {
var theme;
if (e.target.className === 'theme') {
theme = e.target.id;
} else if (e.target.parentElement.className === 'theme') {
theme = e.target.parentElement.id;
} else {
return;
}
set_theme(theme);
});
themePopup.addEventListener('focusout', function (e) {
// e.relatedTarget is null in Safari and Firefox on macOS (see workaround below)
if (
!!e.relatedTarget &&
!themeToggleButton.contains(e.relatedTarget) &&
!themePopup.contains(e.relatedTarget)
) {
hideThemes();
}
});
// Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang/mdBook/issues/628
document.addEventListener('click', function (e) {
if (
themePopup.style.display === 'block' &&
!themeToggleButton.contains(e.target) &&
!themePopup.contains(e.target)
) {
hideThemes();
}
});
document.addEventListener('keydown', function (e) {
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
return;
}
if (!themePopup.contains(e.target)) {
return;
}
switch (e.key) {
case 'Escape':
e.preventDefault();
hideThemes();
break;
case 'ArrowUp':
e.preventDefault();
var li = document.activeElement.parentElement;
if (li && li.previousElementSibling) {
li.previousElementSibling.querySelector('button').focus();
}
break;
case 'ArrowDown':
e.preventDefault();
var li = document.activeElement.parentElement;
if (li && li.nextElementSibling) {
li.nextElementSibling.querySelector('button').focus();
}
break;
case 'Home':
e.preventDefault();
themePopup.querySelector('li:first-child button').focus();
break;
case 'End':
e.preventDefault();
themePopup.querySelector('li:last-child button').focus();
break;
}
});
})();
(function sidebar() {
var html = document.querySelector('html');
var sidebar = document.getElementById('sidebar');
var sidebarLinks = document.querySelectorAll('#sidebar a');
var sidebarToggleButton = document.getElementById('sidebar-toggle');
var sidebarResizeHandle = document.getElementById('sidebar-resize-handle');
var firstContact = null;
sidebar.addEventListener('transitionend', () => {
window.typstRerender(true);
});
function showSidebar() {
html.classList.remove('sidebar-hidden');
html.classList.add('sidebar-visible');
Array.from(sidebarLinks).forEach(function (link) {
link.setAttribute('tabIndex', 0);
});
sidebarToggleButton.setAttribute('aria-expanded', true);
sidebar.setAttribute('aria-hidden', false);
try {
localStorage.setItem('shiroa-sidebar', 'visible');
} catch (e) {}
}
var sidebarAnchorToggles = document.querySelectorAll('#sidebar a.toggle');
function toggleSection(ev) {
ev.currentTarget.parentElement.classList.toggle('expanded');
}
Array.from(sidebarAnchorToggles).forEach(function (el) {
el.addEventListener('click', toggleSection);
});
function hideSidebar() {
html.classList.remove('sidebar-visible');
html.classList.add('sidebar-hidden');
Array.from(sidebarLinks).forEach(function (link) {
link.setAttribute('tabIndex', -1);
});
sidebarToggleButton.setAttribute('aria-expanded', false);
sidebar.setAttribute('aria-hidden', true);
try {
localStorage.setItem('shiroa-sidebar', 'hidden');
} catch (e) {}
}
// Toggle sidebar
sidebarToggleButton.addEventListener('click', function sidebarToggle() {
if (html.classList.contains('sidebar-hidden')) {
var current_width = parseInt(
document.documentElement.style.getPropertyValue('--sidebar-width'),
10,
);
if (current_width < 150) {
document.documentElement.style.setProperty('--sidebar-width', '150px');
}
showSidebar();
} else if (html.classList.contains('sidebar-visible')) {
hideSidebar();
} else {
if (getComputedStyle(sidebar)['transform'] === 'none') {
hideSidebar();
} else {
showSidebar();
}
}
});
sidebarResizeHandle.addEventListener('mousedown', initResize, false);
function initResize(e) {
window.addEventListener('mousemove', resize, false);
window.addEventListener('mouseup', stopResize, false);
html.classList.add('sidebar-resizing');
}
function resize(e) {
window.typstRerender(true);
var pos = e.clientX - sidebar.offsetLeft;
if (pos < 20) {
hideSidebar();
} else {
if (html.classList.contains('sidebar-hidden')) {
showSidebar();
}
pos = Math.min(pos, window.innerWidth - 100);
document.documentElement.style.setProperty('--sidebar-width', pos + 'px');
}
}
//on mouseup remove windows functions mousemove & mouseup
function stopResize(e) {
window.typstRerender(false);
html.classList.remove('sidebar-resizing');
window.removeEventListener('mousemove', resize, false);
window.removeEventListener('mouseup', stopResize, false);
}
document.addEventListener(
'touchstart',
function (e) {
firstContact = {
x: e.touches[0].clientX,
time: Date.now(),
};
},
{ passive: true },
);
document.addEventListener(
'touchmove',
function (e) {
if (!firstContact) return;
var curX = e.touches[0].clientX;
var xDiff = curX - firstContact.x,
tDiff = Date.now() - firstContact.time;
if (tDiff < 250 && Math.abs(xDiff) >= 150) {
if (xDiff >= 0 && firstContact.x < Math.min(document.body.clientWidth * 0.25, 300))
showSidebar();
else if (xDiff < 0 && curX < 300) hideSidebar();
firstContact = null;
}
},
{ passive: true },
);
})();