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 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. font-size: 2em;
  14. font-family: sans-serif;
  15. }
  16. #_overlay {
  17. z-index: 2;
  18. will-change: opacity;
  19. }
  20. #_main {
  21. z-index: 1;
  22. }
  23. #_msg {
  24. z-index: 3;
  25. position: absolute;
  26. top: 6px;
  27. right: 6px;
  28. backgrounud: white;
  29. display: none;
  30. font-size: 15px;
  31. }
  32. #_msg.active {
  33. display: block;
  34. }
  35. ._content {
  36. background: white;
  37. position: absolute;
  38. width: 100%;
  39. height: 100%;
  40. top: 0%;
  41. left: 0px;
  42. display: flex;
  43. align-items: center;
  44. justify-content: center;
  45. }
  46. ._content ._wrapper {
  47. display: inline-block;
  48. text-align: center;
  49. }
  50. ._content h1 { font-size: 2em }
  51. ._content h2 { font-size: 1.4em }
  52. ._content h3 { font-size: 1.2em }
  53. ._content p { font-size: 2.2em }
  54. ._content .fullscreen {
  55. position: absolute;
  56. width: 100%;
  57. height: 100%;
  58. top: 0px;
  59. left: 50%;
  60. -moz-transform: translateX(-50%);
  61. -ms-transform: translateX(-50%);
  62. -webkit-transform: translateX(-50%);
  63. transform: translateX(-50%);
  64. }
  65. ._content img.fullscreen {
  66. width: auto;
  67. }
  68. ._content img.fullscreen.stretch {
  69. width: 100%;
  70. }
  71. ._content p,
  72. ._content ul,
  73. ._content ol {
  74. text-align: left;
  75. line-height: 1.3em;
  76. }
  77. #_overlay {
  78. transition: opacity <<transition_time>>s, transform <<transition_time>>s;
  79. opacity: 1;
  80. }
  81. #_overlay.hidden {
  82. opacity: 0;
  83. transform: scale(1.1);
  84. }
  85. </style>
  86. </head>
  87. <body>
  88. <div id="_main" class="_content"></div>
  89. <div id="_overlay" class="_content"></div>
  90. <div id="_msg"></div>
  91. <!-- Fetch polyfill -->
  92. <script src="/polyfills.js"></script>
  93. <script>
  94. (function fullscreen() {
  95. var elem = document.body;
  96. var rFS = elem.requestFullScreen ||
  97. elem.msRequestFullScreen ||
  98. elem.mozRequestFullScreen ||
  99. elem.webkitRequestFullScreen;
  100. if (rFS)
  101. rFS.call(elem);
  102. })();
  103. var overlay = () => document.querySelector("#_overlay");
  104. var main = () => document.querySelector("#_main");
  105. var msg = () => document.querySelector("#_msg");
  106. function message(str) {
  107. msg().innerHTML = str;
  108. msg().className = "active";
  109. }
  110. // Swap the IDs of two elements
  111. function swap(elem1, elem2) {
  112. var tmp = elem1.id;
  113. elem1.id = elem2.id;
  114. elem2.id = tmp;
  115. }
  116. // Change slides with a transition
  117. function update(name) {
  118. overlay().innerHTML = "";
  119. overlay().className = "_content";
  120. swap(main(), overlay());
  121. fetch("/slide")
  122. .then(response => response.text())
  123. .then(text => {
  124. history.replaceState({}, "", "/"+name+"/");
  125. main().innerHTML = "<div class='_wrapper'>"+text+"</div>";
  126. setTimeout(() => {
  127. overlay().className = "_content hidden";
  128. }, 1000);
  129. })
  130. .catch(err => console.error(err));
  131. }
  132. function reload() {
  133. message("Server down, waiting");
  134. var i = setInterval(() => {
  135. fetch("/")
  136. .then(() => {
  137. history.replaceState({}, "", "/");
  138. location.reload();
  139. })
  140. .catch(() => {});
  141. }, 1000);
  142. }
  143. function await() {
  144. // Wait for the next slide change, then update again
  145. console.log("fetching");
  146. fetch("/await", { method: "POST" })
  147. .then(response => response.json())
  148. .then(obj => {
  149. console.log("fetched", JSON.stringify(obj));
  150. if (obj.evt === "next") {
  151. update(obj.args.name);
  152. } else if (obj.evt === "reload") {
  153. return reload();
  154. } else {
  155. console.log("Unknown event: "+obj.evt);
  156. }
  157. await();
  158. })
  159. .catch(err => { console.error(err); await(); });
  160. }
  161. await();
  162. fetch("/init")
  163. .then(response => response.text())
  164. .then(name => update(name));
  165. </script>
  166. </body>
  167. </html>