error_tmpl.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. * DS207: Consider shorter variations of null checks
  8. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
  9. */
  10. const error = function (title, text, links) {
  11. if (text == null) {
  12. text = "";
  13. }
  14. if (links == null) {
  15. links = "";
  16. }
  17. if (text) {
  18. text = `<p class="_error-text">${text}</p>`;
  19. }
  20. if (links) {
  21. links = `<p class="_error-links">${links}</p>`;
  22. }
  23. return `<div class="_error"><h1 class="_error-title">${title}</h1>${text}${links}</div>`;
  24. };
  25. const back = '<a href="#" data-behavior="back" class="_error-link">Go back</a>';
  26. app.templates.notFoundPage = () =>
  27. error(
  28. " Page not found. ",
  29. " It may be missing from the source documentation or this could be a bug. ",
  30. back,
  31. );
  32. app.templates.pageLoadError = () =>
  33. error(
  34. " The page failed to load. ",
  35. ` It may be missing from the server (try reloading the app) or you could be offline (try <a href="/offline">installing the documentation for offline usage</a> when online again).<br>
  36. If you're online and you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. `,
  37. ` ${back} &middot; <a href="/#${location.pathname}" target="_top" class="_error-link">Reload</a>
  38. &middot; <a href="#" class="_error-link" data-retry>Retry</a> `,
  39. );
  40. app.templates.bootError = () =>
  41. error(
  42. " The app failed to load. ",
  43. ` Check your Internet connection and try <a href="#" data-behavior="reload">reloading</a>.<br>
  44. If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. `,
  45. );
  46. app.templates.offlineError = function (reason, exception) {
  47. if (reason === "cookie_blocked") {
  48. return error(" Cookies must be enabled to use offline mode. ");
  49. }
  50. reason = (() => {
  51. switch (reason) {
  52. case "not_supported":
  53. return ` DevDocs requires IndexedDB to cache documentations for offline access.<br>
  54. Unfortunately your browser either doesn't support IndexedDB or doesn't make it available. `;
  55. case "buggy":
  56. return ` DevDocs requires IndexedDB to cache documentations for offline access.<br>
  57. Unfortunately your browser's implementation of IndexedDB contains bugs that prevent DevDocs from using it. `;
  58. case "private_mode":
  59. return ` Your browser appears to be running in private mode.<br>
  60. This prevents DevDocs from caching documentations for offline access.`;
  61. case "exception":
  62. return ` An error occurred when trying to open the IndexedDB database:<br>
  63. <code class="_label">${exception.name}: ${exception.message}</code> `;
  64. case "cant_open":
  65. return ` An error occurred when trying to open the IndexedDB database:<br>
  66. <code class="_label">${exception.name}: ${exception.message}</code><br>
  67. This could be because you're browsing in private mode or have disallowed offline storage on the domain. `;
  68. case "version":
  69. return ` The IndexedDB database was modified with a newer version of the app.<br>
  70. <a href="#" data-behavior="reload">Reload the page</a> to use offline mode. `;
  71. case "empty":
  72. return ' The IndexedDB database appears to be corrupted. Try <a href="#" data-behavior="reset">resetting the app</a>. ';
  73. }
  74. })();
  75. return error("Offline mode is unavailable.", reason);
  76. };
  77. app.templates.unsupportedBrowser = `\
  78. <div class="_fail">
  79. <h1 class="_fail-title">Your browser is unsupported, sorry.</h1>
  80. <p class="_fail-text">DevDocs is an API documentation browser which supports the following browsers:
  81. <ul class="_fail-list">
  82. <li>Recent versions of Firefox, Chrome, or Opera
  83. <li>Safari 11.1+
  84. <li>Edge 17+
  85. <li>iOS 11.3+
  86. </ul>
  87. <p class="_fail-text">
  88. If you're unable to upgrade, we apologize.
  89. We decided to prioritize speed and new features over support for older browsers.
  90. <p class="_fail-text">
  91. Note: if you're already using one of the browsers above, check your settings and add-ons.
  92. The app uses feature detection, not user agent sniffing.
  93. <p class="_fail-text">
  94. &mdash; <a href="https://twitter.com/DevDocs">@DevDocs</a>
  95. </div>\
  96. `;