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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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: 1.4em }
  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 ul,
  79. ._content ol {
  80. text-align: left;
  81. line-height: 1.3em;
  82. }
  83. #_overlay {
  84. transition: opacity <<transition_time>>s, transform <<transition_time>>s;
  85. opacity: 1;
  86. }
  87. #_overlay.hidden {
  88. opacity: 0;
  89. transform: scale(1.1);
  90. }
  91. </style>
  92. </head>
  93. <body>
  94. <div id="_main" class="_content"></div>
  95. <div id="_overlay" class="_content"></div>
  96. <div id="_msg"></div>
  97. <!-- Fetch polyfill -->
  98. <script src="/polyfills.js"></script>
  99. <script>
  100. (function fullscreen() {
  101. var elem = document.body;
  102. var rFS = elem.requestFullScreen ||
  103. elem.msRequestFullScreen ||
  104. elem.mozRequestFullScreen ||
  105. elem.webkitRequestFullScreen;
  106. if (rFS)
  107. rFS.call(elem);
  108. })();
  109. var overlay = () => document.querySelector("#_overlay");
  110. var main = () => document.querySelector("#_main");
  111. var msg = () => document.querySelector("#_msg");
  112. function message(str) {
  113. msg().innerHTML = str;
  114. msg().className = "active";
  115. }
  116. // Swap the IDs of two elements
  117. function swap(elem1, elem2) {
  118. var tmp = elem1.id;
  119. elem1.id = elem2.id;
  120. elem2.id = tmp;
  121. }
  122. // Change slides with a transition
  123. function update(name) {
  124. overlay().innerHTML = "";
  125. overlay().className = "_content";
  126. swap(main(), overlay());
  127. fetch("/slide")
  128. .then(response => response.text())
  129. .then(text => {
  130. history.replaceState({}, "", "/"+name+"/");
  131. main().innerHTML = "<div class='_wrapper'>"+text+"</div>";
  132. setTimeout(() => {
  133. overlay().className = "_content hidden";
  134. }, 1000);
  135. })
  136. .catch(err => console.error(err));
  137. }
  138. function reload() {
  139. message("Server down, waiting");
  140. var i = setInterval(() => {
  141. fetch("/")
  142. .then(() => {
  143. history.replaceState({}, "", "/");
  144. location.reload();
  145. })
  146. .catch(() => {});
  147. }, 1000);
  148. }
  149. function await() {
  150. // Wait for the next slide change, then update again
  151. console.log("fetching");
  152. fetch("/await", { method: "POST" })
  153. .then(response => response.json())
  154. .then(obj => {
  155. console.log("fetched", JSON.stringify(obj));
  156. if (obj.evt === "next") {
  157. update(obj.args.name);
  158. } else if (obj.evt === "reload") {
  159. return reload();
  160. } else {
  161. console.log("Unknown event: "+obj.evt);
  162. }
  163. await();
  164. })
  165. .catch(err => { console.error(err); await(); });
  166. }
  167. await();
  168. fetch("/init")
  169. .then(response => response.text())
  170. .then(name => update(name));
  171. </script>
  172. </body>
  173. </html>