help_tmpl.js 8.4 KB

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