index.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>QuestPDF Previewer</title>
  6. <style>
  7. html {
  8. background-color: #333;
  9. }
  10. body {
  11. margin: 0;
  12. }
  13. embed {
  14. border: none;
  15. position: absolute;
  16. left: 0;
  17. top: 0;
  18. width: 100%;
  19. height: 100%;
  20. }
  21. .alert {
  22. position: absolute;
  23. top: 0;
  24. left: 0;
  25. right: 0;
  26. width: 100%;
  27. padding: 8px 16px;
  28. color: #FFFA;
  29. font-family: sans-serif;
  30. font-size: 14px;
  31. line-height: 1.5;
  32. box-shadow: 0 5px 5px -3px rgba(0,0,0,.2),0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12) !important;
  33. }
  34. #recommended-alert {
  35. background-color: #616161;
  36. }
  37. #recommended-alert .close {
  38. color: #FFF;
  39. cursor: pointer;
  40. }
  41. #connection-issue-alert {
  42. visibility: hidden;
  43. background-color: #B71C1C;
  44. color: white;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <embed id="previewer" src="/render#toolbar=0&scrollbar=0" />
  50. <div id="recommended-alert" class="alert">
  51. The recommended browser for this previewer is Microsoft Edge. It does preserve document scroll position when refreshing document, giving better overall experience.
  52. <a class="close" onclick="closeRecommendation()">Click to close</a>
  53. </div>
  54. <div id="connection-issue-alert" class="alert">
  55. Cannot connect to QuestPDF previewer host. Possibly your debugging session has ended. Please close this browser.
  56. </div>
  57. <script>
  58. const recommendationAlert = document.getElementById("recommended-alert");
  59. const connectionIssueAlert = document.getElementById("connection-issue-alert");
  60. function closeRecommendation() {
  61. recommendationAlert.parentElement.removeChild(recommendationAlert);
  62. localStorage.setItem("show-recommendation-alert", 'false');
  63. }
  64. function refreshRecommendation() {
  65. const showRecommendation = localStorage.getItem("show-recommendation-alert");
  66. if (showRecommendation !== 'false')
  67. return;
  68. recommendationAlert.parentElement.removeChild(recommendationAlert);
  69. }
  70. function changeConnectionIssueAlertVisibility(show) {
  71. connectionIssueAlert.style.setProperty("visibility", show ? "visible" : "hidden");
  72. }
  73. async function refreshDocumentLoop() {
  74. window.addEventListener("change", () => reloading = true);
  75. while (true) {
  76. try {
  77. const response = await fetch('/listen');
  78. const value = await response.text();
  79. if (value === "true")
  80. window.location.reload();
  81. changeConnectionIssueAlertVisibility(false);
  82. }
  83. catch {
  84. changeConnectionIssueAlertVisibility(true);
  85. }
  86. }
  87. }
  88. refreshRecommendation();
  89. refreshDocumentLoop();
  90. </script>
  91. </body>
  92. </html>