help_tmpl.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. app.templates.helpPage = function () {
  2. const ctrlKey = $.isMac() ? "cmd" : "ctrl";
  3. const navKey = $.isMac() ? "cmd" : "alt";
  4. const arrowScroll = app.settings.get("arrowScroll");
  5. const aliases = Object.entries(app.models.Entry.ALIASES);
  6. const middle = Math.ceil(aliases.length / 2);
  7. const aliases_one = aliases.slice(0, middle);
  8. const aliases_two = aliases.slice(middle);
  9. return `\
  10. <nav class="_toc" role="directory">
  11. <h3 class="_toc-title">Table of Contents</h3>
  12. <ul class="_toc-list">
  13. <li><a href="#managing-documentations">Managing Documentations</a>
  14. <li><a href="#search">Search</a>
  15. <li><a href="#shortcuts">Keyboard Shortcuts</a>
  16. <li><a href="#aliases">Search Aliases</a>
  17. </ul>
  18. </nav>
  19. <h1 class="_lined-heading">User Guide</h1>
  20. <h2 class="_block-heading" id="managing-documentations">Managing Documentations</h2>
  21. <p>
  22. Documentations can be enabled and disabled in the <a href="/settings">Preferences</a>.
  23. Alternatively, you can enable a documentation by searching for it in the main search
  24. and clicking the "Enable" link in the results.
  25. For faster and better search, only enable the documentations you plan on actively using.
  26. <p>
  27. Once a documentation is enabled, it becomes part of the search and its content can be downloaded for offline access — and faster page loads when online — in the <a href="/offline">Offline</a> area.
  28. <h2 class="_block-heading" id="search">Search</h2>
  29. <p>
  30. The search is case-insensitive and ignores whitespace. It supports fuzzy matching
  31. (e.g. <code class="_label">bgcp</code> matches <code class="_label">background-clip</code>)
  32. as well as aliases (full list <a href="#aliases">below</a>).
  33. <dl>
  34. <dt id="doc_search">Searching a single documentation
  35. <dd>
  36. The search can be scoped to a single documentation by typing its name (or an abbreviation)
  37. and pressing <code class="_label">tab</code> (<code class="_label">space</code>&nbsp;on mobile).
  38. For example, to search the JavaScript documentation, enter <code class="_label">javascript</code>
  39. or <code class="_label">js</code>, then <code class="_label">tab</code>.<br>
  40. To clear the current scope, empty the search field and hit <code class="_label">backspace</code> or
  41. <code class="_label">esc</code>.
  42. <dt id="url_search">Prefilling the search field
  43. <dd>
  44. The search can be prefilled from the URL by visiting <a href="/#q=keyword" target="_top">devdocs.io/#q=keyword</a>.
  45. Characters after <code class="_label">#q=</code> will be used as search query.<br>
  46. To search a single documentation, add its name (or an abbreviation) and a space before the keyword:
  47. <a href="/#q=js%20date" target="_top">devdocs.io/#q=js date</a>.
  48. <dt id="browser_search">Searching using the address bar
  49. <dd>
  50. DevDocs supports OpenSearch. It can easily be installed as a search engine on most web browsers:
  51. <ul>
  52. <li>On Chrome, the setup is done automatically. Simply press <code class="_label">tab</code> when devdocs.io is autocompleted
  53. in the omnibox (to set a custom keyword, click <em>Manage search engines\u2026</em> in Chrome's settings).
  54. <li>On Firefox, <a href="https://support.mozilla.org/en-US/kb/add-or-remove-search-engine-firefox#w_add-a-search-engine-from-the-address-bar">add the search from the address bar</a>:
  55. Click ••• in the address bar, and select <em>Add Search Engine</em>. Then, you can add a keyword for this search engine in the preferences.
  56. </dl>
  57. <p>
  58. <i>Note: the above search features only work for documentations that are enabled.</i>
  59. <h2 class="_block-heading" id="shortcuts">Keyboard Shortcuts</h2>
  60. <h3 class="_shortcuts-title">Sidebar</h3>
  61. <dl class="_shortcuts-dl">
  62. <dt class="_shortcuts-dt">
  63. ${arrowScroll ? '<code class="_shortcut-code">shift</code> + ' : ""}
  64. <code class="_shortcut-code">&darr;</code>
  65. <code class="_shortcut-code">&uarr;</code>
  66. <dd class="_shortcuts-dd">Move selection
  67. <dt class="_shortcuts-dt">
  68. ${arrowScroll ? '<code class="_shortcut-code">shift</code> + ' : ""}
  69. <code class="_shortcut-code">&rarr;</code>
  70. <code class="_shortcut-code">&larr;</code>
  71. <dd class="_shortcuts-dd">Show/hide sub-list
  72. <dt class="_shortcuts-dt">
  73. <code class="_shortcut-code">enter</code>
  74. <dd class="_shortcuts-dd">Open selection
  75. <dt class="_shortcuts-dt">
  76. <code class="_shortcut-code">${ctrlKey} + enter</code>
  77. <dd class="_shortcuts-dd">Open selection in a new tab
  78. <dt class="_shortcuts-dt">
  79. <code class="_shortcut-code">alt + r</code>
  80. <dd class="_shortcuts-dd">Reveal current page in sidebar
  81. </dl>
  82. <h3 class="_shortcuts-title">Browsing</h3>
  83. <dl class="_shortcuts-dl">
  84. <dt class="_shortcuts-dt">
  85. <code class="_shortcut-code">${navKey} + &larr;</code>
  86. <code class="_shortcut-code">${navKey} + &rarr;</code>
  87. <dd class="_shortcuts-dd">Go back/forward
  88. <dt class="_shortcuts-dt">
  89. ${
  90. arrowScroll
  91. ? '<code class="_shortcut-code">&darr;</code> ' +
  92. '<code class="_shortcut-code">&uarr;</code>'
  93. : '<code class="_shortcut-code">alt + &darr;</code> ' +
  94. '<code class="_shortcut-code">alt + &uarr;</code>' +
  95. "<br>" +
  96. '<code class="_shortcut-code">shift + &darr;</code> ' +
  97. '<code class="_shortcut-code">shift + &uarr;</code>'
  98. }
  99. <dd class="_shortcuts-dd">Scroll step by step<br><br>
  100. <dt class="_shortcuts-dt">
  101. <code class="_shortcut-code">space</code>
  102. <code class="_shortcut-code">shift + space</code>
  103. <dd class="_shortcuts-dd">Scroll screen by screen
  104. <dt class="_shortcuts-dt">
  105. <code class="_shortcut-code">${ctrlKey} + &uarr;</code>
  106. <code class="_shortcut-code">${ctrlKey} + &darr;</code>
  107. <dd class="_shortcuts-dd">Scroll to the top/bottom
  108. <dt class="_shortcuts-dt">
  109. <code class="_shortcut-code">alt + f</code>
  110. <dd class="_shortcuts-dd">Focus first link in the content area<br>(press tab to focus the other links)
  111. </dl>
  112. <h3 class="_shortcuts-title">App</h3>
  113. <dl class="_shortcuts-dl">
  114. <dt class="_shortcuts-dt">
  115. <code class="_shortcut-code">ctrl + ,</code>
  116. <dd class="_shortcuts-dd">Open preferences
  117. <dt class="_shortcuts-dt">
  118. <code class="_shortcut-code">esc</code>
  119. <dd class="_shortcuts-dd">Clear search field / reset UI
  120. <dt class="_shortcuts-dt">
  121. <code class="_shortcut-code">?</code>
  122. <dd class="_shortcuts-dd">Show this page
  123. </dl>
  124. <h3 class="_shortcuts-title">Miscellaneous</h3>
  125. <dl class="_shortcuts-dl">
  126. <dt class="_shortcuts-dt">
  127. <code class="_shortcut-code">alt + c</code>
  128. <dd class="_shortcuts-dd">Copy URL of original page
  129. <dt class="_shortcuts-dt">
  130. <code class="_shortcut-code">alt + o</code>
  131. <dd class="_shortcuts-dd">Open original page
  132. <dt class="_shortcuts-dt">
  133. <code class="_shortcut-code">alt + g</code>
  134. <dd class="_shortcuts-dd">Search on Google
  135. <dt class="_shortcuts-dt">
  136. <code class="_shortcut-code">alt + s</code>
  137. <dd class="_shortcuts-dd">Search on Stack Overflow
  138. <dt class="_shortcuts-dt">
  139. <code class="_shortcut-code">alt + d</code>
  140. <dd class="_shortcuts-dd">Search on DuckDuckGo
  141. </dl>
  142. <p class="_note _note-green">
  143. <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or
  144. continue to type and it will refocus the search field and start showing new results.
  145. <h2 class="_block-heading" id="aliases">Search Aliases</h2>
  146. <div class="_aliases">
  147. <table>
  148. <tr>
  149. <th>Word
  150. <th>Alias
  151. ${aliases_one
  152. .map(
  153. ([key, value]) =>
  154. `<tr><td class=\"_code\">${key}<td class=\"_code\">${value}`,
  155. )
  156. .join("")}
  157. </table>
  158. <table>
  159. <tr>
  160. <th>Word
  161. <th>Alias
  162. ${aliases_two
  163. .map(
  164. ([key, value]) =>
  165. `<tr><td class=\"_code\">${key}<td class=\"_code\">${value}`,
  166. )
  167. .join("")}
  168. </table>
  169. </div>
  170. <p>Feel free to suggest new aliases on <a href="https://github.com/freeCodeCamp/devdocs/issues/new">GitHub</a>.\
  171. `;
  172. };