Repository with sources and generator of https://larlet.fr/david/ https://larlet.fr/david/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <!DOCTYPE html><!-- This is a valid HTML5 document. -->
  2. <!-- Screen readers, SEO, extensions and so on. -->
  3. <html lang="fr">
  4. <!-- Has to be within the first 1024 bytes, hence before the `title` element
  5. See: https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset -->
  6. <meta charset="utf-8">
  7. <!-- Why no `X-UA-Compatible` meta: https://stackoverflow.com/a/6771584 -->
  8. <!-- The viewport meta is quite crowded and we are responsible for that.
  9. See: https://codepen.io/tigt/post/meta-viewport-for-2015 -->
  10. <meta name="viewport" content="width=device-width,initial-scale=1">
  11. <!-- Required to make a valid HTML5 document. -->
  12. <title>
  13. Tag #processus
  14. — David Larlet</title>
  15. <meta name="description" content="Publications relatives au tag #processus">
  16. <!-- That good ol' feed, subscribe :). -->
  17. <link rel="alternate"
  18. type="application/atom+xml"
  19. title="Feed"
  20. href="/david/log/">
  21. <!-- Generated from https://realfavicongenerator.net/ such a mess. -->
  22. <link rel="apple-touch-icon"
  23. sizes="180x180"
  24. href="/static/david/icons2/apple-touch-icon.png">
  25. <link rel="icon"
  26. type="image/png"
  27. sizes="32x32"
  28. href="/static/david/icons2/favicon-32x32.png">
  29. <link rel="icon"
  30. type="image/png"
  31. sizes="16x16"
  32. href="/static/david/icons2/favicon-16x16.png">
  33. <link rel="manifest" href="/static/david/icons2/site.webmanifest">
  34. <link rel="mask-icon"
  35. href="/static/david/icons2/safari-pinned-tab.svg"
  36. color="#07486c">
  37. <link rel="shortcut icon" href="/static/david/icons2/favicon.ico">
  38. <meta name="msapplication-TileColor" content="#f7f7f7">
  39. <meta name="msapplication-config"
  40. content="/static/david/icons2/browserconfig.xml">
  41. <meta name="theme-color"
  42. content="#f7f7f7"
  43. media="(prefers-color-scheme: light)">
  44. <meta name="theme-color"
  45. content="#272727"
  46. media="(prefers-color-scheme: dark)">
  47. <!-- Is that even respected? Retrospectively? What a shAItshow…
  48. https://neil-clarke.com/block-the-bots-that-feed-ai-models-by-scraping-your-website/ -->
  49. <meta name="robots" content="noai, noimageai">
  50. <!-- Documented, feel free to shoot an email. -->
  51. <link rel="stylesheet" href="/static/david/css/style_2021-01-20.css">
  52. <!-- See https://www.zachleat.com/web/comprehensive-webfonts/ for the trade-off. -->
  53. <link rel="preload"
  54. href="/static/david/css/fonts/triplicate_t4_poly_regular.woff2"
  55. as="font"
  56. type="font/woff2"
  57. media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)"
  58. crossorigin>
  59. <link rel="preload"
  60. href="/static/david/css/fonts/triplicate_t4_poly_bold.woff2"
  61. as="font"
  62. type="font/woff2"
  63. media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)"
  64. crossorigin>
  65. <link rel="preload"
  66. href="/static/david/css/fonts/triplicate_t4_poly_italic.woff2"
  67. as="font"
  68. type="font/woff2"
  69. media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)"
  70. crossorigin>
  71. <link rel="preload"
  72. href="/static/david/css/fonts/triplicate_t3_regular.woff2"
  73. as="font"
  74. type="font/woff2"
  75. media="(prefers-color-scheme: dark)"
  76. crossorigin>
  77. <link rel="preload"
  78. href="/static/david/css/fonts/triplicate_t3_bold.woff2"
  79. as="font"
  80. type="font/woff2"
  81. media="(prefers-color-scheme: dark)"
  82. crossorigin>
  83. <link rel="preload"
  84. href="/static/david/css/fonts/triplicate_t3_italic.woff2"
  85. as="font"
  86. type="font/woff2"
  87. media="(prefers-color-scheme: dark)"
  88. crossorigin>
  89. <script>
  90. function toggleTheme(themeName) {
  91. document.documentElement.classList.toggle(
  92. 'forced-dark',
  93. themeName === 'dark'
  94. )
  95. document.documentElement.classList.toggle(
  96. 'forced-light',
  97. themeName === 'light'
  98. )
  99. }
  100. const selectedTheme = localStorage.getItem('theme')
  101. if (selectedTheme !== 'undefined') {
  102. toggleTheme(selectedTheme)
  103. }
  104. </script>
  105. <style type="text/css">
  106. details[open] summary {
  107. display: none;
  108. }
  109. </style>
  110. <body class="remarkdown h1-underline h2-underline h3-underline em-underscore hr-center ul-star pre-tick"
  111. data-instant-intensity="viewport-all">
  112. <header>
  113. <h1>Publications relatives au tag #processus</h1>
  114. </header>
  115. <nav>
  116. <p class="center">
  117. <a href="/david/" title="Aller à l’accueil">
  118. <svg class="icon icon-home">
  119. <use xlink:href="/static/david/icons2/symbol-defs-2021-12.svg#icon-home"></use>
  120. </svg>
  121. Accueil</a>
  122. • <a rel="tags"
  123. href="/david/#tags-2023"
  124. title="Liste de toutes les étiquettes">
  125. <svg class="icon icon-tags">
  126. <use xlink:href="/static/david/icons2/symbol-defs-2021-12.svg#icon-tags"></use>
  127. </svg>
  128. Étiquettes</a>
  129. </p>
  130. </nav>
  131. <hr>
  132. <main>
  133. <p>Les plus récentes en premier, les 3 premières sont dépliées et ensuite c’est à la demande, bonne exploration !</p>
  134. <h2>
  135. <a href="/david/2024/01/12/" title="Lien permanent vers cet article">Personnel</a> (2024-01-12)
  136. </h2>
  137. <blockquote>
  138. <p>Mes lieux de lecture et d’écriture sont très associés. J’écris parce que je&nbsp;lis.</p>
  139. <p>J’écris de deux&nbsp;façons.</p>
  140. <p><cite><em><a data-link-domain="la-grange.net" href="https://www.la-grange.net/2024/01/11/pourquoi">je ne sais pas pourquoi</a> <a href="/david/cache/2024/87c468a4eddabe5d2c28e902d7f17504/" title="Copie locale au 2024-01-11">[archive]</a></em></cite></p>
  141. </blockquote>
  142. <p>Karl nous parle de ses moments / lieux d’écriture et de lecture. Je me suis souvent posé cette question et je reconnais des <abbr title="Où Lire, Où Écrire.">oloés</abbr> communs (une <a data-link-domain="tw5.immateriel.fr" href="https://tw5.immateriel.fr/wiki/immateriel/b/YXGEDFB">définition par ici</a> <a href="/david/cache/2024/89dbef9daef24f311b6401cef62f5855/" title="Copie locale au 2024-01-11">[archive]</a>). Mes moments et lieux sont beaucoup plus traditionnels, c’est principalement le soir et dans mon bureau-chambre. Mais il n’y a pas de règle stricte pour autant. Parfois, l’envie d’écrire va être trop forte lors d’une lecture en cours de journée, d’autres fois je vais me réveiller tôt et commencer à écrire dans ma tête depuis mon lit ou sous la douche. Une idée peut arriver et/ou s’étirer en faisant du sport ou dans des contextes&nbsp;routiniers.</p>
  143. <p>Et puis il y a l’écriture qui appelle une autre écriture, ce moment de <a data-link-domain="blog.jim-nielsen.com" href="https://blog.jim-nielsen.com/2023/blogging-and-compositing/">compost</a> <a href="/david/cache/2024/5030196507bcf3e06162e9eaed40abbe/" title="Copie locale au 2024-01-11">[archive]</a> où l’on sent qu’il y avait une deuxième vie possible à cette réflexion. Un autre <a href="/david/stream/2018/04/07/">tour de spirale</a>.</p>
  144. <blockquote lang="en">
  145. <p><strong>marketing feels like a layer of veneer, full of shiny promises in order to reel you in, where the goal is to collect you — as a part of an&nbsp;“audience.”</strong></p>
  146. <p>but I think, in this race to “build an audience,” somewhere in the process, something is missing, left behind — perhaps, a sense of humanity, or individual complexity, or truth, or&nbsp;intimacy.</p>
  147. <p>I don’t want to feel like I’m just an email address, an IP address, or a potential “lead.” I want to feel fully seen. human.</p>
  148. <p>[…] instead of “building an audience,” build a world. <mark>build a digital garden-ecosystem, that exists</mark> — first and primarily — <em>for itself</em>. a world that doesn’t need likes, traffic, subscribers, or clicks — in order to validate its&nbsp;existence.</p>
  149. <p><cite><em><a data-link-domain="keningzhu.com" href="https://keningzhu.com/journal/build-a-world-not-an-audience">build a world, not an audience</a> <a href="/david/cache/2024/cd2fda3dae5d89990f73fbdaa1c3b491/" title="Copie locale au 2024-01-11">[archive]</a></em></cite></p>
  150. </blockquote>
  151. <hr />
  152. <blockquote lang="en">
  153. <p>These are all very interesting questions but for me, the more pressing question is a slightly different one: which <em>you</em> is your personal site representing? We often don’t pay too much attention to this but <mark>we all have different ways of being&nbsp;ourselves.</mark></p>
  154. <p>So which one of these should my site represent? Should my site be the personal site of the Manu freelance web developer, with his interests in digital typography, minimal design, and simple websites? Or should represent the slightly competitive on the basketball court Manu, who doesn’t really care all that much about winning but is concerned about having fun? Or maybe it should represent Manu the romantic partner, with all his worry about the practical aspects of life but also full of affection for his partner? The list goes on and&nbsp;on.</p>
  155. <p><cite><em><a data-link-domain="manuelmoreale.com" href="https://manuelmoreale.com/the-personality-of-a-personal-website">The personality of a personal website</a> <a href="/david/cache/2024/e5c1ca8e3beeb0d256a064832c3566aa/" title="Copie locale au 2024-01-11">[archive]</a></em></cite></p>
  156. </blockquote>
  157. <p>Je m’interroge souvent sur ce que j’essaye de cacher ici. Ce que cela raconte de ma personnalité, si l’image retournée est <a data-link-domain="thom4.net" href="https://thom4.net/2023/02/01/carnets/">vraiment fidèle</a> <a href="/david/cache/2024/09c0739036ea4a8b6c985e127fe7e3c8/" title="Copie locale au 2024-01-11">[archive]</a> après tout. L’écriture en ligne reste une forme d’expression qui s’attend au regard des autres. Si j’entretiens un journal <em>extime</em> depuis tant d’années c’est bien qu’il y a un enjeu à ce niveau&nbsp;là.</p>
  158. <hr />
  159. <blockquote lang="en">
  160. <p>We shape our structures and afterward our structures shape us, but the <em>we</em> of the first clause and the <em>us</em> of the second <mark>are not the&nbsp;same.</mark></p>
  161. <p><cite><a data-link-domain="erinkissane.com" href="https://erinkissane.com/tomorrow-and-tomorrow-and-tomorrow">Tomorrow &amp; Tomorrow &amp; Tomorrow</a> <a href="/david/cache/2024/62bf3ce6ef66e39b7f250a6123d92e66/" title="Copie locale au 2024-01-11">[archive]</a></cite></p>
  162. </blockquote>
  163. <p>En rebond de la <a data-link-domain="quaternum.net" href="https://www.quaternum.net/2024/01/08/tools-shape-practices-shape-tools/">découverte d’Antoine</a> <a href="/david/cache/2024/34fec23081019abd741e0578b050c40e/" title="Copie locale au 2024-01-11">[archive]</a>. Une autre façon d’être&nbsp;dé·formé.</p>
  164. <hr />
  165. <p>Deux outils autour de la transformation de&nbsp;vidéos&nbsp;:</p>
  166. <ul>
  167. <li><a data-link-domain="ybouane.com" href="https://ybouane.com/ffmpeg-ui">FFMPEG&nbsp;UI</a></li>
  168. <li><a data-link-domain="mifi.no" href="https://mifi.no/losslesscut/">LosslessCut</a></li>
  169. </ul>
  170. <h2>
  171. <a href="/david/2024/01/08/" title="Lien permanent vers cet article">Liens</a> (2024-01-08)
  172. </h2>
  173. <p>Je décide de tester d’ajouter le domaine du lien après la lien, j’ai souvent besoin de cette information avant de cliquer sur un lien. Pour cela je charge le domaine en Python grâce à la flexibilité de <a data-link-domain="mistune.lepture.com" href="https://mistune.lepture.com/en/latest/">mistune</a> et je m’en sers ensuite en CSS pour l’afficher&nbsp;dynamiquement&nbsp;:</p>
  174. <pre><code>a[data-link-domain]::after {
  175. content: &quot; [&quot; attr(data-link-domain) &quot;]&quot;;
  176. font-size: smaller;
  177. color: var(--link-color-domain);
  178. }
  179. </code></pre>
  180. <p>Je fais aussi des tests de soulignement avec un gradient qui irait de la couleur du lien principal à celle du&nbsp;domaine&nbsp;:</p>
  181. <pre><code>a {
  182. text-decoration-skip-ink: auto;
  183. text-decoration-thickness: calc(var(--fluid-0) / 10);
  184. position: relative;
  185. }
  186. a::before {
  187. content: '';
  188. width: 100%;
  189. position: absolute;
  190. left: 0;
  191. bottom: -1px;
  192. height: calc(var(--fluid-0) / 10);
  193. background: linear-gradient(
  194. to right,
  195. var(--link-color),
  196. var(--link-color-domain)
  197. );
  198. }
  199. </code></pre>
  200. <p>Mais au final je jette car je perds la partie <code>skip-ink</code> que je trouve chouette comme évolution de rendu possible. Toujours cet équilibre complexité / expérience /&nbsp;accessibilité.</p>
  201. <p>Plus tard, je commence l’implémentation de l’archivage des liens distants. J’ai pas mal d’idées mais je sais qu’il ne faut pas que je prenne trop de retard dans la récupération sinon je ne vais pas avoir l’énergie pour reprendre l’historique. Ce sera probablement l’occasion de faire un autre <em>Web Component</em> dédié. En suivant les recommandations <a data-link-domain="fedi.larlet.fr" href="https://fedi.larlet.fr/@david/111703611010197838">sur masto</a>, je les nomme <code>archive</code> pour le moment et je conserve la date de récupération de l’article car c’est une information importante. J’adapterai le style plus&nbsp;tard.</p>
  202. <p>Il faut que j’améliore cette automatisation car c’est assez fastidieux pour le moment, beaucoup de retouches manuelles pour obtenir un article lisible selon les sources. Je vais aussi réduire le nombre de liens que j’archive, les sources techniques ont probablement moins d’intérêt dans la&nbsp;durée.</p>
  203. <p>Chaque lien distant prend une longueur non négligeable suite à ces deux&nbsp;ajouts&nbsp;🤔.</p>
  204. <hr />
  205. <blockquote>
  206. <p>Ce billet illustre la loi qui dit “Moins un blog est mis à jour, plus il y a de probabilité que ce qui y est publié a pour sujet les aspects techniques dudit&nbsp;blog”.</p>
  207. <p><cite><em><a data-link-domain="blog.professeurjoachim.com" href="https://blog.professeurjoachim.com/billet/2024-01-05-ma-page-now-ou-plutot-en-ce-moment">Ma page /now (ou plutôt /en-ce-moment)</a> <a href="/david/cache/2024/076169df8a4bd9dde9a4637c6b306dff/" title="Copie locale au 2024-01-07">[archive]</a></em></cite></p>
  208. </blockquote>
  209. <p>J’ai ri. Je n’ai jamais fait une telle page car je sais que je n’arriverais pas à la maintenir à jour. Je galère déjà avec mon <a data-link-domain="larlet.com" href="https://larlet.com/">profil pro</a>.</p>
  210. <blockquote lang="en">
  211. <p>I also started noticing when people do this subconiously. For example, most software engineers I know hate blogging, but <mark>they like building their own blog engine to make blogging more pleasant</mark> (I’m very guilty of this&nbsp;too).</p>
  212. <p>Kent Beck nailed it: “for each desired change, make the change easy (warning: this may be hard), then make the easy&nbsp;change”.</p>
  213. <p><cite><em><a data-link-domain="frantic.im" href="https://frantic.im/opening-mail/">Opening Mail</a> <a href="/david/cache/2024/7a223e552e8a8e3e11c759cbc5bc3ffa/" title="Copie locale au 2024-01-07">[archive]</a></em></cite></p>
  214. </blockquote>
  215. <p>Note&nbsp;: cette année, je ne ferai aucun lien vers 𝕏 (twitter.com) depuis mes&nbsp;articles.</p>
  216. <hr />
  217. <p>L’hiver commence maintenant le 7&nbsp;janvier à Montréal. Phénomène météorologique exceptionnel <em>et</em> tendance&nbsp;climatique.</p>
  218. <h2>
  219. <a href="/david/2024/01/06/" title="Lien permanent vers cet article">Objectif</a> (2024-01-06)
  220. </h2>
  221. <p>C’est fou comme le fait de se donner un objectif (sportif) change la donne en terme de motivation. Pour cette année, ce sera la <em>Traversée de Charlevoix</em>. Je vais essayer de documenter le processus de&nbsp;préparation.</p>
  222. <hr />
  223. <p>Au détour d’un vieux&nbsp;chalet&nbsp;:</p>
  224. <figure>
  225. <a href="/static/david/2024/2024-01-05-la-recherche-sida.jpg"
  226. title="Cliquer pour une version haute résolution">
  227. <img
  228. src="/static/david/2024/2024-01-05-la-recherche-sida.jpg"
  229. width="4032" height="3024"
  230. srcset="/static/david/2024/2024-01-05-la-recherche-sida.jpg 4032w, /static/david/2024/2024-01-05-la-recherche-sida_660x440.jpg 660w, /static/david/2024/2024-01-05-la-recherche-sida_990x660.jpg 990w, /static/david/2024/2024-01-05-la-recherche-sida_1320x880.jpg 1320w"
  231. sizes="min(100vw, calc(100vh * 4032 / 3024))"
  232. loading="lazy"
  233. decoding="async"
  234. alt="Photo du Magazine «&nbsp;La Recherche&nbsp;» (couverture)">
  235. </a>
  236. <figcaption>La Recherche, juin 1985. Les mécanismes biologiques autour du SIDA étaient en cours de&nbsp;découverte.</figcaption>
  237. </figure>
  238. <p>D’autres temps, d’autres&nbsp;démons.</p>
  239. <hr />
  240. <p>Le dossier spécial sur la voiture électrique se terminait&nbsp;ainsi&nbsp;:</p>
  241. <blockquote>
  242. <p>Nous sommes loin des anticipations du début des années 1970&nbsp;qui attribuaient au véhicule électrique 7&nbsp;à 10&#8239;% du parc automobile à l’horizon 1990-1995. L’avenir même du véhicule, du moins en ce qui concerne l’étendue de son champ d’utilisation, demeure incertain. Celle-ci sera fonction des progrès qui seront réalisés sur les générateurs électrochimiques. Les filières potentiellement les plus performantes (filières chaudes, filières organiques, piles à combustibles) n’en sont encore qu’au stade de la recherche appliquée ou du développement et quelques-unes au stade de la recherche fondamentale. Mais des progrès sont enregistrés et les raisons profondes de poursuivre l’effort demeurent. <mark>Si une volonté politique s’affirme et parvient à motiver les premiers utilisateurs potentiels</mark> (administrations et grands organismes publics), on peut espérer voir sortir les premières séries industrielles de véhicules au début de la prochaine&nbsp;décennie.</p>
  243. </blockquote>
  244. <p>D’autres époques, mêmes utopies. Je vois de plus en plus de gros véhicules électriques, j’ai même croisé une JEEP l’autre fois. Tristesse du rêve&nbsp;américain.</p>
  245. <hr />
  246. <blockquote>
  247. <p>J’aime bien l’expression «&nbsp;sans nom&nbsp;» (genre une galère sans nom, une injustice sans nom)<br />
  248. Ça fait un peu eldritchien pour moi, genre quelque chose de si terrible qu’on ne peut pas le nommer, qu’on ne peut pas concevoir&nbsp;entièrement</p>
  249. <p>Mais aussi ça me donne l’impression que si je nomme les choses ça va régler une partie du problème c’est&nbsp;fun</p>
  250. <p>«&nbsp;ma vie était une galère sans nom c’était terrible. Bha je l’ai appelé bob et du coup depuis ça&nbsp;va&nbsp;»</p>
  251. <p><cite><a data-link-domain="pipou.academy" href="https://pipou.academy/@tiphaine/111629699683457788">@tiphaine@pipou.academy</a></cite></p>
  252. </blockquote>
  253. </main>
  254. <hr>
  255. <footer>
  256. <p>
  257. <nobr>
  258. <a href="/david/" title="Aller à l’accueil">
  259. <svg class="icon icon-home">
  260. <use xlink:href="/static/david/icons2/symbol-defs-2022-03.svg#icon-home"></use>
  261. </svg>
  262. Accueil</a>
  263. </nobr>
  264. <nobr>
  265. <a href="/david/log/" title="Accès au flux RSS">
  266. <svg class="icon icon-rss2">
  267. <use xlink:href="/static/david/icons2/symbol-defs-2022-03.svg#icon-rss2"></use>
  268. </svg>
  269. Suivre</a>
  270. </nobr>
  271. <nobr>
  272. <a href="http://larlet.com"
  273. title="Go to my English profile"
  274. data-instant>
  275. <svg class="icon icon-user-tie">
  276. <use xlink:href="/static/david/icons2/symbol-defs-2022-03.svg#icon-user-tie"></use>
  277. </svg>
  278. Pro</a>
  279. </nobr>
  280. <nobr>
  281. <a href="mailto:david%40larlet.fr" title="Envoyer un courriel">
  282. <svg class="icon icon-mail">
  283. <use xlink:href="/static/david/icons2/symbol-defs-2022-03.svg#icon-mail"></use>
  284. </svg>
  285. Email</a>
  286. </nobr>
  287. <nobr>
  288. <abbr class="nowrap"
  289. title="Hébergeur : Alwaysdata, 62 rue Tiquetonne 75002 Paris, +33184162340">
  290. <svg class="icon icon-hammer2">
  291. <use xlink:href="/static/david/icons2/symbol-defs-2022-03.svg#icon-hammer2"></use>
  292. </svg>
  293. Légal</abbr>
  294. </nobr>
  295. </p>
  296. <template id="theme-selector">
  297. <form>
  298. <fieldset>
  299. <legend>
  300. <svg class="icon icon-brightness-contrast">
  301. <use xlink:href="/static/david/icons2/symbol-defs-2022-03.svg#icon-brightness-contrast"></use>
  302. </svg>
  303. Thème
  304. </legend>
  305. <label>
  306. <input type="radio" value="auto" name="chosen-color-scheme" checked>
  307. Auto
  308. </label>
  309. <label>
  310. <input type="radio" value="dark" name="chosen-color-scheme">
  311. Foncé
  312. </label>
  313. <label>
  314. <input type="radio" value="light" name="chosen-color-scheme">
  315. Clair
  316. </label>
  317. </fieldset>
  318. </form>
  319. </template>
  320. </footer>
  321. <script src="/static/david/js/instantpage-5.1.0.min.js" type="module"></script>
  322. <script>
  323. function loadThemeForm(templateName) {
  324. const themeSelectorTemplate = document.querySelector(templateName)
  325. const form = themeSelectorTemplate.content.firstElementChild
  326. themeSelectorTemplate.replaceWith(form)
  327. form.addEventListener('change', (e) => {
  328. const chosenColorScheme = e.target.value
  329. localStorage.setItem('theme', chosenColorScheme)
  330. toggleTheme(chosenColorScheme)
  331. })
  332. const selectedTheme = localStorage.getItem('theme')
  333. if (selectedTheme && selectedTheme !== 'undefined') {
  334. form.querySelector(`[value="${selectedTheme}"]`).checked = true
  335. }
  336. }
  337. const prefersColorSchemeDark = '(prefers-color-scheme: dark)'
  338. window.addEventListener('load', () => {
  339. let hasDarkRules = false
  340. for (const styleSheet of Array.from(document.styleSheets)) {
  341. let mediaRules = []
  342. for (const cssRule of styleSheet.cssRules) {
  343. if (cssRule.type !== CSSRule.MEDIA_RULE) {
  344. continue
  345. }
  346. // WARNING: Safari does not have/supports `conditionText`.
  347. if (cssRule.conditionText) {
  348. if (cssRule.conditionText !== prefersColorSchemeDark) {
  349. continue
  350. }
  351. } else {
  352. if (cssRule.cssText.startsWith(prefersColorSchemeDark)) {
  353. continue
  354. }
  355. }
  356. mediaRules = mediaRules.concat(Array.from(cssRule.cssRules))
  357. }
  358. // WARNING: do not try to insert a Rule to a styleSheet you are
  359. // currently iterating on, otherwise the browser will be stuck
  360. // in a infinite loop…
  361. for (const mediaRule of mediaRules) {
  362. styleSheet.insertRule(mediaRule.cssText)
  363. hasDarkRules = true
  364. }
  365. }
  366. if (hasDarkRules) {
  367. loadThemeForm('#theme-selector')
  368. }
  369. })
  370. </script>
  371. </body>
  372. </html>