network-error.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="color-scheme" content="dark light" />
  6. <style>
  7. body {
  8. margin: 0;
  9. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  10. color: rgba(0, 0, 0, 0.54);
  11. }
  12. .main {
  13. margin: 0 auto;
  14. width: calc(100% - 32px);
  15. max-width: 512px;
  16. margin: 14vh auto 0;
  17. }
  18. #main-title {
  19. font-size: 24px;
  20. font-weight: 500;
  21. margin-bottom: 16px;
  22. }
  23. #main-error-code {
  24. font-size: 12px;
  25. }
  26. #main-description {
  27. margin-bottom: 16px;
  28. line-height: 1.5rem;
  29. }
  30. ul {
  31. margin-top: 0;
  32. }
  33. #main-icon {
  34. background-repeat: no-repeat;
  35. width: 72px;
  36. height: 72px;
  37. margin-bottom: 40px;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div class="main">
  43. <div id="main-icon"></div>
  44. <div id="main-title"></div>
  45. <div id="main-description"></div>
  46. <div id="main-error-code"></div>
  47. </div>
  48. <script>
  49. document.body.style.backgroundColor =
  50. window.theme['pages.backgroundColor'];
  51. const url = window.errorURL;
  52. document.title = url;
  53. const errorCodeEl = document.getElementById('main-error-code');
  54. const titleEl = document.getElementById('main-title');
  55. const descriptionEl = document.getElementById('main-description');
  56. const iconEl = document.getElementById('main-icon');
  57. if (window.theme['pages.lightForeground']) {
  58. document.body.style.color = 'rgba(255, 255, 255, 0.54)';
  59. iconEl.style.filter = 'invert(1)';
  60. }
  61. if (window.location.href.split('/').length === 4) {
  62. errorCode = window.location.href.split('/')[3];
  63. }
  64. const pageUnresolvedIcon =
  65. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABIAQMAAABvIyEEAAAABlBMVEUAAABTU1OoaSf/AAAAAXRSTlMAQObYZgAAAENJREFUeF7tzbEJACEQRNGBLeAasBCza2lLEGx0CxFGG9hBMDDxRy/72O9FMnIFapGylsu1fgoBdkXfUHLrQgdfrlJN1BdYBjQQm3UAAAAASUVORK5CYII=';
  66. const info = {
  67. '-6': {
  68. title: 'Your file was not found',
  69. description: `It may have been moved or deleted.`,
  70. code: 'ERR_FILE_NOT_FOUND',
  71. },
  72. '-10': {
  73. title: 'This site can’t be reached',
  74. description: `The webpage at <b>${url}</b> might be temporarily down or it may have moved permanently to a new web address.`,
  75. code: 'ERR_ACCESS_DENIED',
  76. },
  77. '-105': {
  78. title: 'This site can’t be reached',
  79. description: `<b>${url}</b>’s server IP address could not be found.`,
  80. code: 'ERR_NAME_NOT_RESOLVED',
  81. },
  82. '-106': {
  83. title: 'No internet',
  84. description: `Try: <ul><li>Checking the network cables, modem, and router</li><li>Reconnecting to Wi-Fi</li></ul>`,
  85. code: 'ERR_INTERNET_DISCONNECTED',
  86. },
  87. '-108': {
  88. title: 'This site can’t be reached',
  89. description: `The webpage at <b>${url}</b> might be temporarily down or it may have moved permanently to a new web address.`,
  90. code: 'ERR_ADDRESS_INVALID',
  91. },
  92. '-109': {
  93. title: 'This site can’t be reached',
  94. description: `<b>${url}</b> is unreachable.`,
  95. code: 'ERR_ADDRESS_UNREACHABLE',
  96. },
  97. '-300': {
  98. title: 'This site can’t be reached',
  99. description: `The webpage at <b>${url}</b> might be temporarily down or it may have moved permanently to a new web address.`,
  100. code: 'ERR_INVALID_URL',
  101. },
  102. '-379': {
  103. title: 'This site can’t be reached',
  104. description: `The webpage at <b>${url}</b> might be temporarily down or it may have moved permanently to a new web address.`,
  105. code: 'ERR_HTTP_RESPONSE_CODE_FAILURE',
  106. },
  107. };
  108. const { title, description, code, icon } = info[errorCode];
  109. titleEl.textContent = title;
  110. descriptionEl.innerHTML = description;
  111. errorCodeEl.textContent = code;
  112. iconEl.style.backgroundImage = `url(${pageUnresolvedIcon})`;
  113. </script>
  114. </body>
  115. </html>