Add menu-bar links

This commit is contained in:
Unisko PENG, 2023-03-29 10:23:35 +08:00
parent 46fcc478d0
commit 9e2ab10221
2 changed files with 246 additions and 231 deletions

View File

@ -1,151 +1,168 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html lang="zh_CN" class="sidebar-visible no-js light"> <html lang="zh_CN" class="sidebar-visible no-js light">
<head> <head>
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>序和前言 - Yet another Chinese rust-lang book.</title> <title>序和前言 - Yet another Chinese rust-lang book.</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
<link rel="stylesheet" href="tomorrow-night.css"> <link rel="stylesheet" href="tomorrow-night.css">
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
<link rel="stylesheet" href="theme/pagetoc.css"> <link rel="stylesheet" href="theme/pagetoc.css">
</head> </head>
<body> <body>
<div id="body-container"> <div id="body-container">
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
<script> <script>
var path_to_root = ""; var path_to_root = "";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light"; var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
</script> </script>
<!-- Work around some values being stored in localStorage wrapped in quotes --> <!-- Work around some values being stored in localStorage wrapped in quotes -->
<script> <script>
try { try {
var theme = localStorage.getItem('mdbook-theme'); var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar'); var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) { if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1)); localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
} }
if (sidebar.startsWith('"') && sidebar.endsWith('"')) { if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1)); localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
} }
} catch (e) { } } catch (e) { }
</script> </script>
<!-- Set the theme before any content is loaded, prevents flash --> <!-- Set the theme before any content is loaded, prevents flash -->
<script> <script>
var theme; var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; } if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html'); var html = document.querySelector('html');
html.classList.remove('no-js') html.classList.remove('no-js')
html.classList.remove('light') html.classList.remove('light')
html.classList.add(theme); html.classList.add(theme);
html.classList.add('js'); html.classList.add('js');
</script> </script>
<!-- Hide / unhide sidebar before it is displayed --> <!-- Hide / unhide sidebar before it is displayed -->
<script> <script>
var html = document.querySelector('html'); var html = document.querySelector('html');
var sidebar = null; var sidebar = null;
if (document.body.clientWidth >= 1080) { if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible'; sidebar = sidebar || 'visible';
} else { } else {
sidebar = 'hidden'; sidebar = 'hidden';
} }
html.classList.remove('sidebar-visible'); html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar); html.classList.add("sidebar-" + sidebar);
</script> </script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded affix "><a href="../index.html" class="active">序和前言</a></li><li class="chapter-item expanded "><a href="Ch01_Getting_Started.html"><strong aria-hidden="true">1.</strong> 入门</a></li><li class="chapter-item expanded "><a href="Ch02_Programming_a_Guessing_Game.html"><strong aria-hidden="true">2.</strong> 编写一个猜数游戏</a></li><li class="chapter-item expanded "><a href="Ch03_Common_Programming_Concepts.html"><strong aria-hidden="true">3.</strong> 常见编程概念</a></li><li class="spacer"></li><li class="chapter-item expanded affix "><li class="part-title">进阶</li><li class="chapter-item expanded "><a href="Ch04_Understanding_Ownership.html"><strong aria-hidden="true">4.</strong> “掌握” 所有权</a></li><li class="chapter-item expanded "><a href="Ch05_Using_Structs_to_Structure_Related_Data.html"><strong aria-hidden="true">5.</strong> 使用结构体来对相关数据进行架构</a></li><li class="chapter-item expanded "><a href="Ch06_Enums_and_Pattern_Matching.html"><strong aria-hidden="true">6.</strong> 枚举与模式匹配</a></li><li class="chapter-item expanded "><a href="Ch07_Managing_Growing_Projects_with_Packages_Crates_and_Modules.html"><strong aria-hidden="true">7.</strong> 使用包、代码箱与模组对日趋增长的项目进行管理</a></li><li class="chapter-item expanded "><a href="Ch08_Common_Collections.html"><strong aria-hidden="true">8.</strong> 常用集合数据结构</a></li><li class="chapter-item expanded "><a href="Ch09_Error_Handling.html"><strong aria-hidden="true">9.</strong> 错误的处理</a></li><li class="spacer"></li><li class="chapter-item expanded affix "><li class="part-title">深入掌握</li><li class="chapter-item expanded "><a href="Ch10_Generic_Types_Traits_and_Lifetimes.html"><strong aria-hidden="true">10.</strong> 泛型、特质与生命周期</a></li><li class="chapter-item expanded "><a href="Ch11_Writing_Automated_Tests.html"><strong aria-hidden="true">11.</strong> 编写自动化测试</a></li><li class="spacer"></li><li class="chapter-item expanded affix "><li class="part-title">上篇总结 - 实操</li><li class="chapter-item expanded "><a href="Ch12_An_IO_Project_Building_a_Command_Line_Program.html"><strong aria-hidden="true">12.</strong> 一个文件系统 I/O 项目:构建一个命令行程序</a></li><li class="spacer"></li><li class="chapter-item expanded affix "><li class="part-title">下篇</li><li class="chapter-item expanded "><a href="Ch13_Functional_Language_Features_Iterators_and_Closures.html"><strong aria-hidden="true">13.</strong> 函数式编程语言特性:迭代器与闭包</a></li><li class="chapter-item expanded "><a href="Ch14_More_about_Cargo_and_Crates-io.html"><strong aria-hidden="true">14.</strong> Cargo 的其他方面及 Crates.io</a></li><li class="chapter-item expanded "><a href="Ch15_Smart_Pointers.html"><strong aria-hidden="true">15.</strong> 灵巧指针</a></li><li class="chapter-item expanded "><a href="Ch16_Fearless_Concurrency.html"><strong aria-hidden="true">16.</strong> 无惧并发</a></li><li class="chapter-item expanded "><a href="Ch17_Object_Oriented_Programming_Features_of_Rust.html"><strong aria-hidden="true">17.</strong> Rust 的面向对象编程特性</a></li><li class="chapter-item expanded "><a href="Ch18_Patterns_and_Matching.html"><strong aria-hidden="true">18.</strong> 模式与匹配</a></li><li class="chapter-item expanded "><a href="Ch19_Advanced_Features.html"><strong aria-hidden="true">19.</strong> 先进特性</a></li><li class="chapter-item expanded "><a href="Ch20_Final_Project_Building_a_Multithreaded_Web_Server.html"><strong aria-hidden="true">20.</strong> 最后项目:构建一个多线程的 Web 服务器</a></li></ol> <ol class="chapter"><li class="chapter-item expanded affix "><a href="../index.html" class="active">序和前言</a></li><li class="chapter-item expanded "><a href="Ch01_Getting_Started.html"><strong aria-hidden="true">1.</strong> 入门</a></li><li class="chapter-item expanded "><a href="Ch02_Programming_a_Guessing_Game.html"><strong aria-hidden="true">2.</strong> 编写一个猜数游戏</a></li><li class="chapter-item expanded "><a href="Ch03_Common_Programming_Concepts.html"><strong aria-hidden="true">3.</strong> 常见编程概念</a></li><li class="spacer"></li><li class="chapter-item expanded affix "><li class="part-title">进阶</li><li class="chapter-item expanded "><a href="Ch04_Understanding_Ownership.html"><strong aria-hidden="true">4.</strong> “掌握” 所有权</a></li><li class="chapter-item expanded "><a href="Ch05_Using_Structs_to_Structure_Related_Data.html"><strong aria-hidden="true">5.</strong> 使用结构体来对相关数据进行架构</a></li><li class="chapter-item expanded "><a href="Ch06_Enums_and_Pattern_Matching.html"><strong aria-hidden="true">6.</strong> 枚举与模式匹配</a></li><li class="chapter-item expanded "><a href="Ch07_Managing_Growing_Projects_with_Packages_Crates_and_Modules.html"><strong aria-hidden="true">7.</strong> 使用包、代码箱与模组对日趋增长的项目进行管理</a></li><li class="chapter-item expanded "><a href="Ch08_Common_Collections.html"><strong aria-hidden="true">8.</strong> 常用集合数据结构</a></li><li class="chapter-item expanded "><a href="Ch09_Error_Handling.html"><strong aria-hidden="true">9.</strong> 错误的处理</a></li><li class="spacer"></li><li class="chapter-item expanded affix "><li class="part-title">深入掌握</li><li class="chapter-item expanded "><a href="Ch10_Generic_Types_Traits_and_Lifetimes.html"><strong aria-hidden="true">10.</strong> 泛型、特质与生命周期</a></li><li class="chapter-item expanded "><a href="Ch11_Writing_Automated_Tests.html"><strong aria-hidden="true">11.</strong> 编写自动化测试</a></li><li class="spacer"></li><li class="chapter-item expanded affix "><li class="part-title">上篇总结 - 实操</li><li class="chapter-item expanded "><a href="Ch12_An_IO_Project_Building_a_Command_Line_Program.html"><strong aria-hidden="true">12.</strong> 一个文件系统 I/O 项目:构建一个命令行程序</a></li><li class="spacer"></li><li class="chapter-item expanded affix "><li class="part-title">下篇</li><li class="chapter-item expanded "><a href="Ch13_Functional_Language_Features_Iterators_and_Closures.html"><strong aria-hidden="true">13.</strong> 函数式编程语言特性:迭代器与闭包</a></li><li class="chapter-item expanded "><a href="Ch14_More_about_Cargo_and_Crates-io.html"><strong aria-hidden="true">14.</strong> Cargo 的其他方面及 Crates.io</a></li><li class="chapter-item expanded "><a href="Ch15_Smart_Pointers.html"><strong aria-hidden="true">15.</strong> 灵巧指针</a></li><li class="chapter-item expanded "><a href="Ch16_Fearless_Concurrency.html"><strong aria-hidden="true">16.</strong> 无惧并发</a></li><li class="chapter-item expanded "><a href="Ch17_Object_Oriented_Programming_Features_of_Rust.html"><strong aria-hidden="true">17.</strong> Rust 的面向对象编程特性</a></li><li class="chapter-item expanded "><a href="Ch18_Patterns_and_Matching.html"><strong aria-hidden="true">18.</strong> 模式与匹配</a></li><li class="chapter-item expanded "><a href="Ch19_Advanced_Features.html"><strong aria-hidden="true">19.</strong> 先进特性</a></li><li class="chapter-item expanded "><a href="Ch20_Final_Project_Building_a_Multithreaded_Web_Server.html"><strong aria-hidden="true">20.</strong> 最后项目:构建一个多线程的 Web 服务器</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered">
<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> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper"> <h3 class="menu-title">Yet another Chinese rust-lang book.</h3>
<div class="page"> <div class="right-buttons">
<div id="menu-bar-hover-placeholder"></div> <a href="https://java.xfoss.com" title="Head First Java 中文版" aria-label="Head First Java 中文版">
<div id="menu-bar" class="menu-bar sticky bordered"> ☕·Head First Java 中文
<div class="left-buttons"> </a>
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <a href="https://ccna60d.xfoss.com" title="CCNA in 60 days" aria-label="CCNA 60 天">
<i class="fa fa-bars"></i> 🖧·60 天通过 CCNA
</button> </a>
<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"> <a href="https://snippets.xfoss.com" title="代码片段与技术笔记code snippets and tech notes"
<i class="fa fa-paint-brush"></i> aria-label="代码片段与技术笔记code snippets and tech notes">
</button> ✨·代码片段与技术笔记
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu"> </a>
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li> <a href="https://ts.xfoss.com" title="TypeScript 教程" aria-label="TypeScript 教程">
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li> 📜·TypeScript 教程
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li> </a>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <a href="https://books.xfoss.com" title="捐赠donation" aria-label="捐赠donation">
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> 🎁·捐赠donation
</ul> </a>
<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">Yet another Chinese rust-lang book.</h1> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
<div class="right-buttons"> </div>
<a href="print.html" title="Print this book" aria-label="Print this book"> </div>
<i id="print-button" class="fa fa-print"></i>
</a>
</div> <div id="search-wrapper" class="hidden">
</div> <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>
<div id="search-wrapper" class="hidden"> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<form id="searchbar-outer" class="searchbar-outer"> <script>
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
</form> document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
<div id="searchresults-outer" class="searchresults-outer hidden"> Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
<div id="searchresults-header" class="searchresults-header"></div> link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
<ul id="searchresults"> });
</ul> </script>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <div id="content" class="content">
<script> <main><div class="sidetoc"><nav class="pagetoc"></nav></div>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible'); <h1 id="rust-编程语言"><a class="header" href="#rust-编程语言">Rust 编程语言</a></h1>
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><div class="sidetoc"><nav class="pagetoc"></nav></div>
<h1 id="rust-编程语言"><a class="header" href="#rust-编程语言">Rust 编程语言</a></h1>
<p>原著:<a href="https://doc.rust-lang.org/book/">The Rust Programming Language</a></p> <p>原著:<a href="https://doc.rust-lang.org/book/">The Rust Programming Language</a></p>
<p><em>原作者Steve Klabnik 与 Carol Nichols, 及 Rust 社区</em></p> <p><em>原作者Steve Klabnik 与 Carol Nichols, 及 Rust 社区</em></p>
<p>此版本的教材,假定安装了 Rust <code>1.67.1</code> (发布于 2023-02-09或更新版本。请参阅 <a href="docs/Ch01_Getting_Started.html#Installation">第 1 章的 “安装” 小节</a> 进行安装,或对已安装的 Rust 进行升级。</p> <p>此版本的教材,假定安装了 Rust <code>1.67.1</code> (发布于 2023-02-09或更新版本。请参阅 <a href="docs/Ch01_Getting_Started.html#Installation">第 1 章的 “安装” 小节</a> 进行安装,或对已安装的 Rust 进行升级。</p>
@ -199,65 +216,65 @@ rustc 1.68.0 (2c8cc3432 2023-03-06)
<p>最后,还有一些包含了这门语言的有用信息的附录,这些附录则更多的像是参考的形式。附录 A 涵盖了 Rust 的关键字,附录 B 涵盖了 Rust 的运算符和符号,附录 C 涵盖了由标准库所提供的那些派生特质derivable traits附录 D 涵盖了一些有用的开发工具,还有附录 E 对 Rust 版本进行了解释。</p> <p>最后,还有一些包含了这门语言的有用信息的附录,这些附录则更多的像是参考的形式。附录 A 涵盖了 Rust 的关键字,附录 B 涵盖了 Rust 的运算符和符号,附录 C 涵盖了由标准库所提供的那些派生特质derivable traits附录 D 涵盖了一些有用的开发工具,还有附录 E 对 Rust 版本进行了解释。</p>
<p>阅读本书并无定法:你要跳着去读,也是可以的!在遇到疑惑时,或许就不得不跳回去看看了。你只要怎么有效就行了。</p> <p>阅读本书并无定法:你要跳着去读,也是可以的!在遇到疑惑时,或许就不得不跳回去看看了。你只要怎么有效就行了。</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="next" href="Ch01_Getting_Started.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Ch01_Getting_Started.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="next" href="Ch01_Getting_Started.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav> </nav>
</div>
</div> </div>
<!-- Livereload script (if served using the cli tool) --> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<script>
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; <a rel="next" href="Ch01_Getting_Started.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
const wsAddress = wsProtocol + "//" + location.host + "/" + "__livereload"; <i class="fa fa-angle-right"></i>
const socket = new WebSocket(wsAddress); </a>
socket.onmessage = function (event) { </nav>
if (event.data === "reload") {
socket.close(); </div>
location.reload();
<!-- Livereload script (if served using the cli tool) -->
<script>
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsAddress = wsProtocol + "//" + location.host + "/" + "__livereload";
const socket = new WebSocket(wsAddress);
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
} }
}; </script>
window.onbeforeunload = function() {
socket.close();
}
</script>
<script> <script>
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js"></script> <script src="elasticlunr.min.js"></script>
<script src="mark.min.js"></script> <script src="mark.min.js"></script>
<script src="searcher.js"></script> <script src="searcher.js"></script>
<script src="clipboard.min.js"></script> <script src="clipboard.min.js"></script>
<script src="highlight.js"></script> <script src="highlight.js"></script>
<script src="book.js"></script> <script src="book.js"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
<script src="theme/pagetoc.js"></script> <script src="theme/pagetoc.js"></script>
</div> </div>
</body> </body>
</html> </html>

View File

@ -58,49 +58,49 @@
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
<script> <script>
var path_to_root = "{{ path_to_root }}"; var path_to_root = "{{ path_to_root }}";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}"; var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
</script> </script>
<!-- Work around some values being stored in localStorage wrapped in quotes --> <!-- Work around some values being stored in localStorage wrapped in quotes -->
<script> <script>
try { try {
var theme = localStorage.getItem('mdbook-theme'); var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar'); var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) { if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1)); localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
} }
if (sidebar.startsWith('"') && sidebar.endsWith('"')) { if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1)); localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
} }
} catch (e) { } } catch (e) { }
</script> </script>
<!-- Set the theme before any content is loaded, prevents flash --> <!-- Set the theme before any content is loaded, prevents flash -->
<script> <script>
var theme; var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; } if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html'); var html = document.querySelector('html');
html.classList.remove('no-js') html.classList.remove('no-js')
html.classList.remove('{{ default_theme }}') html.classList.remove('{{ default_theme }}')
html.classList.add(theme); html.classList.add(theme);
html.classList.add('js'); html.classList.add('js');
</script> </script>
<!-- Hide / unhide sidebar before it is displayed --> <!-- Hide / unhide sidebar before it is displayed -->
<script> <script>
var html = document.querySelector('html'); var html = document.querySelector('html');
var sidebar = null; var sidebar = null;
if (document.body.clientWidth >= 1080) { if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible'; sidebar = sidebar || 'visible';
} else { } else {
sidebar = 'hidden'; sidebar = 'hidden';
} }
html.classList.remove('sidebar-visible'); html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar); html.classList.add("sidebar-" + sidebar);
</script> </script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
@ -140,11 +140,6 @@ html.classList.add("sidebar-" + sidebar);
<h3 class="menu-title">{{ book_title }}</h3> <h3 class="menu-title">{{ book_title }}</h3>
<div class="right-buttons"> <div class="right-buttons">
<a href="https://rust-lang.xfoss.com" title="Yet another Chinese rust-lang book"
aria-label="Yet another Chinese rust-lang book">
·Rust 官方书中文
</a>
<a href="https://java.xfoss.com" title="Head First Java 中文版" aria-label="Head First Java 中文版"> <a href="https://java.xfoss.com" title="Head First Java 中文版" aria-label="Head First Java 中文版">
☕·Head First Java 中文 ☕·Head First Java 中文
</a> </a>
@ -152,12 +147,15 @@ html.classList.add("sidebar-" + sidebar);
🖧·60 天通过 CCNA 🖧·60 天通过 CCNA
</a> </a>
<a href="https://snippets.xfoss.com" title="代码片段与技术笔记code snippets and tech notes" <a href="https://snippets.xfoss.com" title="代码片段与技术笔记code snippets and tech notes"
aria-label="代码片段与技术笔记code snippets and tech notes"> aria-label="代码片段与技术笔记code snippets and tech notes">
✨·代码片段与技术笔记 ✨·代码片段与技术笔记
</a> </a>
<a href="https://ts.xfoss.com" title="TypeScript 教程" aria-label="TypeScript 教程"> <a href="https://ts.xfoss.com" title="TypeScript 教程" aria-label="TypeScript 教程">
📜·TypeScript 教程 📜·TypeScript 教程
</a> </a>
<a href="https://books.xfoss.com" title="捐赠donation" aria-label="捐赠donation">
🎁·捐赠donation
</a>
{{#if print_enable}} {{#if print_enable}}
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book"> <a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">
@ -194,10 +192,10 @@ html.classList.add("sidebar-" + sidebar);
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script> <script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible'); document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible'); document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) { Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1); link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
}); });
</script> </script>
<div id="content" class="content"> <div id="content" class="content">
@ -244,18 +242,18 @@ Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
<!-- Livereload script (if served using the cli tool) --> <!-- Livereload script (if served using the cli tool) -->
<script> <script>
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}"; const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
const socket = new WebSocket(wsAddress); const socket = new WebSocket(wsAddress);
socket.onmessage = function (event) { socket.onmessage = function (event) {
if (event.data === "reload") { if (event.data === "reload") {
socket.close(); socket.close();
location.reload(); location.reload();
} }
}; };
window.onbeforeunload = function() { window.onbeforeunload = function() {
socket.close(); socket.close();
} }
</script> </script>
{{/if}} {{/if}}
@ -264,17 +262,17 @@ window.onbeforeunload = function() {
<script> <script>
var localAddrs = ["localhost", "127.0.0.1", ""]; var localAddrs = ["localhost", "127.0.0.1", ""];
// make sure we don't activate google analytics if the developer is // make sure we don't activate google analytics if the developer is
// inspecting the book locally... // inspecting the book locally...
if (localAddrs.indexOf(document.location.hostname) === -1) { if (localAddrs.indexOf(document.location.hostname) === -1) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{google_analytics}}', 'auto'); ga('create', '{{google_analytics}}', 'auto');
ga('send', 'pageview'); ga('send', 'pageview');
} }
</script> </script>
{{/if}} {{/if}}
@ -317,16 +315,16 @@ if (localAddrs.indexOf(document.location.hostname) === -1) {
{{#if mathjax_support}} {{#if mathjax_support}}
<script> <script>
window.addEventListener('load', function() { window.addEventListener('load', function() {
MathJax.Hub.Register.StartupHook('End', function() { MathJax.Hub.Register.StartupHook('End', function() {
window.setTimeout(window.print, 100); window.setTimeout(window.print, 100);
}); });
}); });
</script> </script>
{{else}} {{else}}
<script> <script>
window.addEventListener('load', function() { window.addEventListener('load', function() {
window.setTimeout(window.print, 100); window.setTimeout(window.print, 100);
}); });
</script> </script>
{{/if}} {{/if}}
{{/if}} {{/if}}