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

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