Pictures!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Slides</title>
  7. <style>
  8. html, body {
  9. margin: 0px;
  10. padding: 0px;
  11. height: 100%;
  12. overflow: hidden;
  13. }
  14. #_overlay {
  15. z-index: 2;
  16. will-change: opacity;
  17. }
  18. #_main {
  19. z-index: 1;
  20. }
  21. ._content {
  22. background: white;
  23. position: absolute;
  24. width: 100%;
  25. height: 100%;
  26. top: 0%;
  27. left: 0px;
  28. display: flex;
  29. align-items: center;
  30. justify-content: center;
  31. }
  32. ._content ._wrapper {
  33. display: inline-block;
  34. text-align: center;
  35. }
  36. ._content h1 { font-size: 5em }
  37. ._content h2 { font-size: 4.5em }
  38. ._content h3 { font-size: 4em }
  39. ._content p { font-size: 2.2em }
  40. ._content .fullscreen {
  41. position: absolute;
  42. width: 100%;
  43. height: 100%;
  44. top: 0px;
  45. left: 50%;
  46. -moz-transform: translateX(-50%);
  47. -ms-transform: translateX(-50%);
  48. -webkit-transform: translateX(-50%);
  49. transform: translateX(-50%);
  50. }
  51. ._content img.fullscreen {
  52. width: auto;
  53. }
  54. #_overlay {
  55. transition: opacity <<transition_time>>s;
  56. opacity: 1;
  57. }
  58. #_overlay.hidden {
  59. opacity: 0;
  60. }
  61. </style>
  62. </head>
  63. <body>
  64. <div id="_main" class="_content"></div>
  65. <div id="_overlay" class="_content"></div>
  66. <!-- Fetch polyfill -->
  67. <script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
  68. <script>
  69. var overlay = () => document.querySelector("#_overlay");
  70. var main = () => document.querySelector("#_main");
  71. // Swap the IDs of two elements
  72. function swap(elem1, elem2) {
  73. var tmp = elem1.id;
  74. elem1.id = elem2.id;
  75. elem2.id = tmp;
  76. }
  77. // Change slides with a transition
  78. function update(name) {
  79. overlay().innerHTML = "";
  80. overlay().className = "_content";
  81. swap(main(), overlay());
  82. fetch("/slide")
  83. .then(response => response.text())
  84. .then(text => {
  85. history.replaceState({}, "", "/"+name+"/");
  86. main().innerHTML = "<div class='_wrapper'>"+text+"</div>";
  87. setTimeout(() => {
  88. overlay().className = "_content hidden";
  89. }, 1000);
  90. })
  91. .catch(err => console.error(err));
  92. }
  93. function reload() {
  94. var i = setInterval(() => {
  95. fetch("/")
  96. .then(() => {
  97. history.replaceState({}, "", "/");
  98. location.reload();
  99. })
  100. .catch(() => {});
  101. }, 1000);
  102. }
  103. function await() {
  104. // Wait for the next slide change, then update again
  105. console.log("fetching");
  106. fetch("/await")
  107. .then(response => response.json())
  108. .then(obj => {
  109. console.log("fetched", JSON.stringify(obj));
  110. if (obj.evt === "next") {
  111. update(obj.args.name);
  112. } else if (obj.evt === "reload") {
  113. return reload();
  114. } else {
  115. console.log("Unknown event: "+obj.evt);
  116. }
  117. await();
  118. })
  119. .catch(err => { console.error(err); await(); });
  120. }
  121. await();
  122. fetch("/init")
  123. .then(response => response.text())
  124. .then(name => update(name));
  125. </script>
  126. </body>
  127. </html>